mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 21:30:51 +00:00
binds/which-key: migrate to setupOpts
This commit is contained in:
parent
7a0e7739c5
commit
a42a4a4fb6
3 changed files with 51 additions and 27 deletions
|
@ -4,33 +4,20 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.strings) optionalString;
|
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
|
|
||||||
cfg = config.vim.binds.whichKey;
|
cfg = config.vim.binds.whichKey;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = ["which-key"];
|
vim = {
|
||||||
|
startPlugins = ["which-key"];
|
||||||
|
|
||||||
vim.pluginRC.whichkey = entryAnywhere ''
|
pluginRC.whichkey = entryAnywhere ''
|
||||||
local wk = require("which-key")
|
local wk = require("which-key")
|
||||||
wk.setup ({
|
wk.setup (${toLuaObject cfg.setupOpts})
|
||||||
key_labels = {
|
wk.register(${toLuaObject cfg.register})
|
||||||
["<space>"] = "SPACE",
|
'';
|
||||||
["<leader>"] = "SPACE",
|
};
|
||||||
["<cr>"] = "RETURN",
|
|
||||||
["<tab>"] = "TAB",
|
|
||||||
},
|
|
||||||
|
|
||||||
${optionalString config.vim.ui.borders.plugins.which-key.enable ''
|
|
||||||
window = {
|
|
||||||
border = ${toLuaObject config.vim.ui.borders.plugins.which-key.style},
|
|
||||||
},
|
|
||||||
''}
|
|
||||||
})
|
|
||||||
|
|
||||||
wk.register(${toLuaObject cfg.register})
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
_: {
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./which-key.nix
|
./which-key.nix
|
||||||
./config.nix
|
./config.nix
|
||||||
|
|
|
@ -1,14 +1,51 @@
|
||||||
{lib, ...}: let
|
{
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
config,
|
||||||
inherit (lib.types) attrsOf nullOr str;
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
|
inherit (lib.types) attrsOf nullOr str attrs enum bool;
|
||||||
|
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||||
in {
|
in {
|
||||||
options.vim.binds.whichKey = {
|
options.vim.binds.whichKey = {
|
||||||
enable = mkEnableOption "which-key keybind helper menu";
|
enable = mkEnableOption "which-key keybind helper menu";
|
||||||
|
|
||||||
register = mkOption {
|
register = mkOption {
|
||||||
description = "Register label for which-key keybind helper menu";
|
|
||||||
type = attrsOf (nullOr str);
|
type = attrsOf (nullOr str);
|
||||||
default = {};
|
default = {};
|
||||||
|
description = "Register label for which-key keybind helper menu";
|
||||||
|
};
|
||||||
|
|
||||||
|
setupOpts = mkPluginSetupOption "which-key" {
|
||||||
|
preset = mkOption {
|
||||||
|
type = enum ["classic" "modern" "helix"];
|
||||||
|
default = "modern";
|
||||||
|
description = "The default preset for the which-key window";
|
||||||
|
};
|
||||||
|
|
||||||
|
notify = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = true;
|
||||||
|
description = "Show a warning when issues were detected with mappings";
|
||||||
|
};
|
||||||
|
|
||||||
|
replace = mkOption {
|
||||||
|
type = attrs;
|
||||||
|
default = {
|
||||||
|
"<space>" = "SPACE";
|
||||||
|
"<leader>" = "SPACE";
|
||||||
|
"<cr>" = "RETURN";
|
||||||
|
"<tab>" = "TAB";
|
||||||
|
};
|
||||||
|
description = "Functions/Lua Patterns for formatting the labels";
|
||||||
|
};
|
||||||
|
|
||||||
|
win = {
|
||||||
|
border = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = config.vim.ui.borders.plugins.which-key.style;
|
||||||
|
description = "Which-key window border style";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue