mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-01-07 03:07:17 +00:00
utility/binds/which-key: allow configurable category labels
This commit is contained in:
parent
f7bd0fff01
commit
c027c9b1bf
2 changed files with 123 additions and 100 deletions
|
|
@ -3,14 +3,17 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) mkIf nvim;
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.strings) optionalString;
|
||||||
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
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.luaConfigRC.whichkey = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.whichkey = entryAnywhere ''
|
||||||
local wk = require("which-key")
|
local wk = require("which-key")
|
||||||
wk.setup ({
|
wk.setup ({
|
||||||
key_labels = {
|
key_labels = {
|
||||||
|
|
@ -20,108 +23,14 @@ in {
|
||||||
["<tab>"] = "TAB",
|
["<tab>"] = "TAB",
|
||||||
},
|
},
|
||||||
|
|
||||||
${lib.optionalString (config.vim.ui.borders.plugins.which-key.enable) ''
|
${optionalString (config.vim.ui.borders.plugins.which-key.enable) ''
|
||||||
window = {
|
window = {
|
||||||
border = "${config.vim.ui.borders.plugins.which-key.style}",
|
border = "${config.vim.ui.borders.plugins.which-key.style}",
|
||||||
},
|
},
|
||||||
''}
|
''}
|
||||||
})
|
})
|
||||||
|
|
||||||
wk.register({
|
wk.register(${toLuaObject cfg.register})
|
||||||
${
|
|
||||||
if config.vim.tabline.nvimBufferline.enable
|
|
||||||
then ''
|
|
||||||
-- Buffer
|
|
||||||
["<leader>b"] = { name = "+Buffer" },
|
|
||||||
["<leader>bm"] = { name = "BufferLineMove" },
|
|
||||||
["<leader>bs"] = { name = "BufferLineSort" },
|
|
||||||
["<leader>bsi"] = { name = "BufferLineSortById" },
|
|
||||||
''
|
|
||||||
else ""
|
|
||||||
}
|
|
||||||
|
|
||||||
${
|
|
||||||
if config.vim.telescope.enable
|
|
||||||
then ''
|
|
||||||
["<leader>f"] = { name = "+Telescope" },
|
|
||||||
-- Telescope
|
|
||||||
["<leader>fl"] = { name = "Telescope LSP" },
|
|
||||||
["<leader>fm"] = { name = "Cellular Automaton" }, -- TODO: mvoe this to its own parent group
|
|
||||||
["<leader>fv"] = { name = "Telescope Git" },
|
|
||||||
["<leader>fvc"] = { name = "Commits" },
|
|
||||||
''
|
|
||||||
else ""
|
|
||||||
}
|
|
||||||
|
|
||||||
${
|
|
||||||
if config.vim.lsp.trouble.enable
|
|
||||||
then ''
|
|
||||||
-- Trouble
|
|
||||||
["<leader>lw"] = { name = "Workspace" },
|
|
||||||
["<leader>x"] = { name = "+Trouble" }, -- TODO: move all trouble binds to the same parent group
|
|
||||||
["<leader>l"] = { name = "+Trouble" },
|
|
||||||
''
|
|
||||||
else ""
|
|
||||||
}
|
|
||||||
|
|
||||||
${
|
|
||||||
if config.vim.lsp.nvimCodeActionMenu.enable
|
|
||||||
then ''
|
|
||||||
-- Parent Groups
|
|
||||||
["<leader>c"] = { name = "+CodeAction" },
|
|
||||||
''
|
|
||||||
else ""
|
|
||||||
}
|
|
||||||
|
|
||||||
${
|
|
||||||
if config.vim.minimap.codewindow.enable || config.vim.minimap.minimap-vim.enable
|
|
||||||
then ''
|
|
||||||
-- Minimap
|
|
||||||
["<leader>m"] = { name = "+Minimap" }, -- TODO: remap both minimap plugins' keys to be the same
|
|
||||||
''
|
|
||||||
else ""
|
|
||||||
}
|
|
||||||
|
|
||||||
${
|
|
||||||
if config.vim.notes.mind-nvim.enable || config.vim.notes.obsidian.enable || config.vim.notes.orgmode.enable
|
|
||||||
then ''
|
|
||||||
-- Notes
|
|
||||||
["<leader>o"] = { name = "+Notes" },
|
|
||||||
-- TODO: options for other note taking plugins and their individual binds
|
|
||||||
-- TODO: move all note-taker binds under leader + o
|
|
||||||
''
|
|
||||||
else ""
|
|
||||||
}
|
|
||||||
|
|
||||||
${
|
|
||||||
# TODO: This probably will need to be reworked for custom-keybinds
|
|
||||||
if config.vim.filetree.nvimTree.enable
|
|
||||||
then ''
|
|
||||||
-- NvimTree
|
|
||||||
["<leader>t"] = { name = "+NvimTree" },
|
|
||||||
''
|
|
||||||
else ""
|
|
||||||
}
|
|
||||||
|
|
||||||
${
|
|
||||||
if config.vim.git.gitsigns.enable
|
|
||||||
then ''
|
|
||||||
-- Git
|
|
||||||
["<leader>g"] = { name = "+Gitsigns" },
|
|
||||||
''
|
|
||||||
else ""
|
|
||||||
}
|
|
||||||
|
|
||||||
${
|
|
||||||
if config.vim.utility.preview.glow.enable
|
|
||||||
then ''
|
|
||||||
-- Markdown
|
|
||||||
["<leader>pm"] = { name = "+Preview Markdown" },
|
|
||||||
''
|
|
||||||
else ""
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,121 @@
|
||||||
{lib, ...}: let
|
{
|
||||||
inherit (lib) mkEnableOption;
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
|
inherit (lib.lists) optionals;
|
||||||
|
inherit (lib.types) submodule listOf str;
|
||||||
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 {
|
||||||
|
description = "Register label for which-key keybind helper menu";
|
||||||
|
type = listOf (submodule {
|
||||||
|
options = {
|
||||||
|
keybind = mkOption {
|
||||||
|
type = str;
|
||||||
|
description = "Keybind to register";
|
||||||
|
};
|
||||||
|
label = mkOption {
|
||||||
|
type = str;
|
||||||
|
description = "Label for keybind";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
default =
|
||||||
|
optionals config.vim.tabline.nvimBufferline.enable [
|
||||||
|
{
|
||||||
|
keybind = "<leader>b";
|
||||||
|
label = "+Buffer";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
keybind = "<leader>bm";
|
||||||
|
label = "BufferLineMove";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
keybind = "<leader>bs";
|
||||||
|
label = "BufferLineSort";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
keybind = "<leader>bsi";
|
||||||
|
label = "BufferLineSortById";
|
||||||
|
}
|
||||||
|
]
|
||||||
|
++ optionals config.vim.telescope.enable [
|
||||||
|
{
|
||||||
|
keybind = "<leader>f";
|
||||||
|
label = "+Telescope";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
keybind = "<leader>fl";
|
||||||
|
label = "Telescope LSP";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
keybind = "<leader>fm";
|
||||||
|
label = "Cellular Automaton";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
keybind = "<leader>fv";
|
||||||
|
label = "Telescope Git";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
keybind = "<leader>fvc";
|
||||||
|
label = "Commits";
|
||||||
|
}
|
||||||
|
]
|
||||||
|
++ optionals config.vim.lsp.trouble.enable [
|
||||||
|
{
|
||||||
|
keybind = "<leader>lw";
|
||||||
|
label = "Workspace";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
keybind = "<leader>x";
|
||||||
|
label = "+Trouble";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
keybind = "<leader>l";
|
||||||
|
label = "Trouble";
|
||||||
|
}
|
||||||
|
]
|
||||||
|
++ optionals config.vim.lsp.nvimCodeActionMenu.enable [
|
||||||
|
{
|
||||||
|
keybind = "<leader>c";
|
||||||
|
label = "+CodeAction";
|
||||||
|
}
|
||||||
|
]
|
||||||
|
++ optionals (config.vim.minimap.codewindow.enable || config.vim.minimap.minimap-vim.enable) [
|
||||||
|
{
|
||||||
|
keybind = "<leader>m";
|
||||||
|
label = "+Minimap";
|
||||||
|
}
|
||||||
|
]
|
||||||
|
++ optionals (config.vim.notes.mind-nvim.enable || config.vim.notes.obsidian.enable || config.vim.notes.orgmode.enable) [
|
||||||
|
{
|
||||||
|
keybind = "<leader>o";
|
||||||
|
label = "+Notes";
|
||||||
|
}
|
||||||
|
]
|
||||||
|
++ optionals config.vim.filetree.nvimTree.enable [
|
||||||
|
{
|
||||||
|
keybind = "<leader>t";
|
||||||
|
label = "+NvimTree";
|
||||||
|
}
|
||||||
|
]
|
||||||
|
++ optionals config.vim.git.gitsigns.enable [
|
||||||
|
{
|
||||||
|
keybind = "<leader>g";
|
||||||
|
label = "+Gitsigns";
|
||||||
|
}
|
||||||
|
]
|
||||||
|
++ optionals config.vim.utility.preview.glow.enable [
|
||||||
|
{
|
||||||
|
keybind = "<leader>pm";
|
||||||
|
label = "+Preview Markdown";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
apply = map (x: {${x.keybind} = {name = x.label;};});
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue