better movement while using cmp
This commit is contained in:
@ -38,6 +38,12 @@ local has_words_before = function()
|
|||||||
[1]:sub(col, col):match("%s") == nil
|
[1]:sub(col, col):match("%s") == nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- insert '(' after completing a function
|
||||||
|
cmp.event:on(
|
||||||
|
'confirm_done',
|
||||||
|
require('nvim-autopairs.completion.cmp').on_confirm_done()
|
||||||
|
)
|
||||||
|
|
||||||
local luasnip = require('luasnip')
|
local luasnip = require('luasnip')
|
||||||
require("luasnip.loaders.from_vscode").lazy_load()
|
require("luasnip.loaders.from_vscode").lazy_load()
|
||||||
|
|
||||||
@ -81,11 +87,13 @@ cmp.setup {
|
|||||||
return vim_item
|
return vim_item
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
|
-- mappings -----------------------------------------------------------------
|
||||||
mapping = cmp.mapping.preset.insert({
|
mapping = cmp.mapping.preset.insert({
|
||||||
["<Tab>"] = cmp.mapping(function(fallback)
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_next_item()
|
cmp.select_next_item()
|
||||||
elseif luasnip.expand_or_jumpable() then
|
elseif luasnip.expand_or_locally_jumpable() then
|
||||||
luasnip.expand_or_jump()
|
luasnip.expand_or_jump()
|
||||||
elseif has_words_before() then
|
elseif has_words_before() then
|
||||||
cmp.complete()
|
cmp.complete()
|
||||||
@ -102,9 +110,20 @@ cmp.setup {
|
|||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end, { "i", "s" }),
|
end, { "i", "s" }),
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
['<CR>'] = cmp.mapping({
|
||||||
|
i = function(fallback)
|
||||||
|
if cmp.visible() and cmp.get_active_entry() then
|
||||||
|
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
s = cmp.mapping.confirm({ select = true }),
|
||||||
|
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
|
||||||
|
}),
|
||||||
['<ESC>'] = cmp.mapping.close(),
|
['<ESC>'] = cmp.mapping.close(),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
sorting = {
|
sorting = {
|
||||||
comparators = {
|
comparators = {
|
||||||
cmp.config.compare.offset,
|
cmp.config.compare.offset,
|
||||||
|
Reference in New Issue
Block a user