2020-09-28 17:07:45 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.neovim;
|
2023-04-18 23:20:54 +02:00
|
|
|
in
|
|
|
|
{
|
2020-09-28 17:07:45 +02:00
|
|
|
options.programs.neovim = {
|
2022-10-10 17:26:11 +02:00
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
example = true;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2022-10-10 17:26:11 +02:00
|
|
|
Whether to enable Neovim.
|
|
|
|
|
|
|
|
When enabled through this option, Neovim is wrapped to use a
|
|
|
|
configuration managed by this module. The configuration file in the
|
|
|
|
user's home directory at {file}`~/.config/nvim/init.vim` is no longer
|
|
|
|
loaded by default.
|
|
|
|
'';
|
|
|
|
};
|
2020-09-28 17:07:45 +02:00
|
|
|
|
|
|
|
defaultEditor = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2020-09-28 17:07:45 +02:00
|
|
|
When enabled, installs neovim and configures neovim to be the default editor
|
|
|
|
using the EDITOR environment variable.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
viAlias = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2020-09-28 17:07:45 +02:00
|
|
|
Symlink {command}`vi` to {command}`nvim` binary.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
vimAlias = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2020-09-28 17:07:45 +02:00
|
|
|
Symlink {command}`vim` to {command}`nvim` binary.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
withRuby = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = "Enable Ruby provider.";
|
2021-11-06 14:29:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
withPython3 = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = "Enable Python 3 provider.";
|
2021-11-06 14:29:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
withNodeJs = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = "Enable Node provider.";
|
2020-09-28 17:07:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
configure = mkOption {
|
|
|
|
type = types.attrs;
|
2023-04-18 23:20:54 +02:00
|
|
|
default = { };
|
2021-10-03 18:06:03 +02:00
|
|
|
example = literalExpression ''
|
|
|
|
{
|
|
|
|
customRC = '''
|
2020-09-28 17:07:45 +02:00
|
|
|
" here your custom configuration goes!
|
2021-10-03 18:06:03 +02:00
|
|
|
''';
|
|
|
|
packages.myVimPackage = with pkgs.vimPlugins; {
|
|
|
|
# loaded on launch
|
|
|
|
start = [ fugitive ];
|
|
|
|
# manually loadable by calling `:packadd $plugin-name`
|
|
|
|
opt = [ ];
|
2020-09-28 17:07:45 +02:00
|
|
|
};
|
2021-10-03 18:06:03 +02:00
|
|
|
}
|
2020-09-28 17:07:45 +02:00
|
|
|
'';
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2020-09-28 17:07:45 +02:00
|
|
|
Generate your init file from your list of plugins and custom commands.
|
2022-08-03 01:57:59 +02:00
|
|
|
Neovim will then be wrapped to load {command}`nvim -u /nix/store/«hash»-vimrc`
|
2020-09-28 17:07:45 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-11-27 01:19:27 +01:00
|
|
|
package = mkPackageOption pkgs "neovim-unwrapped" { };
|
2020-09-28 17:07:45 +02:00
|
|
|
|
|
|
|
finalPackage = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
visible = false;
|
|
|
|
readOnly = true;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = "Resulting customized neovim package.";
|
2020-09-28 17:07:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
runtime = mkOption {
|
2023-04-18 23:20:54 +02:00
|
|
|
default = { };
|
2021-10-03 18:06:03 +02:00
|
|
|
example = literalExpression ''
|
|
|
|
{ "ftplugin/c.vim".text = "setlocal omnifunc=v:lua.vim.lsp.omnifunc"; }
|
2020-09-28 17:07:45 +02:00
|
|
|
'';
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2020-09-28 17:07:45 +02:00
|
|
|
Set of files that have to be linked in {file}`runtime`.
|
|
|
|
'';
|
|
|
|
|
|
|
|
type = with types; attrsOf (submodule (
|
|
|
|
{ name, config, ... }:
|
2023-04-18 23:20:54 +02:00
|
|
|
{
|
|
|
|
options = {
|
2020-09-28 17:07:45 +02:00
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2023-04-18 23:20:54 +02:00
|
|
|
Whether this runtime directory should be generated. This
|
|
|
|
option allows specific runtime files to be disabled.
|
2020-09-28 17:07:45 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
target = mkOption {
|
|
|
|
type = types.str;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2020-09-28 17:07:45 +02:00
|
|
|
Name of symlink. Defaults to the attribute
|
|
|
|
name.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
text = mkOption {
|
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.lines;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = "Text of the file.";
|
2020-09-28 17:07:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
source = mkOption {
|
2023-04-28 14:39:51 +02:00
|
|
|
default = null;
|
|
|
|
type = types.nullOr types.path;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = "Path of the source file.";
|
2020-09-28 17:07:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2023-04-18 23:20:54 +02:00
|
|
|
config.target = mkDefault name;
|
|
|
|
}
|
|
|
|
));
|
2020-09-28 17:07:45 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [
|
|
|
|
cfg.finalPackage
|
|
|
|
];
|
2021-10-28 18:51:44 +02:00
|
|
|
environment.variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim");
|
2020-09-28 17:07:45 +02:00
|
|
|
|
2023-04-18 23:20:54 +02:00
|
|
|
environment.etc = listToAttrs (attrValues (mapAttrs
|
|
|
|
(name: value: {
|
|
|
|
name = "xdg/nvim/${name}";
|
2023-04-28 14:39:51 +02:00
|
|
|
value = removeAttrs
|
|
|
|
(value // {
|
|
|
|
target = "xdg/nvim/${value.target}";
|
|
|
|
})
|
|
|
|
(optionals (isNull value.source) [ "source" ]);
|
2023-04-18 23:20:54 +02:00
|
|
|
})
|
|
|
|
cfg.runtime));
|
2020-09-28 17:07:45 +02:00
|
|
|
|
2023-04-18 23:20:54 +02:00
|
|
|
programs.neovim.finalPackage = pkgs.wrapNeovim cfg.package {
|
|
|
|
inherit (cfg) viAlias vimAlias withPython3 withNodeJs withRuby configure;
|
2020-09-28 17:07:45 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|