diff --git a/home/common/core/nixvim/default.nix b/home/common/core/nixvim/default.nix index 9974999..32c6445 100644 --- a/home/common/core/nixvim/default.nix +++ b/home/common/core/nixvim/default.nix @@ -12,7 +12,8 @@ inherit (pkgs) nixpkgs-fmt prettierd - ;}; + ; + }; programs.nixvim = { enable = true; diff --git a/home/common/core/nixvim/plugins/cmp.nix b/home/common/core/nixvim/plugins/cmp.nix new file mode 100644 index 0000000..e1dc978 --- /dev/null +++ b/home/common/core/nixvim/plugins/cmp.nix @@ -0,0 +1,105 @@ +{ + programs.nixvim.plugins = { + cmp-emoji = { enable = true; }; + cmp = { + enable = true; + settings = { + autoEnableSources = true; + experimental = { ghost_text = true; }; + performance = { + debounce = 60; + fetchingTimeout = 200; + maxViewEntries = 30; + }; + snippet = { expand = "luasnip"; }; + formatting = { + fields = [ "kind" "abbr" "menu" ]; + }; + sources = [ + { name = "nvim_lsp"; } + { name = "nvim_lua"; } + { name = "luasnip"; } + { name = "buffer"; } + { name = "path"; } + { name = "vim-dadbod-completion"; } + ]; + window = { + completion = { border = "solid"; }; + documentation = { border = "solid"; }; + }; + mapping = { + "" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; + "" = "cmp.mapping.select_next_item()"; + "" = "cmp.mapping.select_prev_item()"; + "" = "cmp.mapping.abort()"; + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.confirm({ select = true })"; + "" = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })"; + }; + }; + }; + cmp-nvim-lsp = { enable = true; }; # lsp + cmp-buffer = { enable = true; }; + cmp-path = { enable = true; }; # file system paths + cmp_luasnip = { enable = true; }; # snippets + cmp-cmdline = { enable = false; }; # autocomplete for cmdline + }; + programs.nixvim.extraConfigLua = '' + luasnip = require("luasnip") + kind_icons = { + Text = "󰊄", + Method = "", + Function = "󰡱", + Constructor = "", + Field = "", + Variable = "󱀍", + Class = "", + Interface = "", + Module = "󰕳", + Property = "", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "", + } + + local cmp = require'cmp' + + -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({'/', "?" }, { + sources = { + { name = 'buffer' } + } + }) + + -- Set configuration for specific filetype. + cmp.setup.filetype('gitcommit', { + sources = cmp.config.sources({ + { name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it. + }, { + { name = 'buffer' }, + }) + }) + + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(':', { + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }), + }) ''; +} diff --git a/home/common/core/nixvim/plugins/default.nix b/home/common/core/nixvim/plugins/default.nix index 10fac20..b2196e6 100644 --- a/home/common/core/nixvim/plugins/default.nix +++ b/home/common/core/nixvim/plugins/default.nix @@ -1,16 +1,18 @@ { pkgs, ... }: { imports = [ + ./cmp.nix ./colorizer.nix ./conform.nix - ./gitsigns.nix - ./harpoon.nix + ./gitsigns.nix + ./harpoon.nix ./lsp.nix - ./lualine.nix - ./nvim-tree.nix - ./surround.nix - ./telescope.nix - ./treesitter.nix + ./lualine.nix + ./luasnip.nix + ./nvim-tree.nix + ./surround.nix + ./telescope.nix + ./treesitter.nix ]; # Load Plugins that aren't provided as modules by nixvim diff --git a/home/common/core/nixvim/plugins/luasnip.nix b/home/common/core/nixvim/plugins/luasnip.nix new file mode 100644 index 0000000..ef93822 --- /dev/null +++ b/home/common/core/nixvim/plugins/luasnip.nix @@ -0,0 +1,15 @@ +{ pkgs, ... }: { + programs.nixvim.plugins.luasnip = { + enable = true; + extraConfig = { + enable_autosnippets = true; + store_selection_keys = ""; + }; + fromVscode = [ + { + lazyLoad = true; + paths = "${pkgs.vimPlugins.friendly-snippets}"; + } + ]; + }; +}