From 63efd267673eb5febf4da728923f21f5353d8462 Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Sat, 8 Sep 2018 17:10:32 +0200 Subject: [PATCH] neovim: support new extraPython*Packages options Also fix `configure` argument. --- modules/programs/neovim.nix | 46 ++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/modules/programs/neovim.nix b/modules/programs/neovim.nix index 2e9cbca67..76dcd42d2 100644 --- a/modules/programs/neovim.nix +++ b/modules/programs/neovim.nix @@ -6,6 +6,24 @@ let cfg = config.programs.neovim; + extraPythonPackageType = mkOptionType { + name = "extra-python-packages"; + description = "python packages in python.withPackages format"; + check = with types; (x: if isFunction x + then isList (x pkgs.pythonPackages) + else false); + merge = mergeOneOption; + }; + + extraPython3PackageType = mkOptionType { + name = "extra-python3-packages"; + description = "python3 packages in python.withPackages format"; + check = with types; (x: if isFunction x + then isList (x pkgs.python3Packages) + else false); + merge = mergeOneOption; + }; + in { @@ -39,12 +57,13 @@ in }; extraPythonPackages = mkOption { - type = types.listOf types.package; - default = [ ]; - example = literalExample "with pkgs.python2Packages; [ pandas jedi ]"; + type = with types; either extraPythonPackageType (listOf package); + default = (_: []); + defaultText = "ps: []"; + example = literalExample "(ps: with ps; [ pandas jedi ])"; description = '' - List here Python 2 packages required for your plugins to - work. + A function in python.withPackages format, which returns a + list of Python 2 packages required for your plugins to work. ''; }; @@ -66,18 +85,19 @@ in }; extraPython3Packages = mkOption { - type = types.listOf types.package; - default = [ ]; - example = literalExample - "with pkgs.python3Packages; [ python-language-server ]"; + type = with types; either extraPython3PackageType (listOf package); + default = (_: []); + defaultText = "ps: []"; + example = literalExample "(ps: with ps; [ python-language-server ])"; description = '' - List here Python 3 packages required for your plugins to work. + A function in python.withPackages format, which returns a + list of Python 3 packages required for your plugins to work. ''; }; configure = mkOption { - type = types.nullOr types.attrs; - default = null; + type = types.attrs; + default = {}; example = literalExample '' configure = { customRC = $'''' @@ -92,7 +112,7 @@ in }; ''; description = '' - Generate your init file from your list of plugins and custom commands, + 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 ''; };