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

View file

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

View file

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

View file

@ -14,66 +14,26 @@ in {
};
mappings = {
goToDefinition =
mkMappingOption "Go to definition"
"<leader>lgd";
goToDeclaration =
mkMappingOption "Go to declaration"
"<leader>lgD";
goToType =
mkMappingOption "Go to type"
"<leader>lgt";
listImplementations =
mkMappingOption "List implementations"
"<leader>lgi";
listReferences =
mkMappingOption "List references"
"<leader>lgr";
nextDiagnostic =
mkMappingOption "Go to next diagnostic"
"<leader>lgn";
previousDiagnostic =
mkMappingOption "Go to previous diagnostic"
"<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";
goToDefinition = mkMappingOption "Go to definition" "<leader>lgd";
goToDeclaration = mkMappingOption "Go to declaration" "<leader>lgD";
goToType = mkMappingOption "Go to type" "<leader>lgt";
listImplementations = mkMappingOption "List implementations" "<leader>lgi";
listReferences = mkMappingOption "List references" "<leader>lgr";
nextDiagnostic = mkMappingOption "Go to next diagnostic" "<leader>lgn";
previousDiagnostic = mkMappingOption "Go to previous diagnostic" "<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.modules) mkRenamedOptionModule;
inherit (lib.strings) isString;
inherit (lib.types) nullOr str bool int enum listOf either;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.types) luaInline mkPluginSetupOption;
inherit (config.vim.lib) mkMappingOption;
in {
imports = let
renameSetupOpt = oldPath: newPath:
@ -26,29 +31,10 @@ in {
enable = mkEnableOption "nvim-session-manager: manage sessions like folders in VSCode";
mappings = {
loadSession = mkOption {
type = nullOr str;
description = "Load session";
default = "<leader>sl";
};
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";
};
loadSession = mkMappingOption "Load session" "<leader>sl";
deleteSession = mkMappingOption "Delete session" "<leader>sd";
saveCurrentSession = mkMappingOption "Save current session" "<leader>sc";
loadLastSession = mkMappingOption "Load last session" "<leader>slt";
};
usePicker = mkOption {

View file

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

View file

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

View file

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

View file

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