This commit is contained in:
Alfarel 2026-04-08 00:20:10 +02:00 committed by GitHub
commit b6b8b90e97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 485 additions and 623 deletions

View file

@ -1,8 +1,10 @@
# Custom keymaps {#ch-keymaps} # Custom keymaps {#ch-keymaps}
Some plugin modules provide keymap options for your convenience. If a keymap is Some plugin modules provide keymap options for your convenience. These can be
not provided by such module options, you may easily register your own custom disabled using {option}`vim.vendoredKeymaps`. It is also possible to disable
keymaps via {option}`vim.keymaps`. individual keymaps with options by setting them to `null`. If a keymap is not
provided by a module, you may easily register your own custom keymaps via
{option}`vim.keymaps`.
```nix ```nix
{ {

View file

@ -768,7 +768,7 @@ usage should look something like this:
# pluginDefinition.nix # pluginDefinition.nix
{lib, ...}: let {lib, ...}: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption; inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.plugin = { options.vim.plugin = {
enable = mkEnableOption "Enable plugin"; enable = mkEnableOption "Enable plugin";

View file

@ -195,6 +195,7 @@
{command}`:healthcheck` doesn't know that. {command}`:healthcheck` doesn't know that.
- Remove [which-key.nvim] `<leader>o` `+Notes` description which did not - Remove [which-key.nvim] `<leader>o` `+Notes` description which did not
actually correspond to any keybinds. actually correspond to any keybinds.
- Allow disabling nvf's vendored keymaps by toggling `vendoredKeymaps`.
[pyrox0](https://github.com/pyrox0): [pyrox0](https://github.com/pyrox0):

View file

@ -57,6 +57,7 @@
"rc" "rc"
"warnings" "warnings"
"lazy" "lazy"
"lib"
]; ];
# Extra modules, such as deprecation warnings # Extra modules, such as deprecation warnings

View file

@ -1,5 +1,5 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.options) mkOption literalMD; inherit (lib.options) mkEnableOption mkOption literalMD;
inherit (lib.types) either str listOf attrsOf nullOr submodule; inherit (lib.types) either str listOf attrsOf nullOr submodule;
inherit (lib.nvim.config) mkBool; inherit (lib.nvim.config) mkBool;
@ -57,6 +57,8 @@
}; };
in { in {
options.vim = { options.vim = {
vendoredKeymaps = mkEnableOption "this project's vendored keymaps by default" // {default = true;};
keymaps = mkOption { keymaps = mkOption {
type = listOf mapType; type = listOf mapType;
description = "Custom keybindings."; description = "Custom keybindings.";

View file

@ -1,7 +1,11 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.assistant.chatgpt = { options.vim.assistant.chatgpt = {
enable = mkEnableOption "ChatGPT AI assistant. Requires the environment variable OPENAI_API_KEY to be set"; enable = mkEnableOption "ChatGPT AI assistant. Requires the environment variable OPENAI_API_KEY to be set";

View file

@ -21,11 +21,11 @@
''; '';
mkLuaKeymap = mode: key: action: desc: opts: mkLuaKeymap = mode: key: action: desc: opts:
opts mkIf (key != null) (opts
// { // {
inherit mode key action desc; inherit mode key action desc;
lua = true; lua = true;
}; });
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {

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
@ -11,7 +15,7 @@
; ;
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption luaInline; inherit (lib.nvim.types) mkPluginSetupOption luaInline;
inherit (lib.nvim.binds) mkMappingOption; inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.assistant.neocodeium = { options.vim.assistant.neocodeium = {
enable = mkEnableOption "NeoCodeium AI completion"; enable = mkEnableOption "NeoCodeium AI completion";

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,7 +1,11 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.comments.comment-nvim = { options.vim.comments.comment-nvim = {
enable = mkEnableOption "smart and powerful comment plugin for neovim comment-nvim"; enable = mkEnableOption "smart and powerful comment plugin for neovim comment-nvim";

View file

@ -1,9 +1,13 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption literalMD; inherit (lib.options) mkEnableOption mkOption literalMD;
inherit (lib.types) bool listOf str either attrsOf submodule enum anything int nullOr; inherit (lib.types) bool listOf str either attrsOf submodule enum anything int nullOr;
inherit (lib.nvim.types) mkPluginSetupOption luaInline pluginType; inherit (lib.nvim.types) mkPluginSetupOption luaInline pluginType;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.config) mkBool; inherit (lib.nvim.config) mkBool;
inherit (config.vim.lib) mkMappingOption;
keymapType = submodule { keymapType = submodule {
freeformType = attrsOf (listOf (either str luaInline)); freeformType = attrsOf (listOf (either str luaInline));

View file

@ -5,7 +5,7 @@
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.attrsets) optionalAttrs; inherit (lib.attrsets) mapAttrs' optionalAttrs;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.attrsets) attrValues filterAttrs mapAttrsToList; inherit (lib.attrsets) attrValues filterAttrs mapAttrsToList;
inherit (lib.lists) map optional optionals elem; inherit (lib.lists) map optional optionals elem;
@ -98,51 +98,57 @@ in {
preset = "luasnip"; preset = "luasnip";
}; };
keymap = { keymap =
${mappings.complete} = ["show" "fallback"]; mapAttrs' (mapping-name: action: {
${mappings.close} = ["hide" "fallback"]; name = mappings.${mapping-name};
${mappings.scrollDocsUp} = ["scroll_documentation_up" "fallback"]; value = action;
${mappings.scrollDocsDown} = ["scroll_documentation_down" "fallback"]; }) (filterAttrs (mapping-name: _action: mappings.${mapping-name} != null) {
${mappings.confirm} = ["accept" "fallback"]; complete = ["show" "fallback"];
close = ["hide" "fallback"];
scrollDocsUp = ["scroll_documentation_up" "fallback"];
scrollDocsDown = ["scroll_documentation_down" "fallback"];
confirm = ["accept" "fallback"];
next = [
"select_next"
"snippet_forward"
(mkLuaInline
# lua
''
function(cmp)
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
has_words_before = col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
${mappings.next} = [ if has_words_before then
"select_next" return cmp.show()
"snippet_forward" end
(mkLuaInline
# lua
''
function(cmp)
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
has_words_before = col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
if has_words_before then
return cmp.show()
end end
end '')
'') "fallback"
"fallback" ];
]; previous = [
${mappings.previous} = [ "select_prev"
"select_prev" "snippet_backward"
"snippet_backward" "fallback"
"fallback" ];
]; });
};
# cmdline is not enabled by default, we're just providing keymaps in # cmdline is not enabled by default, we're just providing keymaps in
# case the user enables them # case the user enables them
cmdline.keymap = { cmdline.keymap =
${mappings.complete} = ["show" "fallback"]; mapAttrs' (mapping-name: action: {
${mappings.close} = ["hide" "fallback"]; name = mappings.${mapping-name};
${mappings.scrollDocsUp} = ["scroll_documentation_up" "fallback"]; value = action;
${mappings.scrollDocsDown} = ["scroll_documentation_down" "fallback"]; }) (filterAttrs (mapping-name: _action: mappings.${mapping-name} != null) {
# NOTE: mappings.confirm is skipped because our default, <CR> would complete = ["show" "fallback"];
# lead to accidental triggers of blink.accept instead of executing close = ["hide" "fallback"];
# the cmd scrollDocsUp = ["scroll_documentation_up" "fallback"];
scrollDocsDown = ["scroll_documentation_down" "fallback"];
${mappings.next} = ["select_next" "show" "fallback"]; # NOTE: mappings.confirm is skipped because our default, <CR> would
${mappings.previous} = ["select_prev" "fallback"]; # lead to accidental triggers of blink.accept instead of executing
}; # the cmd
next = ["select_next" "show" "fallback"];
previous = ["select_prev" "fallback"];
});
}; };
}; };
}; };

