diff --git a/lib/options.nix b/lib/options.nix index fbe2159a..801100ee 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -155,6 +155,26 @@ rec { mkNullable nixvimTypes.highlight default (if desc == "" then "Highlight settings." else desc); }; + mkPackageOption = + { + name ? null, # Can be null if a custom description is given. + default, + description ? null, + example ? null, + }: + mkOption { + type = with types; nullOr package; + inherit default example; + description = + if description == null then + '' + Which package to use for `${name}`. + Set to `null` to disable its automatic installation. + '' + else + description; + }; + mkPluginPackageOption = name: default: mkOption { diff --git a/plugins/completion/cmp/sources/cmp-fish.nix b/plugins/completion/cmp/sources/cmp-fish.nix index e382869f..90a886d6 100644 --- a/plugins/completion/cmp/sources/cmp-fish.nix +++ b/plugins/completion/cmp/sources/cmp-fish.nix @@ -2,6 +2,7 @@ lib, config, pkgs, + helpers, ... }: with lib; @@ -12,14 +13,9 @@ in meta.maintainers = [ maintainers.GaetanLepage ]; options.plugins.cmp-fish = { - fishPackage = mkOption { - type = with types; nullOr package; + fishPackage = helpers.mkPackageOption { + name = "fish"; default = pkgs.fish; - example = "null"; - description = '' - Which package to use for `fish`. - Set to `null` to disable its automatic installation. - ''; }; }; diff --git a/plugins/git/gitsigns/default.nix b/plugins/git/gitsigns/default.nix index 7caad28b..31cb5f9f 100644 --- a/plugins/git/gitsigns/default.nix +++ b/plugins/git/gitsigns/default.nix @@ -281,13 +281,9 @@ helpers.neovim-plugin.mkNeovimPlugin config { ]; extraOptions = { - gitPackage = mkOption { - type = with types; nullOr package; + gitPackage = helpers.mkPackageOption { + name = "git"; default = pkgs.git; - description = '' - Which package to use for `git`. - Set to `null` to prevent the installation. - ''; }; }; diff --git a/plugins/git/lazygit.nix b/plugins/git/lazygit.nix index 0905553c..d0c27c7b 100644 --- a/plugins/git/lazygit.nix +++ b/plugins/git/lazygit.nix @@ -64,24 +64,14 @@ helpers.vim-plugin.mkVimPlugin config { }; extraOptions = { - gitPackage = mkOption { - type = with types; nullOr package; + gitPackage = helpers.mkPackageOption { + name = "git"; default = pkgs.git; - example = null; - description = '' - The `git` package to use. - Set to `null` to not install any package. - ''; }; - lazygitPackage = mkOption { - type = with types; nullOr package; + lazygitPackage = helpers.mkPackageOption { + name = "lazygit"; default = pkgs.lazygit; - example = null; - description = '' - The `lazygit` package to use. - Set to `null` to not install any package. - ''; }; }; diff --git a/plugins/languages/godot.nix b/plugins/languages/godot.nix index 81636a2e..538683a3 100644 --- a/plugins/languages/godot.nix +++ b/plugins/languages/godot.nix @@ -15,13 +15,9 @@ helpers.vim-plugin.mkVimPlugin config { maintainers = [ maintainers.GaetanLepage ]; extraOptions = { - godotPackage = mkOption { - type = with types; nullOr package; + godotPackage = helpers.mkPackageOption { + name = "godot"; default = pkgs.godot_4; - description = '' - Which package to use for `godot`. - Set to `null` to prevent the installation. - ''; }; }; diff --git a/plugins/languages/lean.nix b/plugins/languages/lean.nix index 653cf8db..48a99a66 100644 --- a/plugins/languages/lean.nix +++ b/plugins/languages/lean.nix @@ -15,11 +15,9 @@ in package = helpers.mkPluginPackageOption "lean-nvim" pkgs.vimPlugins.lean-nvim; - leanPackage = mkOption { - type = with types; nullOr package; + leanPackage = helpers.mkPackageOption { + name = "lean"; default = pkgs.lean4; - description = "Which package to use for lean."; - example = null; }; lsp = helpers.defaultNullOpts.mkNullable ( diff --git a/plugins/languages/ledger.nix b/plugins/languages/ledger.nix index bef4ea79..9552ece4 100644 --- a/plugins/languages/ledger.nix +++ b/plugins/languages/ledger.nix @@ -46,13 +46,9 @@ mkVimPlugin config { ]; extraOptions = { - ledgerPackage = mkOption { - type = with types; nullOr package; + ledgerPackage = helpers.mkPackageOption { + name = "ledger"; default = pkgs.ledger; - description = '' - The package to install for `ledger`. - Set to `null` for disabling installation. - ''; }; }; diff --git a/plugins/languages/rust-tools.nix b/plugins/languages/rust-tools.nix index 83e86b05..5065d4ca 100644 --- a/plugins/languages/rust-tools.nix +++ b/plugins/languages/rust-tools.nix @@ -13,10 +13,9 @@ in options.plugins.rust-tools = helpers.neovim-plugin.extraOptionsOptions // { enable = mkEnableOption "rust tools plugins"; package = helpers.mkPluginPackageOption "rust-tools" pkgs.vimPlugins.rust-tools-nvim; - serverPackage = mkOption { - type = with types; nullOr package; + serverPackage = helpers.mkPackageOption { + name = "rust-analyzer"; default = pkgs.rust-analyzer; - description = "Package to use for rust-analyzer. rust-analyzer will not be installed if this is set to `null`"; }; executor = helpers.defaultNullOpts.mkEnumFirstDefault [ diff --git a/plugins/languages/rustaceanvim.nix b/plugins/languages/rustaceanvim.nix index d7c4c3a0..f4324a4e 100644 --- a/plugins/languages/rustaceanvim.nix +++ b/plugins/languages/rustaceanvim.nix @@ -17,14 +17,9 @@ in package = helpers.mkPluginPackageOption "rustaceanvim" pkgs.vimPlugins.rustaceanvim; - rustAnalyzerPackage = mkOption { - type = with types; nullOr package; + rustAnalyzerPackage = helpers.mkPackageOption { + name = "rust-analyzer"; default = pkgs.rust-analyzer; - description = '' - Which package to use for `rust-analyzer`. - Set to `null` to disable its automatic installation. - ''; - example = null; }; tools = @@ -41,7 +36,7 @@ in { executor = helpers.defaultNullOpts.mkEnum executors "termopen" '' `{execute_command} (fun(cmd:string,args:string[],cwd:string|nil,opts?:RustaceanExecutorOpts))` - The executor to use for runnables/debuggables. + The executor to use for runnables/debuggables. Example: ```lua @@ -62,7 +57,7 @@ in testExecutor = helpers.defaultNullOpts.mkEnum testExecutors "termopen" '' `{execute_command} (fun(cmd:string,args:string[],cwd:string|nil,opts?:RustaceanExecutorOpts))` - The executor to use for runnables that are tests/testables + The executor to use for runnables that are tests/testables ''; crateTestExecutor = helpers.defaultNullOpts.mkEnum testExecutors "termopen" '' diff --git a/plugins/languages/texpresso.nix b/plugins/languages/texpresso.nix index becf15ad..06e9641f 100644 --- a/plugins/languages/texpresso.nix +++ b/plugins/languages/texpresso.nix @@ -16,14 +16,9 @@ helpers.vim-plugin.mkVimPlugin config { maintainers = [ maintainers.nickhu ]; extraOptions = { - texpressoPackage = mkOption { - type = with types; nullOr package; + texpressoPackage = helpers.mkPackageOption { + name = "texpresso"; default = pkgs.texpresso; - example = null; - description = '' - The `texpresso` package to use. - Set to `null` to not install any package. - ''; }; }; diff --git a/plugins/languages/treesitter/treesitter.nix b/plugins/languages/treesitter/treesitter.nix index 42bb6b4d..2be9366d 100644 --- a/plugins/languages/treesitter/treesitter.nix +++ b/plugins/languages/treesitter/treesitter.nix @@ -37,10 +37,8 @@ in description = "Either \"all\" or a list of languages"; }; - gccPackage = mkOption { - type = with types; nullOr package; + gccPackage = helpers.mkPackageOption { default = if cfg.nixGrammars then null else pkgs.gcc; - example = null; description = '' Which package (if any) to be added as the GCC compiler. This is required to build grammars if you are not using `nixGrammars`. diff --git a/plugins/languages/vimtex.nix b/plugins/languages/vimtex.nix index b8aaf625..e931a46b 100644 --- a/plugins/languages/vimtex.nix +++ b/plugins/languages/vimtex.nix @@ -56,14 +56,9 @@ helpers.vim-plugin.mkVimPlugin config { }; extraOptions = { - texlivePackage = mkOption { - type = with types; nullOr package; + texlivePackage = helpers.mkPackageOption { + name = "texlive"; default = pkgs.texlive.combined.scheme-medium; - example = null; - description = '' - The package to install for `textlive. - Set to `null` for not installing `texlive` at all. - ''; }; }; diff --git a/plugins/utils/fzf-lua.nix b/plugins/utils/fzf-lua.nix index 205e581f..3f290176 100644 --- a/plugins/utils/fzf-lua.nix +++ b/plugins/utils/fzf-lua.nix @@ -41,13 +41,9 @@ helpers.neovim-plugin.mkNeovimPlugin config { inherit settingsOptions settingsExample; extraOptions = { - fzfPackage = mkOption { - type = with types; nullOr package; + fzfPackage = helpers.mkPackageOption { + name = "fzf"; default = pkgs.fzf; - description = '' - The fzf package to use. - Set to `null` to not install any package. - ''; example = pkgs.skim; }; diff --git a/plugins/utils/spectre.nix b/plugins/utils/spectre.nix index 410c285d..b7e6500d 100644 --- a/plugins/utils/spectre.nix +++ b/plugins/utils/spectre.nix @@ -246,8 +246,7 @@ helpers.neovim-plugin.mkNeovimPlugin config { replaceDefaultPackage = replacePackages.${toString userCommandSettings.replace.cmd} or null; in { - findPackage = mkOption { - type = with types; nullOr package; + findPackage = helpers.mkPackageOption { default = findDefaultPackage; description = '' Which package to install for the find command. @@ -257,8 +256,7 @@ helpers.neovim-plugin.mkNeovimPlugin config { ''; }; - replacePackage = mkOption { - type = with types; nullOr package; + replacePackage = helpers.mkPackageOption { default = replaceDefaultPackage; description = '' Which package to install for the find command. diff --git a/plugins/utils/todo-comments.nix b/plugins/utils/todo-comments.nix index 34df6829..b95e6e4a 100644 --- a/plugins/utils/todo-comments.nix +++ b/plugins/utils/todo-comments.nix @@ -30,10 +30,8 @@ in package = helpers.mkPluginPackageOption "todo-comments" pkgs.vimPlugins.todo-comments-nvim; - ripgrepPackage = mkOption { - type = with types; nullOr package; + ripgrepPackage = helpers.mkPackageOption { default = pkgs.ripgrep; - example = null; description = "Which package (if any) to be added for file search support in todo-comments."; };