From 590da80ceb32edff0bd44b0c3e0fa99eb8173825 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Thu, 17 Mar 2022 20:43:03 -0600 Subject: [PATCH] neovim/coc: fix loading CoC plugin (#2801) Specifically, refactored all places that use cfg.plugins to use a new combined list that includes CoC if it's enabled. --- modules/programs/neovim.nix | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index d00c1726f..a0e21476e 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -64,14 +64,21 @@ let '' else ""; + allPlugins = cfg.plugins ++ optional cfg.coc.enable { + type = "viml"; + plugin = pkgs.vimPlugins.coc-nvim; + config = cfg.coc.pluginConfig; + optional = false; + }; + moduleConfigure = { packages.home-manager = { start = remove null (map (x: if x ? plugin && x.optional == true then null else (x.plugin or x)) - cfg.plugins); + allPlugins); opt = remove null (map (x: if x ? plugin && x.optional == true then x.plugin else null) - cfg.plugins); + allPlugins); }; beforePlugins = ""; }; @@ -328,6 +335,12 @@ in { for options. ''; }; + + pluginConfig = mkOption { + type = types.lines; + default = ""; + description = "Script to configure CoC. Must be viml."; + }; }; }; }; @@ -342,16 +355,15 @@ in { plugin = x; config = ""; optional = false; - }) cfg.plugins; + }) allPlugins; suppressNotVimlConfig = p: if p.type != "viml" then p // { config = ""; } else p; neovimConfig = pkgs.neovimUtils.makeNeovimConfig { - inherit (cfg) - extraPython3Packages withPython3 withNodeJs withRuby viAlias vimAlias; + inherit (cfg) extraPython3Packages withPython3 withRuby viAlias vimAlias; + withNodeJs = cfg.withNodeJs or cfg.coc.enable; configure = cfg.configure // moduleConfigure; - plugins = (map suppressNotVimlConfig pluginsNormalized) - ++ optionals cfg.coc.enable [{ plugin = pkgs.vimPlugins.coc-nvim; }]; + plugins = map suppressNotVimlConfig pluginsNormalized; customRC = cfg.extraConfig; };