Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<C-;> cmp mapping doesn't work #2070

Closed
2 tasks done
KaranveerB opened this issue Oct 23, 2024 · 3 comments · Fixed by #2073
Closed
2 tasks done

<C-;> cmp mapping doesn't work #2070

KaranveerB opened this issue Oct 23, 2024 · 3 comments · Fixed by #2073
Labels
bug Something isn't working

Comments

@KaranveerB
Copy link
Contributor

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

Announcement

Minimal reproducible full config

if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
  set nocompatible
endif

let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/plug.vim')
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/vim-vsnip'
Plug 'neovim/nvim-lspconfig'
call plug#end()
PlugInstall | quit

" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require "cmp"
cmp.setup {
  snippet = {
    expand = function(args)
      vim.fn["vsnip#anonymous"](args.body)
    end,
  },

  mapping = {
    ['<C-;>'] = cmp.mapping.confirm({ select = true }) -- only change
  },

  sources = cmp.config.sources({
    { name = "nvim_lsp" },
    { name = "buffer" },
  }),
}
EOF

lua << EOF
local capabilities = require('cmp_nvim_lsp').default_capabilities()

require'lspconfig'.cssls.setup {
  capabilities = capabilities,
}
EOF

Description

<C-;> should confirm the action, but it does not. I'm not sure how many other key combos are affected.

On my regular config, I bisected to find the issue is from 2c93d5e. <C-;> seems to be a valid mapping for other neovim things so nvim-cmp should accept it too. 19bd8c7 doesn't fix this and the issue is present in the current latest commit 29fb485.

This may be an issue with nvim and its implementation of keytrans, but I'm busy and being lazy so I hope you'll forgive me for not looking too much more into it for now.

Steps to reproduce

  1. Bind a cmp key to "<C-;>"
  2. try to use it
  3. profit?

Expected behavior

<C-;> triggers the action it is mapped to (in the mwe, confirm)

Actual behavior

<C-;> doesn't do anything and simply adds a semicolon.

Additional context

No response

@KaranveerB KaranveerB added the bug Something isn't working label Oct 23, 2024
@phanen
Copy link
Contributor

phanen commented Oct 23, 2024

Change your terminal emulator (e.g. kitty)

or try <C-_> instead of <C-;>

@KaranveerB
Copy link
Contributor Author

KaranveerB commented Oct 23, 2024

I'm using kitty currently. I also tried adding

vim.keymap.set('n', '<C-;>', function() vim.print("hi") end, { noremap = true })

to the config and <C-;> defintely works outside of the cmp mapping.

As for your request: Fresh alacritty with no config and <C-;> with cmp doesn't work but the non-cmp <C-;> above still works.

<C-_> seems to never work. In kitty, it just zooms out the terminal, and if I bind it to no_op in the kitty config, it just sends - in insert mode. Also doesn't work in alacritty but it sends ^_ in insert mode. If I change the print("hi") keymap to be for <C-_>, it still doesn't work.

@phanen
Copy link
Contributor

phanen commented Oct 26, 2024

Maybe #1935

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants