neovim: add extraConfig and plugins options

This commit is contained in:
Tobias Happ 2019-08-18 15:20:17 +02:00 committed by Robert Helgesson
parent 5d7eabb93f
commit c142e5264d
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -24,6 +24,14 @@ let
merge = mergeOneOption;
};
moduleConfigure =
optionalAttrs (cfg.extraConfig != "") {
customRC = cfg.extraConfig;
}
// optionalAttrs (cfg.plugins != []) {
packages.home-manager.start = cfg.plugins;
};
in
{
@ -137,19 +145,68 @@ in
description = ''
Generate your init file from your list of plugins and custom commands,
and loads it from the store via <command>nvim -u /nix/store/hash-vimrc</command>
</para><para>
This option is deprecated. Please use the options <varname>extraConfig</varname>
and <varname>plugins</varname> which are mutually exclusive with this option.
'';
};
extraConfig = mkOption {
type = types.lines;
default = "";
example = ''
set nocompatible
set nobackup
'';
description = ''
Custom vimrc lines.
</para><para>
This option is mutually exclusive with <varname>configure</varname>.
'';
};
plugins = mkOption {
type = with types; listOf package;
default = [ ];
example = literalExample "[ pkgs.vimPlugins.yankring ]";
description = ''
List of vim plugins to install.
</para><para>
This option is mutually exclusive with <varname>configure</varname>.
'';
};
};
};
config = mkIf cfg.enable {
assertions = [
{
assertion = cfg.configure == { } || moduleConfigure == { };
message = "The programs.neovim option configure is mutually exclusive"
+ " with extraConfig and plugins.";
}
];
warnings = optional (cfg.configure != {}) ''
The programs.neovim.configure option is deprecated. Please use
extraConfig and package option.
'';
home.packages = [ cfg.finalPackage ];
programs.neovim.finalPackage = pkgs.wrapNeovim cfg.package {
inherit (cfg)
extraPython3Packages withPython3
extraPythonPackages withPython
withNodeJs withRuby viAlias vimAlias configure;
withNodeJs withRuby viAlias vimAlias;
configure = cfg.configure // moduleConfigure;
};
};
}