nix/home-manager/common/software/cli/nixvim/cmp.nix

70 lines
1.9 KiB
Nix
Raw Normal View History

2024-04-03 13:08:21 +02:00
{ ... }: {
2024-04-03 13:08:51 +02:00
programs.nixvim.plugins = {
2024-04-03 13:08:21 +02:00
# Snippet engine for neovim
luasnip.enable = true;
cmp_luasnip.enable = true;
# CMP Addons
cmp-buffer.enable = true;
cmp-path.enable = true;
cmp-nvim-lsp.enable = true;
cmp-nvim-lsp-document-symbol.enable = true;
cmp-nvim-lsp-signature-help.enable = true;
nvim-cmp = {
enable = true;
autoEnableSources = true;
mapping = {
"<C-Space>" = "cmp.mapping.complete()";
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
"<C-e>" = "cmp.mapping.close()";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
2024-04-03 15:12:09 +02:00
"<CR>" = "cmp.mapping.confirm({ select = true })";
2024-04-03 13:08:21 +02:00
"<S-Tab>" = {
action = "cmp.mapping.select_prev_item()";
modes = [
"i"
"s"
];
};
"<Tab>" = {
action = "cmp.mapping.select_next_item()";
modes = [
"i"
"s"
];
};
};
sources = [
2024-04-03 15:12:09 +02:00
{ name = "nvim_lua"; }
2024-04-03 13:08:21 +02:00
{ name = "nvim_lsp"; }
2024-04-03 15:12:09 +02:00
{ name = "nvim_lsp_signature_help"; }
2024-04-03 13:08:21 +02:00
{ name = "calc"; }
{ name = "path"; }
{ name = "buffer"; }
{ name = "luasnip"; }
];
snippet.expand = "luasnip";
window = {
completion.border = "rounded";
documentation.border = "rounded";
};
formatting = {
fields = [ "menu" "abbr" "kind" ];
# https://rsdlt.github.io/posts/rust-nvim-ide-guide-walkthrough-development-debug/
format = ''
function(entry, item)
local menu_icon = {
2024-04-03 15:12:09 +02:00
nvim_lsp = 'λ',
luasnip = '',
buffer = 'Ω',
path = '🖫',
2024-04-03 13:08:21 +02:00
}
item.menu = menu_icon[entry.source.name]
return item
end,
'';
};
};
};
}