Skip to content

Commit

Permalink
plugins: cleanup most extraConfig args
Browse files Browse the repository at this point in the history
- Remove `cfg` where it is unused.
- Use `opts` where necessary.
  • Loading branch information
MattSturgeon committed Nov 20, 2024
1 parent 63cfc84 commit 7b94afc
Show file tree
Hide file tree
Showing 22 changed files with 96 additions and 97 deletions.
2 changes: 1 addition & 1 deletion plugins/by-name/avante/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
};
};

extraConfig = _: {
extraConfig = {
plugins.avante.luaConfig.pre = ''
require('avante_lib').load()
'';
Expand Down
2 changes: 1 addition & 1 deletion plugins/by-name/bufferline/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
!(
Expand Down
2 changes: 1 addition & 1 deletion plugins/by-name/edgy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
30 changes: 13 additions & 17 deletions plugins/by-name/firenvim/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
85 changes: 40 additions & 45 deletions plugins/by-name/fzf-lua/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
)
{
enable = lib.mkOverride 1490 true;
};

extraPackages = [ cfg.fzfPackage ];
extraPackages = [ cfg.fzfPackage ];

plugins.fzf-lua.settings.__unkeyed_profile = cfg.profile;
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;
};
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;
};
}
2 changes: 1 addition & 1 deletion plugins/by-name/haskell-scope-highlighting/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion plugins/by-name/headlines/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.
'';
Expand Down
2 changes: 1 addition & 1 deletion plugins/by-name/lightline/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
2 changes: 1 addition & 1 deletion plugins/by-name/lsp-lines/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ helpers.neovim-plugin.mkNeovimPlugin {
)
];

extraConfig = cfg: {
extraConfig = {
# Strongly recommended by the plugin, to avoid duplication.
diagnostics.virtual_text = mkDefault false;
};
Expand Down
2 changes: 1 addition & 1 deletion plugins/by-name/telescope/extensions/fzf-native.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ mkExtension {
case_mode = "ignore_case";
};

extraConfig = cfg: {
extraConfig = {
# Native library is in build/libfzf.so
performance.combinePlugins.pathsToLink = [ "/build" ];
};
Expand Down
2 changes: 1 addition & 1 deletion plugins/by-name/treesitter-context/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
];
Expand Down
2 changes: 1 addition & 1 deletion plugins/by-name/ts-autotag/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
];
Expand Down
16 changes: 5 additions & 11 deletions plugins/by-name/which-key/default.nix
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -583,20 +577,20 @@ 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
See: https://github.com/folke/which-key.nvim?tab=readme-ov-file#%EF%B8%8F-mappings
''
];

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})
'';
};
Expand Down
4 changes: 3 additions & 1 deletion plugins/colorschemes/catppuccin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -316,5 +316,7 @@ lib.nixvim.neovim-plugin.mkNeovimPlugin {
};
};

extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
extraConfig = {
opts.termguicolors = lib.mkDefault true;
};
}
4 changes: 3 additions & 1 deletion plugins/colorschemes/everforest.nix
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,7 @@ lib.nixvim.vim-plugin.mkVimPlugin {
};
};

extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
extraConfig = {
opts.termguicolors = lib.mkDefault true;
};
}
4 changes: 3 additions & 1 deletion plugins/colorschemes/melange.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
4 changes: 3 additions & 1 deletion plugins/colorschemes/modus.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
4 changes: 3 additions & 1 deletion plugins/colorschemes/one.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
4 changes: 3 additions & 1 deletion plugins/colorschemes/oxocarbon.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
4 changes: 3 additions & 1 deletion plugins/colorschemes/rose-pine.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
4 changes: 3 additions & 1 deletion plugins/colorschemes/tokyonight.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
10 changes: 4 additions & 6 deletions plugins/lsp/language-servers/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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; };
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 7b94afc

Please sign in to comment.