Closed NEX-S closed 2 years ago
sorry i dont know how to change lable in github...
You can try changing your TAB mapping with this.
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true })
elseif require("luasnip").expand_or_jumpable() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
else
fallback()
end
end, {
"i",
"s",
})
okay, i have changed my nvim-cmp's config and got this,
Error executing vim.schedule lua callback: ...site/pack/packer/start/nvim-cmp/lua/cmp/utils/keymap.lua:180: Expected lua string
stack traceback:
[C]: in function 'nvim_buf_get_keymap'
...site/pack/packer/start/nvim-cmp/lua/cmp/utils/keymap.lua:180: in function 'get_map'
...site/pack/packer/start/nvim-cmp/lua/cmp/utils/keymap.lua:104: in function 'listen'
...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:143: in function 'prepare'
...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/init.lua:292: in function 'callback'
.../site/pack/packer/start/nvim-cmp/lua/cmp/utils/async.lua:122: in function <.../site/pack/packer/start/nvim-cmp/lua/cmp/utils/async.lua:120>
my config is
vim.opt.completeopt = 'menu,menuone,noselect'
-- Setup nvim-cmp.
local cmp = require'cmp'
cmp.setup {
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
end,
},
window = {
-- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<A-j>'] = cmp.mapping.select_prev_item(),
['<A-k>'] = cmp.mapping.select_next_item(),
['<A-l>'] = cmp.mapping.confirm({ select = true }),
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<A-Space>'] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
['<CR>'] = cmp.mapping.confirm {
select = false,
},
["<Tab>"] = cmp.mapping(
function(fallback)
if cmp.visible() then
cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true })
elseif require("luasnip").expand_or_jumpable() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
else
fallback()
end
end, { "i", "s" }
),
sources = cmp.config.sources({
{ name = 'nvim_lsp' }, -- LSP COMPLETION
{ name = 'path' }, -- PATH COMPLETION
{ name = 'nvim_lua' }, -- LUA API COMPLETION
{ name = 'buffer' }, -- BUFFER COMPLETION
-- { name = 'vsnip' }, -- For vsnip users.
-- { name = 'luasnip' }, -- For luasnip users.
-- { name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users.
})
})
}
I've tried to use comment to locate the which config cause the error and found that if i comment the
sources = cmp.config.sources({
{ name = 'nvim_lsp' }, -- LSP COMPLETION
{ name = 'path' }, -- PATH COMPLETION
{ name = 'nvim_lua' }, -- LUA API COMPLETION
{ name = 'buffer' }, -- BUFFER COMPLETION
the error has been fixed, buf my compeletion is not working... Am i config the nvim-cmp correct? Thanks for your reply, best wish.
fixed thank you <3.
May I asking you for how to fixed that? I seem have the same problem now....
May I asking you for how to fixed that? I seem have the same problem now....
I've forgotten how to fix that :( it was a long time ago and now I'm using my own plugin, but you can still check out my old cmp's config in
https://github.com/NEX-S/nvim-config/blob/main/lua/plugins/nvim-cmp.lua
that should work now too.
if you still have questions, you can ask me on WeChat veperx
good luck :smile_cat:
Thank you for that, and I have figured out the problem.
once I remap the
fixed thank you <3.
okay, i have changed my nvim-cmp's config and got this,
Error executing vim.schedule lua callback: ...site/pack/packer/start/nvim-cmp/lua/cmp/utils/keymap.lua:180: Expected lua string stack traceback: [C]: in function 'nvim_buf_get_keymap' ...site/pack/packer/start/nvim-cmp/lua/cmp/utils/keymap.lua:180: in function 'get_map' ...site/pack/packer/start/nvim-cmp/lua/cmp/utils/keymap.lua:104: in function 'listen' ...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:143: in function 'prepare' ...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/init.lua:292: in function 'callback' .../site/pack/packer/start/nvim-cmp/lua/cmp/utils/async.lua:122: in function <.../site/pack/packer/start/nvim-cmp/lua/cmp/utils/async.lua:120>
my config is
vim.opt.completeopt = 'menu,menuone,noselect' -- Setup nvim-cmp. local cmp = require'cmp' cmp.setup { snippet = { -- REQUIRED - you must specify a snippet engine expand = function(args) require('luasnip').lsp_expand(args.body) -- For `luasnip` users. end, }, window = { -- completion = cmp.config.window.bordered(), -- documentation = cmp.config.window.bordered(), }, mapping = cmp.mapping.preset.insert({ ['<A-j>'] = cmp.mapping.select_prev_item(), ['<A-k>'] = cmp.mapping.select_next_item(), ['<A-l>'] = cmp.mapping.confirm({ select = true }), ['<C-e>'] = cmp.mapping({ i = cmp.mapping.abort(), c = cmp.mapping.close(), }), ['<C-d>'] = cmp.mapping.scroll_docs(-4), ['<C-f>'] = cmp.mapping.scroll_docs(4), ['<A-Space>'] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), ['<CR>'] = cmp.mapping.confirm { select = false, }, ["<Tab>"] = cmp.mapping( function(fallback) if cmp.visible() then cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }) elseif require("luasnip").expand_or_jumpable() then vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "") else fallback() end end, { "i", "s" } ), sources = cmp.config.sources({ { name = 'nvim_lsp' }, -- LSP COMPLETION { name = 'path' }, -- PATH COMPLETION { name = 'nvim_lua' }, -- LUA API COMPLETION { name = 'buffer' }, -- BUFFER COMPLETION -- { name = 'vsnip' }, -- For vsnip users. -- { name = 'luasnip' }, -- For luasnip users. -- { name = 'ultisnips' }, -- For ultisnips users. -- { name = 'snippy' }, -- For snippy users. }) }) }
I've tried to use comment to locate the which config cause the error and found that if i comment the
sources = cmp.config.sources({ { name = 'nvim_lsp' }, -- LSP COMPLETION { name = 'path' }, -- PATH COMPLETION { name = 'nvim_lua' }, -- LUA API COMPLETION { name = 'buffer' }, -- BUFFER COMPLETION
the error has been fixed, buf my compeletion is not working... Am i config the nvim-cmp correct? Thanks for your reply, best wish.
Thanks a lot man! I really needed this keybindings
FAQ
Announcement
Minimal reproducible full config
Im Freshman For neovim in Lua, and my English is bad :(, I was wondering how to use TAB to confirm compeletion in new configs. Maybe this sounds little bit foolish but i would appreaciate if any one can help me with this <3.
Description
.
Steps to reproduce
.
Expected behavior
.
Actual behavior
.
Additional context
.