add cmp mappings
This commit is contained in:
parent
51079edbd5
commit
9341666de7
1 changed files with 47 additions and 0 deletions
|
|
@ -14,6 +14,53 @@ _:
|
|||
|
||||
# TODO: add this at luasnip:
|
||||
# { name = "luasnip", priority = 750 }
|
||||
|
||||
mapping = {
|
||||
"<Up>" = "cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Select }";
|
||||
"<Down>" = "cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Select }";
|
||||
"<C-P>" = "cmp.mapping(function()
|
||||
if (cmp.core.view:visible() or vim.fn.pumvisible() == 1) then
|
||||
cmp.select_prev_item { behavior = cmp.SelectBehavior.Insert }
|
||||
else
|
||||
cmp.complete()
|
||||
end
|
||||
end)";
|
||||
"<C-N>" = "cmp.mapping(function()
|
||||
if (cmp.core.view:visible() or vim.fn.pumvisible() == 1) then
|
||||
cmp.select_next_item { behavior = cmp.SelectBehavior.Insert }
|
||||
else
|
||||
cmp.complete()
|
||||
end
|
||||
end)";
|
||||
"<C-K>" = "cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }";
|
||||
"<C-J>" = "cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }";
|
||||
"<C-U>" = "cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' })";
|
||||
"<C-D>" = "cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' })";
|
||||
"<C-Space>" = "cmp.mapping(cmp.mapping.complete(), { 'i', 'c' })";
|
||||
"<C-Y>" = "cmp.config.disable";
|
||||
"<C-E>" = "cmp.mapping { i = cmp.mapping.abort(), c = cmp.mapping.close() }";
|
||||
"<CR>" = "cmp.mapping.confirm { select = false }";
|
||||
"<Tab>" = "cmp.mapping(function(fallback)
|
||||
if (cmp.core.view:visible() or vim.fn.pumvisible() == 1) then
|
||||
cmp.select_next_item()
|
||||
elseif vim.snippet and vim.snippet.active { direction = 1 } then
|
||||
vim.schedule(function() vim.snippet.jump(1) end)
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' })";
|
||||
"<S-Tab>" = "cmp.mapping(function(fallback)
|
||||
if (cmp.core.view:visible() or vim.fn.pumvisible() == 1) then
|
||||
cmp.select_prev_item()
|
||||
elseif vim.snippet and vim.snippet.active { direction = -1 } then
|
||||
vim.schedule(function() vim.snippet.jump(-1) end)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' })";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue