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

61 lines
1.8 KiB
Nix
Raw Permalink Normal View History

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