From c142e5264dc0b3e1e68d7af73e76e3d83446da11 Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Sun, 18 Aug 2019 15:20:17 +0200 Subject: [PATCH] neovim: add extraConfig and plugins options --- modules/programs/neovim.nix | 59 ++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index 6aaa3980a..dadda2c71 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -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 nvim -u /nix/store/hash-vimrc + + + + This option is deprecated. Please use the options extraConfig + and plugins which are mutually exclusive with this option. + ''; + }; + + extraConfig = mkOption { + type = types.lines; + default = ""; + example = '' + set nocompatible + set nobackup + ''; + description = '' + Custom vimrc lines. + + + + This option is mutually exclusive with configure. + ''; + }; + + plugins = mkOption { + type = with types; listOf package; + default = [ ]; + example = literalExample "[ pkgs.vimPlugins.yankring ]"; + description = '' + List of vim plugins to install. + + + + This option is mutually exclusive with configure. ''; }; }; }; 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; }; }; }