[nvim] feat: tweak autocomplete behavior

change binding
autocomplete
This commit is contained in:
David JULIEN 2022-07-08 15:24:58 +02:00
parent 72d94850b4
commit a035e1ee17

View File

@ -48,7 +48,7 @@ local icons = {
cmp.setup { cmp.setup {
completion = { completion = {
autocomplete = false autocomplete = true
}, },
sources = { sources = {
{ name = "path" }, { name = "path" },
@ -91,21 +91,31 @@ cmp.setup {
select = true, select = true,
}), }),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
["<C-n>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then elseif has_words_before() then
cmp.complete() cmp.complete()
else else
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback) ["<C-p>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else else
fallback() fallback()
end end