View file

@ -3,6 +3,7 @@
config, config,
... ...
}: let }: let
inherit (lib.attrsets) filterAttrs mapAttrs';
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
@ -72,48 +73,53 @@ in {
formatting.format = cfg.format; formatting.format = cfg.format;
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section # `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
mapping = { mapping =
${mappings.complete} = mkLuaInline "cmp.mapping.complete()"; mapAttrs' (mapping-name: action: {
${mappings.close} = mkLuaInline "cmp.mapping.abort()"; name = mappings.${mapping-name};
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)"; value = action;
${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)"; }) (filterAttrs (mapping-name: _action: mappings.${mapping-name} != null)
${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })"; {
complete = mkLuaInline "cmp.mapping.complete()";
close = mkLuaInline "cmp.mapping.abort()";
scrollDocsUp = mkLuaInline "cmp.mapping.scroll_docs(-4)";
scrollDocsDown = mkLuaInline "cmp.mapping.scroll_docs(4)";
confirm = mkLuaInline "cmp.mapping.confirm({ select = true })";
${mappings.next} = mkLuaInline '' next = mkLuaInline ''
cmp.mapping(function(fallback) cmp.mapping(function(fallback)
local has_words_before = function() local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0)) local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end end
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
${optionalString luasnipEnable '' ${optionalString luasnipEnable ''
elseif luasnip.locally_jumpable(1) then elseif luasnip.locally_jumpable(1) then
luasnip.jump(1) luasnip.jump(1)
''} ''}
elseif has_words_before() then elseif has_words_before() then
cmp.complete() cmp.complete()
else else
fallback() fallback()
end end
end) end)
''; '';
${mappings.previous} = mkLuaInline '' previous = mkLuaInline ''
cmp.mapping(function(fallback) cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
${optionalString luasnipEnable '' ${optionalString luasnipEnable ''
elseif luasnip.locally_jumpable(-1) then elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1) luasnip.jump(-1)
''} ''}
else else
fallback() fallback()
end end
end) end)
''; '';
}; });
}; };
}; };
}; };

