Changes to nvim cmp

This commit is contained in:
Afonso Franco 2023-01-06 08:49:17 +00:00
parent 9da6cf9a0b
commit 6796e50944
Signed by: afonso
GPG key ID: C459E0BB3DCEE899
3 changed files with 39 additions and 10 deletions

View file

@ -104,6 +104,8 @@ cmp.setup {
nvim_lsp = "(LSP)",
luasnip = "(Snippet)",
buffer = "(Text)",
nvim_lsp_signature_help = "(Signature)",
nvim_lua = "(Nvim LSP)",
path = "(Path)",
})[entry.source.name]
return vim_item
@ -118,8 +120,32 @@ cmp.setup {
},
sources = cmp.config.sources(
{
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "nvim_lsp",
entry_filter = function(entry, context)
local kind = entry:get_kind()
local line = context.cursor_line
local col = context.cursor.col
local char_before_cursor = string.sub(line, col - 1, col)
if char_before_cursor == "." then
if kind == 2 or kind == 5 then
return true
else return false end
elseif string.match(line, "^%s*%w*$") then
if kind == 3 or kind == 6 then
return true
else
return false
end
end
return true
end
},
{ name = 'nvim_lua' },
{ name = 'luasnip'},
{ name = 'nvim_lsp_signature_help' },
{ name = "path" },
},
{