From 324ce79bd6a1ddef56cd1a24ba71834392798c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charlotte=20=F0=9F=A6=9D=20Delenk?= Date: Thu, 13 Apr 2023 09:36:21 +0100 Subject: [PATCH] only enable nvim_lsp cmp source on desktop --- config/programs/vim/configuration.nix | 2 ++ config/programs/vim/modules/lsp/cmp.nix | 30 ++++++++++++------- .../programs/vim/modules/lua/config/cmp.lua | 10 +++---- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/config/programs/vim/configuration.nix b/config/programs/vim/configuration.nix index ac46b44d..c5866836 100644 --- a/config/programs/vim/configuration.nix +++ b/config/programs/vim/configuration.nix @@ -89,6 +89,8 @@ in { "config.undodir" ]; + vim.g.isDesktop = config.isDesktop; + output.path.path = with pkgs; [ripgrep]; }; options.isDesktop = lib.options.mkEnableOption "desktop integration and LSP"; diff --git a/config/programs/vim/modules/lsp/cmp.nix b/config/programs/vim/modules/lsp/cmp.nix index 09d3bdb5..fffa4f4b 100644 --- a/config/programs/vim/modules/lsp/cmp.nix +++ b/config/programs/vim/modules/lsp/cmp.nix @@ -1,12 +1,22 @@ -{pkgs, ...}: { - output.plugins = with pkgs.vimPlugins; [ - nvim-cmp - cmp-cmdline - cmp-path - cmp-buffer - cmp-nvim-lsp - cmp_luasnip - cmp-git - ]; +{ + pkgs, + config, + lib, + ... +}: { + output.plugins = with pkgs.vimPlugins; + [ + nvim-cmp + cmp-cmdline + cmp-path + cmp-buffer + cmp_luasnip + cmp-git + ] + ++ ( + if config.isDesktop + then [cmp-nvim-lsp] + else [] + ); extraLuaModules = ["config.cmp"]; } diff --git a/config/programs/vim/modules/lua/config/cmp.lua b/config/programs/vim/modules/lua/config/cmp.lua index 1e60d534..1b8f6268 100644 --- a/config/programs/vim/modules/lua/config/cmp.lua +++ b/config/programs/vim/modules/lua/config/cmp.lua @@ -19,12 +19,10 @@ cmp.setup({ [''] = cmp.mapping.abort(), [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }), - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'vsnip' }, -- For vsnip users. - -- { name = 'luasnip' }, -- For luasnip users. - -- { name = 'ultisnips' }, -- For ultisnips users. - -- { name = 'snippy' }, -- For snippy users. + sources = cmp.config.sources( + vim.g.isDesktop and {{ name = 'nvim_lsp' }} or {}, + { + { name = 'luasnip' }, }, { { name = 'buffer' }, })