plugins/nvim-cmp: Correctly handle multi mode mappings (#537)

Fixes #536
This commit is contained in:
traxys 2023-08-23 18:18:05 +02:00 committed by GitHub
parent 02a0093468
commit 2e7137058d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View file

@ -505,7 +505,7 @@ in {
&& ((length modes) >= 1)
)
("," + (helpers.toLuaObject modes));
in "cmp.mapping(${mapping.action}${modesString})"
in "cmp.mapping(${action.action}${modesString})"
)
)
mapping);

View file

@ -11,6 +11,34 @@
};
};
# Issue #536
mappings = {
plugins.nvim-cmp = {
enable = true;
mapping = {
"<CR>" = "cmp.mapping.confirm({ select = false })";
"<Tab>" = {
modes = ["i" "s"];
action = ''
function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expandable() then
luasnip.expand()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then
fallback()
else
fallback()
end
end
'';
};
};
};
};
# All the upstream default options of nvim-cmp
defaults = {
plugins.nvim-cmp = {