From c7e79b53376bc5110c6cdfcc0f5f7705932b8b37 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Thu, 3 Jun 2021 21:37:53 +0200 Subject: [PATCH] programs.neovim: dont wrap init.vim (#2058) since we want to write it ourself in ~/.config/nvim/init.vim --- modules/programs/neovim.nix | 8 ++++--- tests/modules/programs/neovim/default.nix | 6 ++++- tests/modules/programs/neovim/no-init.nix | 22 +++++++++++++++++++ .../modules/programs/neovim/plugin-config.vim | 3 --- 4 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 tests/modules/programs/neovim/no-init.nix diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index dcbac2e2..8cb93bf3 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -51,8 +51,7 @@ let (map (x: if x ? plugin && x.optional == true then x.plugin else null) cfg.plugins); }; - customRC = pkgs.lib.concatMapStrings pluginConfig cfg.plugins - + cfg.extraConfig; + beforePlugins = ""; }; extraMakeWrapperArgs = lib.optionalString (cfg.extraPackages != [ ]) @@ -242,11 +241,14 @@ in { home.packages = [ cfg.finalPackage ]; - xdg.configFile."nvim/init.vim".text = neovimConfig.neovimRcContent; + xdg.configFile = mkIf (neovimConfig.neovimRcContent != "") { + "nvim/init.vim".text = neovimConfig.neovimRcContent; + }; programs.neovim.finalPackage = pkgs.wrapNeovimUnstable cfg.package (neovimConfig // { wrapperArgs = (lib.escapeShellArgs neovimConfig.wrapperArgs) + " " + extraMakeWrapperArgs; + wrapRc = false; }); programs.bash.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; }; diff --git a/tests/modules/programs/neovim/default.nix b/tests/modules/programs/neovim/default.nix index 7d6e53aa..13efac9b 100644 --- a/tests/modules/programs/neovim/default.nix +++ b/tests/modules/programs/neovim/default.nix @@ -1 +1,5 @@ -{ neovim-plugin-config = ./plugin-config.nix; } +{ + neovim-plugin-config = ./plugin-config.nix; + # waiting for a nixpkgs patch + # neovim-no-init = ./no-init.nix; +} diff --git a/tests/modules/programs/neovim/no-init.nix b/tests/modules/programs/neovim/no-init.nix new file mode 100644 index 00000000..1156529d --- /dev/null +++ b/tests/modules/programs/neovim/no-init.nix @@ -0,0 +1,22 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs.neovim = { + enable = true; + package = pkgs.neovim-unwrapped; + vimAlias = true; + withNodeJs = false; + withPython3 = true; + withRuby = false; + + extraPython3Packages = (ps: with ps; [ jedi pynvim ]); + }; + nmt.script = '' + vimrc="home-files/.config/nvim/init.vim" + assertPathNotExists "$vimrc" + ''; + }; +} diff --git a/tests/modules/programs/neovim/plugin-config.vim b/tests/modules/programs/neovim/plugin-config.vim index 60b5d3c7..9c173944 100644 --- a/tests/modules/programs/neovim/plugin-config.vim +++ b/tests/modules/programs/neovim/plugin-config.vim @@ -1,6 +1,3 @@ -" configuration generated by NIX -set nocompatible - set packpath^=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-vim-pack-dir set runtimepath^=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-vim-pack-dir