{ pkgs, lib, config, ... }: with lib; let cfg = config.programs.nixvim; pluginWithConfigType = types.submodule { options = { config = mkOption { type = types.lines; description = "vimscript for this plugin to be placed in init.vim"; default = ""; }; optional = mkEnableOption "optional" // { description = "Don't load by default (load with :packadd)"; }; plugin = mkOption { type = types.package; description = "vim plugin"; }; }; }; helpers = import ./plugins/helpers.nix { lib = lib; }; in { options = { programs.nixvim = { enable = mkEnableOption "enable NixVim"; package = mkOption { type = types.package; default = pkgs.neovim; description = "The package to use for neovim."; }; extraPlugins = mkOption { type = with types; listOf (either package pluginWithConfigType); default = []; description = "List of vim plugins to install."; }; colorscheme = mkOption { type = types.str; description = "The name of the colorscheme"; }; extraConfigLua = mkOption { type = types.lines; default = ""; description = "Extra contents for init.lua"; }; extraConfigVim = mkOption { type = types.lines; default = ""; description = "Extra contents for init.vim"; }; configure = mkOption { type = types.attrsOf types.anything; default = { }; }; options = mkOption { type = types.attrsOf types.anything; default = { }; description = "The configuration options, e.g. line numbers"; }; globals = mkOption { type = types.attrsOf types.anything; default = {}; description = "Global variables"; }; }; }; imports = [ ./plugins ]; config = let neovimConfig = pkgs.neovimUtils.makeNeovimConfig { configure = cfg.configure; plugins = cfg.extraPlugins; withPython2 = false; withPython3 = false; withNodeJs = false; withRuby = false; }; wrappedNeovim = pkgs.wrapNeovimUnstable cfg.package (neovimConfig // { wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs; }); in mkIf cfg.enable { environment.systemPackages = [ wrappedNeovim ]; programs.nixvim = { configure = { customRC = '' lua <