From fead989bba025850e8a5ca265f1f049792505aa4 Mon Sep 17 00:00:00 2001 From: Bad Date: Sat, 19 Nov 2022 17:03:50 +0100 Subject: [PATCH] Switch to cmp-nvim --- users/modules/neovim/nvim-lsp.nix | 51 +++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/users/modules/neovim/nvim-lsp.nix b/users/modules/neovim/nvim-lsp.nix index 9b21984..fa617df 100644 --- a/users/modules/neovim/nvim-lsp.nix +++ b/users/modules/neovim/nvim-lsp.nix @@ -12,7 +12,9 @@ let }; }; mkLspLangConfig = name: cfg: '' - require'lspconfig'["${name}"].setup(require'coq'.lsp_ensure_capabilities(${cfg.script})) + local cfg = ${cfg.script} + cfg["capabilities"] = require('cmp_nvim_lsp').default_capabilities() + require'lspconfig'["${name}"].setup(cfg) ''; mkLspLangConfigs = cfgs: lib.strings.concatStringsSep "\n" ((lib.attrsets.mapAttrsToList mkLspLangConfig cfgs)); in @@ -28,13 +30,50 @@ in config = mkIf cfg.lsp.enable { programs.neovim = { plugins = with pkgs.vimPlugins; [ + nvim-snippy + cmp-nvim-lsp + cmp-buffer + cmp-path + cmp-tmux + cmp-snippy { - plugin = coq_nvim; + plugin = nvim-cmp; config = '' - vim.g.coq_settings = { - xdg = true, - auto_start = true - } + local cmp = require'cmp' + + cmp.setup({ + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + require('snippy').expand_snippet(args.body) + end, + }, + window = {}, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'snippy' }, + { name = 'path' } + }, { + { name = 'buffer' }, + { name= 'tmux' } + }) + }) + + -- 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' }, + }) + }) ''; type = "lua"; }