fix cmp mapping

This commit is contained in:
cy 2025-01-11 00:08:00 -05:00
parent e22ed2d5a4
commit 5218a5331d

View file

@ -72,25 +72,50 @@
plugins.cmp = { plugins.cmp = {
enable = true; enable = true;
settings.sources = [ settings = {
formatting.fields = [
"abbr"
"kind"
"menu"
];
experimental = {
ghost_text = true;
};
snippet.expand = ''
function(args) require('luasnip').lsp_expand(args.body) end
'';
sources = [
{ name = "nvim_lsp"; } { name = "nvim_lsp"; }
{ name = "emoji"; }
{ name = "luasnip"; } { name = "luasnip"; }
{ name = "buffer"; } { name = "buffer"; }
{ name = "nvim_lua"; }
{ name = "path"; } { name = "path"; }
]; ];
mapping = {
settings.mappings = {
"<C-h>" = "cmp.mapping.abort()"; "<C-h>" = "cmp.mapping.abort()";
"<C-n>" = "cmp.mapping.select_next_item()"; "<C-n>" = "cmp.mapping.select_next_item()";
"<C-p>" = "cmp.mapping.select_prev_item()"; "<C-p>" = "cmp.mapping.select_prev_item()";
"<C-d>" = "cmp.mapping.scroll_docs(-4)"; "<C-d>" = "cmp.mapping.scroll_docs(-4)";
"<C-u>" = "cmp.mapping.scroll_docs(4)"; "<C-u>" = "cmp.mapping.scroll_docs(4)";
"<C-k>" = "cmp.mapping.confirm({ select = true })"; "<C-k>" = ''
cmp.mapping(function(fallback)
if cmp.visible() then
if require("luasnip").expandable() then
require("luasnip").expand()
else
cmp.confirm({
select = true,
})
end
else
fallback()
end
end)
'';
"<Tab>" = '' "<Tab>" = ''
cmp.mapping(function(fallback) cmp.mapping(function(fallback)
if require("luasnip").expand_or_jumpable() then if require("luasnip").jumpable(1) then
require("luasnip").expand_or_jump() require("luasnip").jump(1)
else else
fallback() fallback()
end end
@ -107,6 +132,8 @@
''; '';
}; };
}; };
};
plugins.lsp = { plugins.lsp = {
enable = true; enable = true;
keymaps.lspBuf = { keymaps.lspBuf = {