1 { config, lib, pkgs, ... }:
6 cfg = config.programs.neovim;
9 options.programs.neovim = {
14 description = lib.mdDoc ''
15 Whether to enable Neovim.
17 When enabled through this option, Neovim is wrapped to use a
18 configuration managed by this module. The configuration file in the
19 user's home directory at {file}`~/.config/nvim/init.vim` is no longer
24 defaultEditor = mkOption {
27 description = lib.mdDoc ''
28 When enabled, installs neovim and configures neovim to be the default editor
29 using the EDITOR environment variable.
36 description = lib.mdDoc ''
37 Symlink {command}`vi` to {command}`nvim` binary.
44 description = lib.mdDoc ''
45 Symlink {command}`vim` to {command}`nvim` binary.
52 description = lib.mdDoc "Enable Ruby provider.";
55 withPython3 = mkOption {
58 description = lib.mdDoc "Enable Python 3 provider.";
61 withNodeJs = mkOption {
64 description = lib.mdDoc "Enable Node provider.";
67 configure = mkOption {
70 example = literalExpression ''
73 " here your custom configuration goes!
75 packages.myVimPackage = with pkgs.vimPlugins; {
78 # manually loadable by calling `:packadd $plugin-name`
83 description = lib.mdDoc ''
84 Generate your init file from your list of plugins and custom commands.
85 Neovim will then be wrapped to load {command}`nvim -u /nix/store/«hash»-vimrc`
91 default = pkgs.neovim-unwrapped;
92 defaultText = literalExpression "pkgs.neovim-unwrapped";
93 description = lib.mdDoc "The package to use for the neovim binary.";
96 finalPackage = mkOption {
100 description = lib.mdDoc "Resulting customized neovim package.";
105 example = literalExpression ''
106 { "ftplugin/c.vim".text = "setlocal omnifunc=v:lua.vim.lsp.omnifunc"; }
108 description = lib.mdDoc ''
109 Set of files that have to be linked in {file}`runtime`.
112 type = with types; attrsOf (submodule (
113 { name, config, ... }:
120 description = lib.mdDoc ''
121 Whether this runtime directory should be generated. This
122 option allows specific runtime files to be disabled.
128 description = lib.mdDoc ''
129 Name of symlink. Defaults to the attribute
136 type = types.nullOr types.lines;
137 description = lib.mdDoc "Text of the file.";
142 type = types.nullOr types.path;
143 description = lib.mdDoc "Path of the source file.";
148 config.target = mkDefault name;
155 config = mkIf cfg.enable {
156 environment.systemPackages = [
159 environment.variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim");
161 environment.etc = listToAttrs (attrValues (mapAttrs
163 name = "xdg/nvim/${name}";
166 target = "xdg/nvim/${value.target}";
168 (optionals (isNull value.source) [ "source" ]);
172 programs.neovim.finalPackage = pkgs.wrapNeovim cfg.package {
173 inherit (cfg) viAlias vimAlias withPython3 withNodeJs withRuby configure;