1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 06:59:45 +01: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 = [{ assertions = [{
assertion = cfg.configure == { } || moduleConfigure == { }; assertion = cfg.configure == { } || moduleConfigure == { };
message = "The programs.neovim option configure is mutually exclusive" message = "The programs.neovim option configure is mutually exclusive"
@ -250,14 +261,12 @@ in {
home.packages = [ cfg.finalPackage ]; home.packages = [ cfg.finalPackage ];
programs.neovim.finalPackage = pkgs.wrapNeovim cfg.package { xdg.configFile."nvim/init.vim".text = neovimConfig.neovimRcContent;
inherit (cfg) programs.neovim.finalPackage = pkgs.wrapNeovimUnstable cfg.package
extraPython3Packages withPython3 extraPythonPackages withPython (neovimConfig // {
withNodeJs withRuby viAlias vimAlias; wrapperArgs = (lib.escapeShellArgs neovimConfig.wrapperArgs) + " "
+ extraMakeWrapperArgs;
extraMakeWrapperArgs = extraMakeWrapperArgs; });
configure = cfg.configure // moduleConfigure;
};
programs.bash.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; }; programs.bash.shellAliases = mkIf cfg.vimdiffAlias { vimdiff = "nvim -d"; };
programs.fish.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 = '' nmt.script = ''
vimrc=$(grep -Po "(?<=-u )[^ ]*" < "${ vimrc="$TESTED/home-files/.config/nvim/init.vim"
builtins.toJSON config.programs.neovim.finalPackage assertFileExists home-files/.config/nvim/init.vim
}/bin/nvim")
# We need to remove the unkown store paths in the config # We need to remove the unkown store paths in the config
TESTED="" assertFileContent \ TESTED="" assertFileContent \
<( ${pkgs.perl}/bin/perl -pe "s|\Q$NIX_STORE\E/[a-z0-9]{32}-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" < "$vimrc" <( ${pkgs.perl}/bin/perl -pe "s|\Q$NIX_STORE\E/[a-z0-9]{32}-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" < "$vimrc"