diff --git a/home-manager/common/software/cli/nixvim/cmp.nix b/home-manager/common/software/cli/nixvim/cmp.nix new file mode 100644 index 00000000..11125607 --- /dev/null +++ b/home-manager/common/software/cli/nixvim/cmp.nix @@ -0,0 +1,69 @@ +{ ... }: { + nixvim.plugins = { + # 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 = { + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.close()"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.confirm({ select = true })"; + "" = { + action = "cmp.mapping.select_prev_item()"; + modes = [ + "i" + "s" + ]; + }; + "" = { + action = "cmp.mapping.select_next_item()"; + modes = [ + "i" + "s" + ]; + }; + }; + sources = [ +# { name = "nvim_lua"; } + { name = "nvim_lsp"; } +# { name = "nvim_lsp_signature_help"; } + { 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 = { + nvim_lsp = 'λ', + luasnip = '⋗', + buffer = 'Ω', + path = '🖫', + } + item.menu = menu_icon[entry.source.name] + return item + end, + ''; + }; + }; + }; +}