plugins: cleanup most extraConfig args

- Remove `cfg` where it is unused.
- Use `opts` where necessary.
This commit is contained in:
Matt Sturgeon 2024-11-19 15:47:49 +00:00
parent 63cfc84abe
commit 7b94afceaf
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
22 changed files with 98 additions and 99 deletions

View file

@ -78,7 +78,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
};
};
extraConfig = _: {
extraConfig = {
plugins.avante.luaConfig.pre = ''
require('avante_lib').load()
'';

View file

@ -654,7 +654,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
};
};
extraConfig = cfg: {
extraConfig = {
# TODO: added 2024-09-20 remove after 24.11
plugins.web-devicons = lib.mkIf (
!(

View file

@ -11,7 +11,7 @@ helpers.neovim-plugin.mkNeovimPlugin {
maintainers = [ maintainers.GaetanLepage ];
extraConfig = cfg: {
extraConfig = {
# Those options are strongly recommended by the plugin author:
# https://github.com/folke/edgy.nvim?tab=readme-ov-file#-installation
opts = {

View file

@ -72,21 +72,17 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
'';
callSetup = false;
extraConfig =
let
opt = options.plugins.firenvim;
in
cfg: {
warnings =
lib.optional
(
config.performance.combinePlugins.enable
&& !(lib.elem "firenvim" config.performance.combinePlugins.standalonePlugins)
)
''
Nixvim (plugins.firenvim): Using `performance.combinePlugins` breaks `firenvim`.
Add this plugin to `performance.combinePlugins.standalonePlugins` to prevent any issue.
'';
globals.firenvim_config = lib.modules.mkAliasAndWrapDefsWithPriority lib.id opt.settings;
};
extraConfig = cfg: opts: {
warnings =
lib.optional
(
config.performance.combinePlugins.enable
&& !(lib.elem "firenvim" config.performance.combinePlugins.standalonePlugins)
)
''
Nixvim (plugins.firenvim): Using `performance.combinePlugins` breaks `firenvim`.
Add this plugin to `performance.combinePlugins.standalonePlugins` to prevent any issue.
'';
globals.firenvim_config = lib.modules.mkAliasAndWrapDefsWithPriority lib.id opts.settings;
};
}

View file

@ -101,53 +101,48 @@ helpers.neovim-plugin.mkNeovimPlugin {
};
};
extraConfig =
cfg:
let
opt = options.plugins.fzf-lua;
in
{
# TODO: deprecated 2024-08-29 remove after 24.11
warnings = lib.optionals opt.iconsEnabled.isDefined [
''
The option definition `plugins.fzf-lua.iconsEnabled' in ${lib.showFiles opt.iconsEnabled.files} has been deprecated; please remove it.
''
];
# TODO: added 2024-09-20 remove after 24.11
plugins.web-devicons =
lib.mkIf
(
opt.iconsEnabled.isDefined
&& cfg.iconsEnabled
&& !(
config.plugins.mini.enable
&& config.plugins.mini.modules ? icons
&& config.plugins.mini.mockDevIcons
)
extraConfig = cfg: opts: {
# TODO: deprecated 2024-08-29 remove after 24.11
warnings = lib.optionals opts.iconsEnabled.isDefined [
''
The option definition `plugins.fzf-lua.iconsEnabled' in ${lib.showFiles opts.iconsEnabled.files} has been deprecated; please remove it.
''
];
# TODO: added 2024-09-20 remove after 24.11
plugins.web-devicons =
lib.mkIf
(
opts.iconsEnabled.isDefined
&& cfg.iconsEnabled
&& !(
config.plugins.mini.enable
&& config.plugins.mini.modules ? icons
&& config.plugins.mini.mockDevIcons
)
{
enable = lib.mkOverride 1490 true;
};
extraPackages = [ cfg.fzfPackage ];
plugins.fzf-lua.settings.__unkeyed_profile = cfg.profile;
keymaps = mapAttrsToList (
key: mapping:
let
actionStr =
if isString mapping then
"${mapping}()"
else
"${mapping.action}(${helpers.toLuaObject mapping.settings})";
in
)
{
inherit key;
mode = mapping.mode or "n";
action.__raw = "function() require('fzf-lua').${actionStr} end";
options = mapping.options or { };
}
) cfg.keymaps;
};
enable = lib.mkOverride 1490 true;
};
extraPackages = [ cfg.fzfPackage ];
plugins.fzf-lua.settings.__unkeyed_profile = cfg.profile;
keymaps = mapAttrsToList (
key: mapping:
let
actionStr =
if isString mapping then
"${mapping}()"
else
"${mapping.action}(${helpers.toLuaObject mapping.settings})";
in
{
inherit key;
mode = mapping.mode or "n";
action.__raw = "function() require('fzf-lua').${actionStr} end";
options = mapping.options or { };
}
) cfg.keymaps;
};
}

View file

@ -12,7 +12,7 @@ helpers.vim-plugin.mkVimPlugin {
maintainers = [ lib.maintainers.GaetanLepage ];
extraConfig = _: {
extraConfig = {
warnings = optional (!config.plugins.treesitter.enable) ''
Nixvim (plugins.haskell-scope-highlighting): haskell-scope-highlighting needs treesitter to function as intended.
Please, enable it by setting `plugins.treesitter.enable` to `true`.

View file

@ -21,7 +21,7 @@ helpers.neovim-plugin.mkNeovimPlugin {
markdown.headline_highlights = [ "Headline1" ];
};
extraConfig = cfg: {
extraConfig = {
warnings = optional (!config.plugins.treesitter.enable) ''
Nixvim (plugins.headlines): headlines requires `plugins.treesitter` to be enabled with the relevant grammars installed.
'';

View file

@ -210,7 +210,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
};
callSetup = false;
extraConfig = cfg: {
extraConfig = {
globals.lightline = lib.modules.mkAliasAndWrapDefsWithPriority lib.id options.plugins.lightline.settings;
};
}

View file

@ -31,7 +31,7 @@ helpers.neovim-plugin.mkNeovimPlugin {
)
];
extraConfig = cfg: {
extraConfig = {
# Strongly recommended by the plugin, to avoid duplication.
diagnostics.virtual_text = mkDefault false;
};

View file

@ -43,7 +43,7 @@ mkExtension {
case_mode = "ignore_case";
};
extraConfig = cfg: {
extraConfig = {
# Native library is in build/libfzf.so
performance.combinePlugins.pathsToLink = [ "/build" ];
};

View file

@ -96,7 +96,7 @@ helpers.neovim-plugin.mkNeovimPlugin {
zindex = 20;
};
extraConfig = cfg: {
extraConfig = {
warnings = mkIf (!config.plugins.treesitter.enable) [
"Nixvim: treesitter-context needs treesitter to function as intended"
];

View file

@ -36,7 +36,7 @@ helpers.neovim-plugin.mkNeovimPlugin {
"skipTags"
];
extraConfig = cfg: {
extraConfig = {
warnings = mkIf (!config.plugins.treesitter.enable) [
"Nixvim: ts-autotag needs treesitter to function as intended"
];

View file

@ -1,15 +1,9 @@
{
lib,
options,
...
}:
{ lib, ... }:
with lib;
let
inherit (lib) types;
inherit (lib.nixvim) defaultNullOpts mkRaw toLuaObject;
opt = options.plugins.which-key;
specExamples = [
# Basic group with custom icon
{
@ -583,12 +577,12 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
# TODO: introduced 2024-07-29: remove after 24.11
# NOTE: this may be upgraded to a mkRemoveOptionModule when which-key removes support
extraConfig =
cfg:
lib.mkIf opt.registrations.isDefined {
cfg: opts:
lib.mkIf opts.registrations.isDefined {
warnings = [
''
nixvim (plugins.which-key):
The option definition `plugins.which-key.registrations' in ${showFiles opt.registrations.files} has been deprecated in which-key v3; please remove it.
The option definition `plugins.which-key.registrations' in ${showFiles opts.registrations.files} has been deprecated in which-key v3; please remove it.
You should use `plugins.which-key.settings.spec' instead.
Note: the spec format has changed in which-key v3
@ -596,7 +590,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
''
];
plugins.which-key.luaConfig.content = lib.optionalString opt.registrations.isDefined ''
plugins.which-key.luaConfig.content = lib.optionalString opts.registrations.isDefined ''
require("which-key").register(${toLuaObject cfg.registrations})
'';
};

View file

@ -316,5 +316,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
};
};
extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
extraConfig = {
opts.termguicolors = lib.mkDefault true;
};
}

View file

@ -251,5 +251,7 @@ lib.nixvim.vim-plugin.mkVimPlugin {
};
};
extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
extraConfig = {
opts.termguicolors = lib.mkDefault true;
};
}

View file

@ -10,5 +10,7 @@ lib.nixvim.vim-plugin.mkVimPlugin {
maintainers = [ lib.maintainers.GaetanLepage ];
extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
extraConfig = {
opts.termguicolors = lib.mkDefault true;
};
}

View file

@ -108,5 +108,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
on_highlights = "function(highlights, colors) end";
};
extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
extraConfig = {
opts.termguicolors = lib.mkDefault true;
};
}

View file

@ -21,5 +21,7 @@ lib.nixvim.vim-plugin.mkVimPlugin {
allow_italics = true;
};
extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
extraConfig = {
opts.termguicolors = lib.mkDefault true;
};
}

View file

@ -10,5 +10,7 @@ lib.nixvim.vim-plugin.mkVimPlugin {
maintainers = [ lib.maintainers.GaetanLepage ];
extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
extraConfig = {
opts.termguicolors = lib.mkDefault true;
};
}

View file

@ -154,5 +154,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
before_highlight = "function(group, highlight, palette) end";
};
extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
extraConfig = {
opts.termguicolors = lib.mkDefault true;
};
}

View file

@ -177,5 +177,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
on_highlights = "function(highlights, colors) end";
};
extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
extraConfig = {
opts.termguicolors = lib.mkDefault true;
};
}

View file

@ -24,11 +24,9 @@ let
};
};
idris2_lsp = {
extraConfig =
cfg:
mkIf cfg.enable {
plugins.idris2.enable = lib.mkDefault true;
};
extraConfig = {
plugins.idris2.enable = lib.mkDefault true;
};
};
jsonls = {
settings = cfg: { json = cfg; };
@ -115,7 +113,7 @@ let
ts_ls = {
# NOTE: Provide the plugin default filetypes so that
# `plugins.lsp.servers.volar.tslsIntegration` doesn't wipe out the default filetypes
extraConfig = cfg: {
extraConfig = {
plugins.lsp.servers.ts_ls = {
filetypes = [
"javascript"