2017-11-02 18:34:42 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.neovim;
|
|
|
|
|
2018-09-08 17:10:32 +02:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2019-08-18 15:20:17 +02:00
|
|
|
moduleConfigure =
|
|
|
|
optionalAttrs (cfg.extraConfig != "") {
|
|
|
|
customRC = cfg.extraConfig;
|
|
|
|
}
|
|
|
|
// optionalAttrs (cfg.plugins != []) {
|
|
|
|
packages.home-manager.start = cfg.plugins;
|
|
|
|
};
|
|
|
|
|
2017-11-02 18:34:42 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
programs.neovim = {
|
|
|
|
enable = mkEnableOption "Neovim";
|
|
|
|
|
2018-08-18 04:50:49 +02:00
|
|
|
viAlias = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Symlink `vi` to `nvim` binary.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
vimAlias = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Symlink `vim` to `nvim` binary.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-11-27 12:21:37 +01:00
|
|
|
withNodeJs = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Enable node provider. Set to <literal>true</literal> to
|
|
|
|
use Node plugins.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2017-11-02 18:34:42 +01:00
|
|
|
withPython = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Enable Python 2 provider. Set to <literal>true</literal> to
|
|
|
|
use Python 2 plugins.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraPythonPackages = mkOption {
|
2018-09-08 17:10:32 +02:00
|
|
|
type = with types; either extraPythonPackageType (listOf package);
|
|
|
|
default = (_: []);
|
|
|
|
defaultText = "ps: []";
|
|
|
|
example = literalExample "(ps: with ps; [ pandas jedi ])";
|
2017-11-02 18:34:42 +01:00
|
|
|
description = ''
|
2018-11-27 12:21:37 +01:00
|
|
|
A function in python.withPackages format, which returns a
|
2018-09-08 17:10:32 +02:00
|
|
|
list of Python 2 packages required for your plugins to work.
|
2017-11-02 18:34:42 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
withRuby = mkOption {
|
|
|
|
type = types.nullOr types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Enable ruby provider.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
withPython3 = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Enable Python 3 provider. Set to <literal>true</literal> to
|
|
|
|
use Python 3 plugins.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraPython3Packages = mkOption {
|
2018-09-08 17:10:32 +02:00
|
|
|
type = with types; either extraPython3PackageType (listOf package);
|
|
|
|
default = (_: []);
|
|
|
|
defaultText = "ps: []";
|
|
|
|
example = literalExample "(ps: with ps; [ python-language-server ])";
|
2017-11-02 18:34:42 +01:00
|
|
|
description = ''
|
2018-11-27 12:21:37 +01:00
|
|
|
A function in python.withPackages format, which returns a
|
2018-09-08 17:10:32 +02:00
|
|
|
list of Python 3 packages required for your plugins to work.
|
2017-11-02 18:34:42 +01:00
|
|
|
'';
|
|
|
|
};
|
2018-01-31 09:14:01 +01:00
|
|
|
|
2019-02-04 06:57:26 +01:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.neovim-unwrapped;
|
2019-08-28 00:12:28 +02:00
|
|
|
defaultText = literalExample "pkgs.neovim-unwrapped";
|
2019-02-04 06:57:26 +01:00
|
|
|
description = "The package to use for the neovim binary.";
|
|
|
|
};
|
|
|
|
|
2019-08-10 13:55:05 +02:00
|
|
|
finalPackage = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
visible = false;
|
|
|
|
readOnly = true;
|
|
|
|
description = "Resulting customized neovim package.";
|
|
|
|
};
|
|
|
|
|
2018-01-31 09:14:01 +01:00
|
|
|
configure = mkOption {
|
2018-09-08 17:10:32 +02:00
|
|
|
type = types.attrs;
|
|
|
|
default = {};
|
2018-01-31 09:14:01 +01:00
|
|
|
example = literalExample ''
|
|
|
|
configure = {
|
|
|
|
customRC = $''''
|
|
|
|
" here your custom configuration goes!
|
|
|
|
$'''';
|
|
|
|
packages.myVimPackage = with pkgs.vimPlugins; {
|
|
|
|
# loaded on launch
|
|
|
|
start = [ fugitive ];
|
|
|
|
# manually loadable by calling `:packadd $plugin-name`
|
|
|
|
opt = [ ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
description = ''
|
2018-09-08 17:10:32 +02:00
|
|
|
Generate your init file from your list of plugins and custom commands,
|
2018-01-31 09:14:01 +01:00
|
|
|
and loads it from the store via <command>nvim -u /nix/store/hash-vimrc</command>
|
2019-08-18 15:20:17 +02:00
|
|
|
|
|
|
|
</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>.
|
2018-01-31 09:14:01 +01:00
|
|
|
'';
|
|
|
|
};
|
2017-11-02 18:34:42 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2019-08-18 15:20:17 +02:00
|
|
|
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.
|
|
|
|
'';
|
|
|
|
|
2019-08-10 13:55:05 +02:00
|
|
|
home.packages = [ cfg.finalPackage ];
|
|
|
|
|
|
|
|
programs.neovim.finalPackage = pkgs.wrapNeovim cfg.package {
|
|
|
|
inherit (cfg)
|
|
|
|
extraPython3Packages withPython3
|
|
|
|
extraPythonPackages withPython
|
2019-08-18 15:20:17 +02:00
|
|
|
withNodeJs withRuby viAlias vimAlias;
|
|
|
|
|
|
|
|
configure = cfg.configure // moduleConfigure;
|
2019-08-10 13:55:05 +02:00
|
|
|
};
|
2017-11-02 18:34:42 +01:00
|
|
|
};
|
|
|
|
}
|