hrsh7th / nvim-cmp

A completion plugin for neovim coded in Lua.
MIT License
8k stars 398 forks source link

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

Open KaranveerB opened 2 days ago

KaranveerB commented 2 days ago

FAQ

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

phanen commented 2 days ago

Change your terminal emulator (e.g. kitty)

or try instead of <C-;>

KaranveerB commented 1 day ago

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.