View file

@ -6,9 +6,9 @@
inherit (lib.options) mkEnableOption mkOption literalMD; inherit (lib.options) mkEnableOption mkOption literalMD;
inherit (lib.types) str attrsOf nullOr either listOf; inherit (lib.types) str attrsOf nullOr either listOf;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption luaInline mergelessListOf pluginType; inherit (lib.nvim.types) mkPluginSetupOption luaInline mergelessListOf pluginType;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
inherit (config.vim.lib) mkMappingOption;
inherit (builtins) isString; inherit (builtins) isString;
cfg = config.vim.autocomplete.nvim-cmp; cfg = config.vim.autocomplete.nvim-cmp;

View file

@ -1,8 +1,12 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) bool attrsOf str; inherit (lib.types) bool attrsOf str;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.debugger.nvim-dap = { options.vim.debugger.nvim-dap = {
enable = mkEnableOption "debugging via nvim-dap"; enable = mkEnableOption "debugging via nvim-dap";

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

@ -4,8 +4,8 @@
... ...
}: let }: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.git.git-conflict = { options.vim.git.git-conflict = {
enable = mkEnableOption "git-conflict" // {default = config.vim.git.enable;}; enable = mkEnableOption "git-conflict" // {default = config.vim.git.enable;};

View file

@ -5,8 +5,8 @@
}: let }: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.modules) mkRenamedOptionModule; inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (config.vim.lib) mkMappingOption;
in { in {
imports = [ imports = [
(mkRenamedOptionModule ["vim" "git" "gitsigns" "codeActions" "vim" "gitsigns" "codeActions"] ["vim" "git" "gitsigns" "codeActions" "enable"]) (mkRenamedOptionModule ["vim" "git" "gitsigns" "codeActions" "vim" "gitsigns" "codeActions"] ["vim" "git" "gitsigns" "codeActions" "enable"])

View file

@ -1,7 +1,11 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.git.neogit = { options.vim.git.neogit = {
enable = mkEnableOption "An Interactive and powerful Git interface [Neogit]"; enable = mkEnableOption "An Interactive and powerful Git interface [Neogit]";

View file

@ -214,24 +214,31 @@ in {
on_attach = function(client, bufnr) on_attach = function(client, bufnr)
default_on_attach(client, bufnr) default_on_attach(client, bufnr)
local opts = { noremap=true, silent=true, buffer = bufnr } local opts = { noremap=true, silent=true, buffer = bufnr }
vim.keymap.set("n", "<localleader>rr", ":RustLsp runnables<CR>", opts)
vim.keymap.set("n", "<localleader>rp", ":RustLsp parentModule<CR>", opts) ${optionalString config.vim.vendoredKeymaps ''
vim.keymap.set("n", "<localleader>rm", ":RustLsp expandMacro<CR>", opts) vim.keymap.set("n", "<localleader>rr", ":RustLsp runnables<CR>", opts)
vim.keymap.set("n", "<localleader>rc", ":RustLsp openCargo", opts) vim.keymap.set("n", "<localleader>rp", ":RustLsp parentModule<CR>", opts)
vim.keymap.set("n", "<localleader>rg", ":RustLsp crateGraph x11", opts) vim.keymap.set("n", "<localleader>rm", ":RustLsp expandMacro<CR>", opts)
${optionalString cfg.dap.enable '' vim.keymap.set("n", "<localleader>rc", ":RustLsp openCargo", opts)
vim.keymap.set("n", "<localleader>rg", ":RustLsp crateGraph x11", opts)
''}
${optionalString (cfg.dap.enable && config.vim.vendoredKeymaps) ''
vim.keymap.set("n", "<localleader>rd", ":RustLsp debuggables<cr>", opts) vim.keymap.set("n", "<localleader>rd", ":RustLsp debuggables<cr>", opts)
''}
${optionalString (cfg.dap.enable && config.vim.debugger.nvim-dap.mappings.continue != null) ''
vim.keymap.set( vim.keymap.set(
"n", "${config.vim.debugger.nvim-dap.mappings.continue}", "n", "${config.vim.debugger.nvim-dap.mappings.continue}",
function() function()
local dap = require("dap") local dap = require("dap")
if dap.status() == "" then if dap.status() == "" then
vim.cmd "RustLsp debuggables" vim.cmd "RustLsp debuggables"
else else
dap.continue() dap.continue()
end end
end, end,
opts opts
) )
''} ''}
end end

View file

@ -6,13 +6,13 @@
}: let }: let
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.dag) entryAfter;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.types) mkGrammarOption luaInline; inherit (lib.nvim.types) mkGrammarOption luaInline;
inherit (lib.options) mkOption mkEnableOption mkPackageOption literalExpression; inherit (lib.options) mkOption mkEnableOption mkPackageOption literalExpression;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.types) attrsOf anything bool; inherit (lib.types) attrsOf anything bool;
inherit (config.vim.lib) mkMappingOption;
listCommandsAction = listCommandsAction =
if config.vim.telescope.enable if config.vim.telescope.enable
@ -117,7 +117,9 @@ in {
local attach_metals_keymaps = function(client, bufnr) local attach_metals_keymaps = function(client, bufnr)
attach_keymaps(client, bufnr) -- from lsp-setup attach_keymaps(client, bufnr) -- from lsp-setup
${optionalString (cfg.lsp.extraMappings.listCommands != null) ''
vim.api.nvim_buf_set_keymap(bufnr, 'n', '${cfg.lsp.extraMappings.listCommands}', '<cmd>lua ${listCommandsAction}<CR>', {noremap=true, silent=true, desc='Show all Metals commands'}) vim.api.nvim_buf_set_keymap(bufnr, 'n', '${cfg.lsp.extraMappings.listCommands}', '<cmd>lua ${listCommandsAction}<CR>', {noremap=true, silent=true, desc='Show all Metals commands'})
''}
end end
metals_config = require('metals').bare_config() metals_config = require('metals').bare_config()

View file

@ -13,8 +13,9 @@
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.attrsets) mapListToAttrs; inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (lib.nvim.binds) mkKeymap mkMappingOption; inherit (lib.nvim.binds) mkKeymap;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (config.vim.lib) mkMappingOption;
cfg = config.vim.languages.typst; cfg = config.vim.languages.typst;

View file

@ -1,6 +1,10 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption; inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.lsp = { options.vim.lsp = {
formatOnSave = mkEnableOption "format on save"; formatOnSave = mkEnableOption "format on save";
@ -10,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,9 +1,13 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.types) enum int; inherit (lib.types) enum int;
inherit (lib.modules) mkRenamedOptionModule; inherit (lib.modules) mkRenamedOptionModule;
inherit (config.vim.lib) mkMappingOption;
in { in {
imports = let imports = let
renamedSetupOption = oldPath: newPath: renamedSetupOption = oldPath: newPath:

View file

@ -1,8 +1,12 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.types) bool str listOf; inherit (lib.types) bool str listOf;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.lsp = { options.vim.lsp = {
otter-nvim = { otter-nvim = {

View file

@ -1,7 +1,11 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.lsp = { options.vim.lsp = {
trouble = { trouble = {

View file

@ -1,7 +1,11 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.minimap.codewindow = { options.vim.minimap.codewindow = {
enable = mkEnableOption "codewindow plugin for minimap view"; enable = mkEnableOption "codewindow plugin for minimap view";

View file

@ -1,4 +1,5 @@
{ {
config,
pkgs, pkgs,
lib, lib,
... ...
@ -6,8 +7,8 @@
inherit (lib.modules) mkRenamedOptionModule; inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str listOf; inherit (lib.types) str listOf;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (config.vim.lib) mkMappingOption;
in { in {
imports = let imports = let
renamedSetupOption = oldPath: newPath: renamedSetupOption = oldPath: newPath:

View file

@ -1,7 +1,11 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.nvim.binds) mkMappingOption; inherit (config.vim.lib) mkMappingOption;
in { in {
options = { options = {
vim.runner.run-nvim = { vim.runner.run-nvim = {

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

@ -6,8 +6,8 @@
inherit (lib.options) mkOption mkEnableOption literalExpression literalMD; inherit (lib.options) mkOption mkEnableOption literalExpression literalMD;
inherit (lib.types) enum bool either nullOr str int listOf attrs; inherit (lib.types) enum bool either nullOr str int listOf attrs;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption luaInline; inherit (lib.nvim.types) mkPluginSetupOption luaInline;
inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.tabline.nvimBufferline = { options.vim.tabline.nvimBufferline = {
enable = mkEnableOption "neovim bufferline"; enable = mkEnableOption "neovim bufferline";

View file

@ -54,7 +54,9 @@ in {
end end
}) })
vim.keymap.set('n', ${toLuaObject cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = '${lazygitMapDesc}'}) ${optionalString (cfg.lazygit.mappings.open != null) ''
vim.keymap.set('n', ${toLuaObject cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = '${lazygitMapDesc}'})
''}
''; '';
}; };
}; };

View file

@ -1,14 +1,15 @@
{ {
config,
pkgs, pkgs,
lib, lib,
... ...
}: let }: let
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption; inherit (lib.types) nullOr enum bool package either int;
inherit (lib.types) nullOr str 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;
inherit (config.vim.lib) mkMappingOption;
in { in {
imports = [ imports = [
(mkRenamedOptionModule ["vim" "terminal" "toggleterm" "direction"] ["vim" "terminal" "toggleterm" "setupOpts" "direction"]) (mkRenamedOptionModule ["vim" "terminal" "toggleterm" "direction"] ["vim" "terminal" "toggleterm" "setupOpts" "direction"])
@ -18,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

@ -3,6 +3,7 @@
lib, lib,
... ...
}: let }: let
inherit (lib.attrsets) filterAttrs mapAttrs';
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.lists) optionals; inherit (lib.lists) optionals;
@ -30,57 +31,62 @@ in {
]; ];
vim.ui.breadcrumbs.navbuddy.setupOpts = { vim.ui.breadcrumbs.navbuddy.setupOpts = {
mappings = { mappings =
${cfg.navbuddy.mappings.close} = mkLuaInline "actions.close()"; mapAttrs' (mapping-name: action: {
${cfg.navbuddy.mappings.nextSibling} = mkLuaInline "actions.next_sibling()"; name = cfg.navbuddy.mappings.${mapping-name};
${cfg.navbuddy.mappings.previousSibling} = mkLuaInline "actions.previous_sibling()"; value = action;
${cfg.navbuddy.mappings.parent} = mkLuaInline "actions.parent()"; }) (filterAttrs (mapping-name: _action: cfg.navbuddy.mappings.${mapping-name} != null)
${cfg.navbuddy.mappings.children} = mkLuaInline "actions.children()"; {
${cfg.navbuddy.mappings.root} = mkLuaInline "actions.root()"; close = mkLuaInline "actions.close()";
nextSibling = mkLuaInline "actions.next_sibling()";
previousSibling = mkLuaInline "actions.previous_sibling()";
parent = mkLuaInline "actions.parent()";
children = mkLuaInline "actions.children()";
root = mkLuaInline "actions.root()";
${cfg.navbuddy.mappings.visualName} = mkLuaInline "actions.visual_name()"; visualName = mkLuaInline "actions.visual_name()";
${cfg.navbuddy.mappings.visualScope} = mkLuaInline "actions.visual_scope()"; visualScope = mkLuaInline "actions.visual_scope()";
${cfg.navbuddy.mappings.yankName} = mkLuaInline "actions.yank_name()"; yankName = mkLuaInline "actions.yank_name()";
${cfg.navbuddy.mappings.yankScope} = mkLuaInline "actions.yank_scope()"; yankScope = mkLuaInline "actions.yank_scope()";
${cfg.navbuddy.mappings.insertName} = mkLuaInline "actions.insert_name()"; insertName = mkLuaInline "actions.insert_name()";
${cfg.navbuddy.mappings.insertScope} = mkLuaInline "actions.insert_scope()"; insertScope = mkLuaInline "actions.insert_scope()";
${cfg.navbuddy.mappings.appendName} = mkLuaInline "actions.append_name()"; appendName = mkLuaInline "actions.append_name()";
${cfg.navbuddy.mappings.appendScope} = mkLuaInline "actions.append_scope()"; appendScope = mkLuaInline "actions.append_scope()";
${cfg.navbuddy.mappings.rename} = mkLuaInline "actions.rename()"; rename = mkLuaInline "actions.rename()";
${cfg.navbuddy.mappings.delete} = mkLuaInline "actions.delete()"; delete = mkLuaInline "actions.delete()";
${cfg.navbuddy.mappings.foldCreate} = mkLuaInline "actions.fold_create()"; foldCreate = mkLuaInline "actions.fold_create()";
${cfg.navbuddy.mappings.foldDelete} = mkLuaInline "actions.fold_delete()"; foldDelete = mkLuaInline "actions.fold_delete()";
${cfg.navbuddy.mappings.comment} = mkLuaInline "actions.comment()"; comment = mkLuaInline "actions.comment()";
${cfg.navbuddy.mappings.select} = mkLuaInline "actions.select()"; select = mkLuaInline "actions.select()";
${cfg.navbuddy.mappings.moveDown} = mkLuaInline "actions.move_down()"; moveDown = mkLuaInline "actions.move_down()";
${cfg.navbuddy.mappings.moveUp} = mkLuaInline "actions.move_up()"; moveUp = mkLuaInline "actions.move_up()";
${cfg.navbuddy.mappings.togglePreview} = mkLuaInline "actions.toggle_preview()"; togglePreview = mkLuaInline "actions.toggle_preview()";
${cfg.navbuddy.mappings.vsplit} = mkLuaInline "actions.vsplit()"; vsplit = mkLuaInline "actions.vsplit()";
${cfg.navbuddy.mappings.hsplit} = mkLuaInline "actions.hsplit()"; hsplit = mkLuaInline "actions.hsplit()";
${cfg.navbuddy.mappings.telescope} = mkLuaInline '' telescope = mkLuaInline ''
actions.telescope({ actions.telescope({
layout_strategy = "horizontal", layout_strategy = "horizontal",
layout_config = { layout_config = {
height = 0.60, height = 0.60,
width = 0.75, width = 0.75,
prompt_position = "top", prompt_position = "top",
preview_width = 0.50 preview_width = 0.50
}, },
})''; })'';
${cfg.navbuddy.mappings.help} = mkLuaInline "actions.help()"; help = mkLuaInline "actions.help()";
}; });
}; };
vim.pluginRC.breadcrumbs = entryAfter ["lspconfig"] '' vim.pluginRC.breadcrumbs = entryAfter ["lspconfig"] ''

View file

@ -1,9 +1,13 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) anything attrsOf listOf enum; inherit (lib.types) anything attrsOf listOf enum;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption luaInline; inherit (lib.nvim.types) mkPluginSetupOption luaInline;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.utility.ccc = { options.vim.utility.ccc = {
enable = mkEnableOption "ccc color picker for neovim"; enable = mkEnableOption "ccc color picker for neovim";

View file

@ -1,6 +1,10 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption; inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.gestures.gesture-nvim = { options.vim.gestures.gesture-nvim = {
enable = mkEnableOption "gesture-nvim: mouse gestures"; enable = mkEnableOption "gesture-nvim: mouse gestures";

View file

@ -1,9 +1,13 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) bool; inherit (lib.types) bool;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption luaInline; inherit (lib.nvim.types) mkPluginSetupOption luaInline;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.navigation.harpoon = { options.vim.navigation.harpoon = {
mappings = { mappings = {

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,6 +1,10 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption; inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.utility.motion.hop = { options.vim.utility.motion.hop = {
mappings = { mappings = {

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";
};
}; };
}; };
} }

View file

@ -1,7 +1,11 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.nvim.binds) mkMappingOption; inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.utility.outline.aerial-nvim = { options.vim.utility.outline.aerial-nvim = {
enable = mkEnableOption "Aerial.nvim"; enable = mkEnableOption "Aerial.nvim";

View file

@ -1,7 +1,11 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.modules) mkRenamedOptionModule; inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption; inherit (config.vim.lib) mkMappingOption;
in { in {
imports = [ imports = [
(mkRenamedOptionModule ["vim" "languages" "markdown" "glow" "enable"] ["vim" "utility" "preview" "glow" "enable"]) (mkRenamedOptionModule ["vim" "languages" "markdown" "glow" "enable"] ["vim" "utility" "preview" "glow" "enable"])

View file

@ -1,8 +1,12 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkOption; inherit (lib.options) mkOption;
inherit (lib.types) bool; inherit (lib.types) bool;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.nvim.binds) mkMappingOption; inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.utility.smart-splits = { options.vim.utility.smart-splits = {
enable = mkOption { enable = mkOption {

View file

@ -3,7 +3,7 @@
config, config,
... ...
}: let }: let
inherit (lib.options) mkOption; inherit (lib.options) literalExpression mkOption;
inherit (lib.types) bool str; inherit (lib.types) bool str;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
@ -64,7 +64,8 @@ in {
useVendoredKeybindings = mkOption { useVendoredKeybindings = mkOption {
type = bool; type = bool;
default = true; default = config.vim.vendoredKeymaps;
defaultText = literalExpression "config.vim.vendoredKeymaps";
description = '' description = ''
Use alternative set of keybindings that avoids conflicts with other popular plugins, e.g. nvim-leap Use alternative set of keybindings that avoids conflicts with other popular plugins, e.g. nvim-leap
''; '';

View file

@ -6,8 +6,8 @@
}: let }: let
inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) int str listOf float bool either enum submodule attrsOf anything package; inherit (lib.types) int str listOf float bool either enum submodule attrsOf anything package;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption luaInline; inherit (lib.nvim.types) mkPluginSetupOption luaInline;
inherit (config.vim.lib) mkMappingOption;
cfg = config.vim.telescope; cfg = config.vim.telescope;
setupOptions = { setupOptions = {

View file

@ -1,8 +1,12 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) bool; inherit (lib.types) bool;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.nvim.binds) mkMappingOption; inherit (config.vim.lib) mkMappingOption;
in { in {
options.vim.utility.yazi-nvim = { options.vim.utility.yazi-nvim = {
enable = mkEnableOption '' enable = mkEnableOption ''

View file

@ -1,9 +1,13 @@
{lib, ...}: let {
config,
lib,
...
}: let
inherit (lib.modules) mkRenamedOptionModule; inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.nvim.types) luaInline; inherit (lib.nvim.types) luaInline;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (config.vim.lib) mkMappingOption;
in { in {
imports = [ imports = [
(mkRenamedOptionModule ["vim" "visuals" "cellularAutomaton"] ["vim" "visuals" "cellular-automaton"]) (mkRenamedOptionModule ["vim" "visuals" "cellularAutomaton"] ["vim" "visuals" "cellular-automaton"])

View file

@ -0,0 +1,20 @@
{
config,
lib,
...
}: let
inherit (lib.options) mkOption;
inherit (lib.types) nullOr str;
in {
config.vim.lib = {
mkMappingOption = description: default:
mkOption {
type = nullOr str;
default =
if config.vim.vendoredKeymaps
then default
else null;
inherit description;
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./config.nix
./options.nix
];
}

View file

@ -0,0 +1,11 @@
{lib, ...}: let
inherit (lib.options) mkOption;
inherit (lib.types) attrsOf raw;
in {
options.vim.lib = mkOption {
# The second type should be one without merge semantics and which allows function values.
type = attrsOf raw;
default = {};
internal = true;
};
}