plugins: use mkMappingOption instead of mkOption where possible

This commit is contained in:
alfarel 2026-03-14 22:19:58 -04:00
commit 5e1ee37e7f
No known key found for this signature in database
9 changed files with 113 additions and 411 deletions

View file

@ -8,6 +8,7 @@
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) nullOr str enum float; inherit (lib.types) nullOr str enum float;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (config.vim.lib) mkMappingOption;
cfg = config.vim.assistant.copilot; cfg = config.vim.assistant.copilot;
in { in {
@ -59,72 +60,19 @@ in {
mappings = { mappings = {
panel = { panel = {
jumpPrev = mkOption { jumpPrev = mkMappingOption "Jump to previous suggestion" "[[";
type = nullOr str; jumpNext = mkMappingOption "Jump to next suggestion" "]]";
default = "[["; accept = mkMappingOption "Accept suggestion" "<CR>";
description = "Jump to previous suggestion"; refresh = mkMappingOption "Refresh suggestions" "gr";
}; open = mkMappingOption "Open suggestions" "<M-CR>";
jumpNext = mkOption {
type = nullOr str;
default = "]]";
description = "Jump to next suggestion";
};
accept = mkOption {
type = nullOr str;
default = "<CR>";
description = "Accept suggestion";
};
refresh = mkOption {
type = nullOr str;
default = "gr";
description = "Refresh suggestions";
};
open = mkOption {
type = nullOr str;
default = "<M-CR>";
description = "Open suggestions";
};
}; };
suggestion = { suggestion = {
accept = mkOption { accept = mkMappingOption "Accept suggestion" "<M-l>";
type = nullOr str; acceptWord = mkMappingOption "Accept next word" null;
default = "<M-l>"; acceptLine = mkMappingOption "Accept next line" null;
description = "Accept suggestion"; prev = mkMappingOption "Previous suggestion" "<M-[>";
}; next = mkMappingOption "Next suggestion" "<M-]>";
dismiss = mkMappingOption "Dismiss suggestion" "<C-]>";
acceptWord = mkOption {
type = nullOr str;
default = null;
description = "Accept next word";
};
acceptLine = mkOption {
type = nullOr str;
default = null;
description = "Accept next line";
};
prev = mkOption {
type = nullOr str;
default = "<M-[>";
description = "Previous suggestion";
};
next = mkOption {
type = nullOr str;
default = "<M-]>";
description = "Next suggestion";
};
dismiss = mkOption {
type = nullOr str;
default = "<C-]>";
description = "Dismiss suggestion";
};
}; };
}; };
}; };

View file

@ -1,4 +1,8 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit inherit
(lib.types) (lib.types)
nullOr nullOr
@ -10,30 +14,16 @@
; ;
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption luaInline; inherit (lib.nvim.types) mkPluginSetupOption luaInline;
inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.assistant.supermaven-nvim = { options.vim.assistant.supermaven-nvim = {
enable = mkEnableOption "Supermaven AI assistant"; enable = mkEnableOption "Supermaven AI assistant";
setupOpts = mkPluginSetupOption "Supermaven" { setupOpts = mkPluginSetupOption "Supermaven" {
keymaps = { keymaps = {
accept_suggestion = mkOption { accept_suggestion = mkMappingOption "The key to accept a suggestion" null // {example = "<Tab>";};
type = nullOr str; clear_suggestion = mkMappingOption "The key to clear a suggestion" null // {example = "<C-]>";};
default = null; accept_word = mkMappingOption "The key to accept a word" null // {example = "<C-j>";};
example = "<Tab>";
description = "The key to accept a suggestion";
};
clear_suggestion = mkOption {
type = nullOr str;
default = null;
example = "<C-]>";
description = "The key to clear a suggestion";
};
accept_word = mkOption {
type = nullOr str;
default = null;
example = "<C-j>";
description = "The key to accept a word";
};
}; };
ignore_file = mkOption { ignore_file = mkOption {
type = nullOr (attrsOf bool); type = nullOr (attrsOf bool);

View file

@ -1,13 +1,15 @@
{ {
config,
pkgs, pkgs,
lib, lib,
... ...
}: let }: let
inherit (lib.options) mkEnableOption mkOption literalExpression; inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.types) nullOr str bool int submodule listOf enum oneOf attrs addCheck; inherit (lib.types) str bool int submodule listOf enum oneOf attrs addCheck;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.nvim.config) batchRenameOptions; inherit (lib.nvim.config) batchRenameOptions;
inherit (config.vim.lib) mkMappingOption;
migrationTable = { migrationTable = {
disableNetrw = "disable_netrw"; disableNetrw = "disable_netrw";
@ -76,26 +78,10 @@ in {
enable = mkEnableOption "filetree via nvim-tree.lua"; enable = mkEnableOption "filetree via nvim-tree.lua";
mappings = { mappings = {
toggle = mkOption { toggle = mkMappingOption "Toggle NvimTree" "<leader>t";
type = nullOr str; refresh = mkMappingOption "Refresh NvimTree" "<leader>tr";
default = "<leader>t"; findFile = mkMappingOption "Find file in NvimTree" "<leader>tg";
description = "Toggle NvimTree"; focus = mkMappingOption "Focus NvimTree" "<leader>tf";
};
refresh = mkOption {
type = nullOr str;
default = "<leader>tr";
description = "Refresh NvimTree";
};
findFile = mkOption {
type = nullOr str;
default = "<leader>tg";
description = "Find file in NvimTree";
};
focus = mkOption {
type = nullOr str;
default = "<leader>tf";
description = "Focus NvimTree";
};
}; };
setupOpts = mkPluginSetupOption "Nvim Tree" { setupOpts = mkPluginSetupOption "Nvim Tree" {

View file

@ -14,66 +14,26 @@ in {
}; };
mappings = { mappings = {
goToDefinition = goToDefinition = mkMappingOption "Go to definition" "<leader>lgd";
mkMappingOption "Go to definition" goToDeclaration = mkMappingOption "Go to declaration" "<leader>lgD";
"<leader>lgd"; goToType = mkMappingOption "Go to type" "<leader>lgt";
goToDeclaration = listImplementations = mkMappingOption "List implementations" "<leader>lgi";
mkMappingOption "Go to declaration" listReferences = mkMappingOption "List references" "<leader>lgr";
"<leader>lgD"; nextDiagnostic = mkMappingOption "Go to next diagnostic" "<leader>lgn";
goToType = previousDiagnostic = mkMappingOption "Go to previous diagnostic" "<leader>lgp";
mkMappingOption "Go to type" openDiagnosticFloat = mkMappingOption "Open diagnostic float" "<leader>le";
"<leader>lgt"; documentHighlight = mkMappingOption "Document highlight" "<leader>lH";
listImplementations = listDocumentSymbols = mkMappingOption "List document symbols" "<leader>lS";
mkMappingOption "List implementations" addWorkspaceFolder = mkMappingOption "Add workspace folder" "<leader>lwa";
"<leader>lgi"; removeWorkspaceFolder = mkMappingOption "Remove workspace folder" "<leader>lwr";
listReferences = listWorkspaceFolders = mkMappingOption "List workspace folders" "<leader>lwl";
mkMappingOption "List references" listWorkspaceSymbols = mkMappingOption "List workspace symbols" "<leader>lws";
"<leader>lgr"; hover = mkMappingOption "Trigger hover" "<leader>lh";
nextDiagnostic = signatureHelp = mkMappingOption "Signature help" "<leader>ls";
mkMappingOption "Go to next diagnostic" renameSymbol = mkMappingOption "Rename symbol" "<leader>ln";
"<leader>lgn"; codeAction = mkMappingOption "Code action" "<leader>la";
previousDiagnostic = format = mkMappingOption "Format" "<leader>lf";
mkMappingOption "Go to previous diagnostic" toggleFormatOnSave = mkMappingOption "Toggle format on save" "<leader>ltf";
"<leader>lgp";
openDiagnosticFloat =
mkMappingOption "Open diagnostic float"
"<leader>le";
documentHighlight =
mkMappingOption "Document highlight"
"<leader>lH";
listDocumentSymbols =
mkMappingOption "List document symbols"
"<leader>lS";
addWorkspaceFolder =
mkMappingOption "Add workspace folder"
"<leader>lwa";
removeWorkspaceFolder =
mkMappingOption "Remove workspace folder"
"<leader>lwr";
listWorkspaceFolders =
mkMappingOption "List workspace folders"
"<leader>lwl";
listWorkspaceSymbols =
mkMappingOption "List workspace symbols"
"<leader>lws";
hover =
mkMappingOption "Trigger hover"
"<leader>lh";
signatureHelp =
mkMappingOption "Signature help"
"<leader>ls";
renameSymbol =
mkMappingOption "Rename symbol"
"<leader>ln";
codeAction =
mkMappingOption "Code action"
"<leader>la";
format =
mkMappingOption "Format"
"<leader>lf";
toggleFormatOnSave =
mkMappingOption "Toggle format on save"
"<leader>ltf";
}; };
}; };
} }

View file

@ -1,10 +1,15 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.modules) mkRenamedOptionModule; inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.strings) isString; inherit (lib.strings) isString;
inherit (lib.types) nullOr str bool int enum listOf either; inherit (lib.types) nullOr str bool int enum listOf either;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.types) luaInline mkPluginSetupOption; inherit (lib.nvim.types) luaInline mkPluginSetupOption;
inherit (config.vim.lib) mkMappingOption;
in { in {
imports = let imports = let
renameSetupOpt = oldPath: newPath: renameSetupOpt = oldPath: newPath:
@ -26,29 +31,10 @@ in {
enable = mkEnableOption "nvim-session-manager: manage sessions like folders in VSCode"; enable = mkEnableOption "nvim-session-manager: manage sessions like folders in VSCode";
mappings = { mappings = {
loadSession = mkOption { loadSession = mkMappingOption "Load session" "<leader>sl";
type = nullOr str; deleteSession = mkMappingOption "Delete session" "<leader>sd";
description = "Load session"; saveCurrentSession = mkMappingOption "Save current session" "<leader>sc";
default = "<leader>sl"; loadLastSession = mkMappingOption "Load last session" "<leader>slt";
};
deleteSession = mkOption {
type = nullOr str;
description = "Delete session";
default = "<leader>sd";
};
saveCurrentSession = mkOption {
type = nullOr str;
description = "Save current session";
default = "<leader>sc";
};
loadLastSession = mkOption {
type = nullOr str;
description = "Load last session";
default = "<leader>slt";
};
}; };
usePicker = mkOption { usePicker = mkOption {

View file

@ -5,7 +5,7 @@
... ...
}: let }: let
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) nullOr str enum bool package either int; inherit (lib.types) nullOr enum bool package either int;
inherit (lib.modules) mkRenamedOptionModule; inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.nvim.types) mkPluginSetupOption luaInline; inherit (lib.nvim.types) mkPluginSetupOption luaInline;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
@ -19,11 +19,7 @@ in {
options.vim.terminal.toggleterm = { options.vim.terminal.toggleterm = {
enable = mkEnableOption "toggleterm as a replacement to built-in terminal command"; enable = mkEnableOption "toggleterm as a replacement to built-in terminal command";
mappings = { mappings = {
open = mkOption { open = mkMappingOption "Open toggleterm" "<c-t>";
type = nullOr str;
description = "The keymapping to open toggleterm";
default = "<c-t>";
};
}; };
setupOpts = mkPluginSetupOption "ToggleTerm" { setupOpts = mkPluginSetupOption "ToggleTerm" {

View file

@ -7,6 +7,8 @@
inherit (lib.types) nullOr listOf enum bool str int; inherit (lib.types) nullOr listOf enum bool str int;
inherit (lib.modules) mkRenamedOptionModule; inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.nvim.types) mkPluginSetupOption borderType; inherit (lib.nvim.types) mkPluginSetupOption borderType;
inherit (config.vim.lib) mkMappingOption;
mkSimpleIconOption = default: mkSimpleIconOption = default:
mkOption { mkOption {
inherit default; inherit default;
@ -83,167 +85,33 @@ in {
navbuddy = { navbuddy = {
enable = mkEnableOption "navbuddy LSP helper UI. Enabling this option automatically loads and enables nvim-navic"; enable = mkEnableOption "navbuddy LSP helper UI. Enabling this option automatically loads and enables nvim-navic";
mappings = { mappings = {
close = mkOption { close = mkMappingOption "Close and return the cursor to its original location." "<esc>";
type = str; nextSibling = mkMappingOption "Navigate to the next sibling node." "j";
default = "<esc>"; previousSibling = mkMappingOption "Navigate to the previous sibling node." "k";
description = "Close and return the cursor to its original location."; parent = mkMappingOption "Navigate to the parent node." "h";
}; children = mkMappingOption "Navigate to the child node." "l";
root = mkMappingOption "Navigate to the root node." "0";
nextSibling = mkOption { visualName = mkMappingOption "Select the name visually." "v";
type = str; visualScope = mkMappingOption "Select the scope visually." "V";
default = "j"; yankName = mkMappingOption "Yank the name to system clipboard." "y";
description = "Navigate to the next sibling node."; yankScope = mkMappingOption "Yank the scope to system clipboard." "Y";
}; insertName = mkMappingOption "Insert at the start of name." "i";
insertScope = mkMappingOption "Insert at the start of scope." "I";
previousSibling = mkOption { appendName = mkMappingOption "Insert at the end of name." "a";
type = str; appendScope = mkMappingOption "Insert at the end of scope." "A";
default = "k"; rename = mkMappingOption "Rename the node." "r";
description = "Navigate to the previous sibling node."; delete = mkMappingOption "Delete the node." "d";
}; foldCreate = mkMappingOption "Create a new fold of the node." "f";
foldDelete = mkMappingOption "Delete the current fold of the node." "F";
parent = mkOption { comment = mkMappingOption "Comment the node." "c";
type = str; select = mkMappingOption "Goto the node." "<enter>";
default = "h"; moveDown = mkMappingOption "Move the node down." "J";
description = "Navigate to the parent node."; moveUp = mkMappingOption "Move the node up." "K";
}; togglePreview = mkMappingOption "Toggle the preview." "s";
vsplit = mkMappingOption "Open the node in a vertical split." "<C-v>";
children = mkOption { hsplit = mkMappingOption "Open the node in a horizontal split." "<C-s>";
type = str; telescope = mkMappingOption "Start fuzzy finder at the current level." "t";
default = "l"; help = mkMappingOption "Open the mappings help window." "g?";
description = "Navigate to the child node.";
};
root = mkOption {
type = str;
default = "0";
description = "Navigate to the root node.";
};
visualName = mkOption {
type = str;
default = "v";
description = "Select the name visually.";
};
visualScope = mkOption {
type = str;
default = "V";
description = "Select the scope visually.";
};
yankName = mkOption {
type = str;
default = "y";
description = "Yank the name to system clipboard.";
};
yankScope = mkOption {
type = str;
default = "Y";
description = "Yank the scope to system clipboard.";
};
insertName = mkOption {
type = str;
default = "i";
description = "Insert at the start of name.";
};
insertScope = mkOption {
type = str;
default = "I";
description = "Insert at the start of scope.";
};
appendName = mkOption {
type = str;
default = "a";
description = "Insert at the end of name.";
};
appendScope = mkOption {
type = str;
default = "A";
description = "Insert at the end of scope.";
};
rename = mkOption {
type = str;
default = "r";
description = "Rename the node.";
};
delete = mkOption {
type = str;
default = "d";
description = "Delete the node.";
};
foldCreate = mkOption {
type = str;
default = "f";
description = "Create a new fold of the node.";
};
foldDelete = mkOption {
type = str;
default = "F";
description = "Delete the current fold of the node.";
};
comment = mkOption {
type = str;
default = "c";
description = "Comment the node.";
};
select = mkOption {
type = str;
default = "<enter>";
description = "Goto the node.";
};
moveDown = mkOption {
type = str;
default = "J";
description = "Move the node down.";
};
moveUp = mkOption {
type = str;
default = "K";
description = "Move the node up.";
};
togglePreview = mkOption {
type = str;
default = "s";
description = "Toggle the preview.";
};
vsplit = mkOption {
type = str;
default = "<C-v>";
description = "Open the node in a vertical split.";
};
hsplit = mkOption {
type = str;
default = "<C-s>";
description = "Open the node in a horizontal split.";
};
telescope = mkOption {
type = str;
default = "t";
description = "Start fuzzy finder at the current level.";
};
help = mkOption {
type = str;
default = "g?";
description = "Open the mappings help window.";
};
}; };
setupOpts = mkPluginSetupOption "navbuddy" { setupOpts = mkPluginSetupOption "navbuddy" {

View file

@ -1,38 +1,22 @@
{lib, ...}: let {
inherit (lib.options) mkEnableOption mkOption; config,
inherit (lib.types) nullOr str; lib,
...
}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.utility.motion.flash-nvim = { options.vim.utility.motion.flash-nvim = {
enable = mkEnableOption "enhanced code navigation with flash.nvim"; enable = mkEnableOption "enhanced code navigation with flash.nvim";
setupOpts = mkPluginSetupOption "flash-nvim" {}; setupOpts = mkPluginSetupOption "flash-nvim" {};
mappings = { mappings = {
jump = mkOption { jump = mkMappingOption "Jump" "s";
type = nullOr str; treesitter = mkMappingOption "Treesitter" "S";
default = "s"; remote = mkMappingOption "Remote Flash" "r";
description = "Jump"; treesitter_search = mkMappingOption "Treesitter Search" "R";
}; toggle = mkMappingOption "Toggle Flash Search" "<c-s>";
treesitter = mkOption {
type = nullOr str;
default = "S";
description = "Treesitter";
};
remote = mkOption {
type = nullOr str;
default = "r";
description = "Remote Flash";
};
treesitter_search = mkOption {
type = nullOr str;
default = "R";
description = "Treesitter Search";
};
toggle = mkOption {
type = nullOr str;
default = "<c-s>";
description = "Toggle Flash Search";
};
}; };
}; };
} }

View file

@ -1,36 +1,20 @@
{lib, ...}: let {
inherit (lib.options) mkEnableOption mkOption; config,
inherit (lib.types) nullOr str; lib,
...
}: let
inherit (lib.options) mkEnableOption;
inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.utility.motion.leap = { options.vim.utility.motion.leap = {
enable = mkEnableOption "leap.nvim plugin (easy motion)"; enable = mkEnableOption "leap.nvim plugin (easy motion)";
mappings = { mappings = {
leapForwardTo = mkOption { leapForwardTo = mkMappingOption "Leap forward to" "<leader>ss";
type = nullOr str; leapBackwardTo = mkMappingOption "Leap backward to" "<leader>sS";
description = "Leap forward to"; leapForwardTill = mkMappingOption "Leap forward till" "<leader>sx";
default = "<leader>ss"; leapBackwardTill = mkMappingOption "Leap backward till" "<leader>sX";
}; leapFromWindow = mkMappingOption "Leap from window" "gs";
leapBackwardTo = mkOption {
type = nullOr str;
description = "Leap backward to";
default = "<leader>sS";
};
leapForwardTill = mkOption {
type = nullOr str;
description = "Leap forward till";
default = "<leader>sx";
};
leapBackwardTill = mkOption {
type = nullOr str;
description = "Leap backward till";
default = "<leader>sX";
};
leapFromWindow = mkOption {
type = nullOr str;
description = "Leap from window";
default = "gs";
};
}; };
}; };
} }