nvim-cmp
nvim-cmp copied to clipboard
config merging does not convert vim.NIL to nil
FAQ
- [X] I have checked the FAQ and it didn't resolve my problem.
Issues
- [X] I have checked existing issues and there are no open or closed issues with the same problem.
Neovim Version
v0.7.0-dev+963-g082ff2190
Minimal reproducible full config
cmp version: dbc7229
minimal.vim
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/vim-vsnip'
"Plug 'gelguy/wilder.nvim'
"Plug 'romgrk/fzy-lua-native'
call plug#end()
PlugInstall | quit
" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require "cmp"
local cmp_types = require('cmp.types.cmp')
cmp.setup {
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-y>'] = cmp.config.disable,
['<C-e>'] = cmp.mapping.close(),
['<Down>'] = cmp.mapping.select_next_item({ behavior = cmp_types.SelectBehavior.Select }),
['<Up>'] = cmp.mapping.select_prev_item({ behavior = cmp_types.SelectBehavior.Select }),
['<C-n>'] = cmp.mapping.select_next_item({ behavior = cmp_types.SelectBehavior.Insert }),
['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp_types.SelectBehavior.Insert }),
['<CR>'] = cmp.mapping.confirm({ select = false }),
['<Tab>'] = {
i = function(fallback) -- see GH-231, GH-286
if cmp.visible() then cmp.select_next_item()
elseif has_words_before() then cmp.complete()
else fallback() end
end,
c = cmp.config.disable, -- see GH-880
},
['<S-Tab>'] = {
i = function(fallback)
if cmp.visible() then cmp.select_prev_item()
else fallback() end
end,
c = cmp.config.disable,
},
},
sources = {
{ name = "buffer" },
},
}
Note the config ['<Tab>'] = { .... c = cmp.config.disable } to disable TAB mappings in the command line.
Description
<Tab> keys are broken again. When pressing it, an error occurs.
Steps to reproduce
Press <Tab> in the command-line.
Expected behavior
Actual behavior
E5108: Error executing lua /tmp/plugged/vim-plug/nvim-cmp/lua/cmp/core.lua:113: attempt to call a userdata value
stack traceback:
/tmp/plugged/vim-plug/nvim-cmp/lua/cmp/core.lua:113: in function 'on_keymap'
/tmp/plugged/vim-plug/nvim-cmp/lua/cmp/core.lua:145: in function 'callback'
/tmp/plugged/vim-plug/nvim-cmp/lua/cmp/utils/keymap.lua:114: in function </tmp/plugged/vim-plug/nvim-cmp/lua/cmp/utils/keymap.lua:108>
/tmp/plugged/vim-plug/nvim-cmp/lua/cmp/utils/keymap.lua:244: in function </tmp/plugged/vim-plug/nvim-cmp/lua/cmp/utils/keymap.lua:243>
Additional context
This happened due to recent breaking changes in the keymappings.
Can we completely disable and prevent cmp from taking <cmp> keymaps via the "delegation" or "fallback" mechanism? As in #590, I absolutely don't want the following cmap to exist when keymaps are configured to be disabled:
c <Tab> * <Cmd>call v:lua.cmp.utils.keymap.set_map(1)<CR>
Well...
c = cmp.config.disable, -- see GH-880
The mapping config is needed? As I know the default mappings are removed.
Hi @Shougo, thanks for the comment! After today's breaking change #895, this is not needed any more. I tried removing this line, and indeed no more errors.
However, that specific line was necessary, until today; four days ago #880 required us to explicitly disable it (and now the default mapping has been removed).
Even with the explicit disabling, it should behave the same.
OK. The main problem seems cmp.config.disable does not work.
Exactly! cmp.config.disable = vim.NIL, which does not evaluate to false in lua.
I think you should simply remove c = cmp.config.disable.
But it's like a bug. I'll check it.