1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-25 07:58:31 +02:00

programs.neovim: write config in $XDG_CONFIG_HOME/init.vim (#1652)

* neovim: write config in $XDG_CONFIG_HOME/init.vim

instead of wrapping the configuration, which has sideeffects
https://github.com/NixOS/nixpkgs/issues/55376

* fix: update test accordingly
This commit is contained in:
Matthieu Coudron 2020-12-29 20:26:02 +01:00 committed by GitHub
parent 99f0074362
commit 8e0c1c55fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 12 deletions

View File

@ -241,7 +241,18 @@ in {
};
};
config = mkIf cfg.enable {
config = let
extraMakeWrapperArgs = lib.optionalString (cfg.extraPackages != [ ])
''--prefix PATH : "${lib.makeBinPath cfg.extraPackages}"'';
neovimConfig = pkgs.neovimUtils.makeNeovimConfig {
inherit (cfg)
extraPython3Packages withPython3 extraPythonPackages withPython
withNodeJs withRuby viAlias vimAlias;
configure = cfg.configure // moduleConfigure;
plugins = cfg.plugins;
};
in mkIf cfg.enable {
assertions = [{
assertion = cfg.configure == { } || moduleConfigure == { };
message = "The programs.neovim option configure is mutually exclusive"
@ -250,14 +261,12 @@ in {
home.packages = [ cfg.finalPackage ];
programs.neovim.finalPackage = pkgs.wrapNeovim cfg.package {
inherit (cfg)
extraPython3Packages withPython3 extraPythonPackages withPython
withNodeJs withRuby viAlias vimAlias;
extraMakeWrapperArgs = extraMakeWrapperArgs;
configure = cfg.configure // moduleConfigure;
};
xdg.configFile."nvim/init.vim".text = neovimConfig.neovimRcContent;
programs.neovim.finalPackage = pkgs.wrapNeovimUnstable cfg.package
(neovimConfig // {
wrapperArgs = (lib.escapeShellArgs neovimConfig.wrapperArgs) + " "
+ extraMakeWrapperArgs;
});
programs.bash.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; };
programs.fish.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; };

View File

@ -23,9 +23,8 @@ with lib;
};
nmt.script = ''
vimrc=$(grep -Po "(?<=-u )[^ ]*" < "${
builtins.toJSON config.programs.neovim.finalPackage
}/bin/nvim")
vimrc="$TESTED/home-files/.config/nvim/init.vim"
assertFileExists home-files/.config/nvim/init.vim
# We need to remove the unkown store paths in the config
TESTED="" assertFileContent \
<( ${pkgs.perl}/bin/perl -pe "s|\Q$NIX_STORE\E/[a-z0-9]{32}-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" < "$vimrc"