mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 21:30:51 +00:00
Merge pull request #235 from FrothyMarrow/which-key-categories
utility/binds/which-key: allow configurable category labels
This commit is contained in:
commit
37645ff116
16 changed files with 95 additions and 110 deletions
|
@ -56,3 +56,5 @@ Release notes for release 0.6
|
|||
- Rewrote the entire `fidget.nvim` module to include extensive configuration options. Option `vim.fidget-nvim.align.bottom` has
|
||||
been removed in favor of [vim.fidget-nvim.notification.window.align](vim.fidget-nvim.notification.window.align), which now supports
|
||||
`top` and `bottom` values. `vim.fidget-nvim.align.right` has no longer any equivalent and also has been removed.
|
||||
|
||||
- `which-key.nvim` categories can now be customized through [vim.binds.whichKey.register](vim.binds.whichKey.register).
|
||||
|
|
|
@ -68,6 +68,8 @@ in
|
|||
mkSetLuaBinding = binding: action:
|
||||
mkLuaBinding binding.value action binding.description;
|
||||
|
||||
pushDownDefault = attr: self.mapAttrs (name: value: self.mkDefault value) attr;
|
||||
|
||||
# For forward compatibility.
|
||||
literalExpression = super.literalExpression or super.literalExample;
|
||||
})
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
inherit (lib.nvim.binds) mkBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) listToLuaTable expToLua;
|
||||
# TODO: move this to its own module
|
||||
inherit (lib) pushDownDefault;
|
||||
|
||||
cfg = config.vim.filetree.nvimTree;
|
||||
self = import ./nvimtree.nix {inherit pkgs lib;};
|
||||
|
@ -25,6 +27,10 @@ in {
|
|||
(mkBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
||||
];
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>t" = "+NvimTree";
|
||||
};
|
||||
|
||||
vim.luaConfigRC.nvimtreelua = entryAnywhere ''
|
||||
${
|
||||
lib.optionalString cfg.disableNetrw ''
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetExprBinding mkSetLuaBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
# TODO: move this to its own module
|
||||
inherit (lib) pushDownDefault;
|
||||
|
||||
cfg = config.vim.git;
|
||||
|
||||
|
@ -63,6 +65,10 @@ in {
|
|||
(mkSetLuaBinding gsMappings.resetHunk "function() package.loaded.gitsigns.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end")
|
||||
];
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>g" = "+Gitsigns";
|
||||
};
|
||||
|
||||
vim.luaConfigRC.gitsigns = entryAnywhere ''
|
||||
require('gitsigns').setup{}
|
||||
'';
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) addDescriptionsToMappings mkIf mkSetBinding nvim;
|
||||
inherit (lib) addDescriptionsToMappings mkIf mkSetBinding nvim pushDownDefault;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
|
||||
|
@ -17,6 +17,10 @@ in {
|
|||
|
||||
vim.maps.normal = mkSetBinding mappings.open ":CodeActionMenu<CR>";
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>c" = "+CodeAction";
|
||||
};
|
||||
|
||||
vim.luaConfigRC.code-action-menu = nvim.dag.entryAnywhere ''
|
||||
-- border configuration
|
||||
vim.g.code_action_menu_window_border = '${config.vim.ui.borders.plugins.code-action-menu.style}'
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim;
|
||||
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim pushDownDefault;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
|
||||
|
@ -24,6 +24,12 @@ in {
|
|||
(mkSetBinding mappings.locList "<cmd>TroubleToggle loclist<CR>")
|
||||
];
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>l" = "Trouble";
|
||||
"<leader>x" = "+Trouble";
|
||||
"<leader>lw" = "Workspace";
|
||||
};
|
||||
|
||||
vim.luaConfigRC.trouble = nvim.dag.entryAnywhere ''
|
||||
-- Enable trouble diagnostics viewer
|
||||
require("trouble").setup {}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetLuaBinding nvim;
|
||||
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetLuaBinding nvim pushDownDefault;
|
||||
|
||||
cfg = config.vim.minimap.codewindow;
|
||||
|
||||
|
@ -24,6 +24,10 @@ in {
|
|||
(mkSetLuaBinding mappings.toggleFocus "require('codewindow').toggle_focus")
|
||||
];
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>m" = "+Minimap";
|
||||
};
|
||||
|
||||
vim.luaConfigRC.codewindow = nvim.dag.entryAnywhere ''
|
||||
local codewindow = require('codewindow')
|
||||
codewindow.setup({
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf;
|
||||
inherit (lib) mkIf pushDownDefault;
|
||||
|
||||
cfg = config.vim.minimap.minimap-vim;
|
||||
in {
|
||||
|
@ -13,5 +13,9 @@ in {
|
|||
pkgs.code-minimap
|
||||
"minimap-vim"
|
||||
];
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>m" = "+Minimap";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf nvim;
|
||||
inherit (lib) mkIf nvim pushDownDefault;
|
||||
|
||||
cfg = config.vim.notes.mind-nvim;
|
||||
in {
|
||||
|
@ -18,6 +18,10 @@ in {
|
|||
"<leader>oc" = {action = ":MindClose<CR>";};
|
||||
};
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>o" = "+Notes";
|
||||
};
|
||||
|
||||
vim.luaConfigRC.mind-nvim = nvim.dag.entryAnywhere ''
|
||||
require'mind'.setup()
|
||||
'';
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf nvim;
|
||||
inherit (lib) mkIf nvim pushDownDefault;
|
||||
|
||||
cfg = config.vim.notes.obsidian;
|
||||
auto = config.vim.autocomplete;
|
||||
|
@ -15,6 +15,10 @@ in {
|
|||
"tabular"
|
||||
];
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>o" = "+Notes";
|
||||
};
|
||||
|
||||
vim.luaConfigRC.obsidian = nvim.dag.entryAnywhere ''
|
||||
require("obsidian").setup({
|
||||
dir = "${cfg.dir}",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf mkMerge nvim;
|
||||
inherit (lib) mkIf mkMerge nvim pushDownDefault;
|
||||
|
||||
cfg = config.vim.notes.orgmode;
|
||||
in {
|
||||
|
@ -13,6 +13,10 @@ in {
|
|||
"orgmode-nvim"
|
||||
];
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>o" = "+Notes";
|
||||
};
|
||||
|
||||
vim.luaConfigRC.orgmode = nvim.dag.entryAnywhere ''
|
||||
-- Load custom treesitter grammar for org filetype
|
||||
require('orgmode').setup_ts_grammar()
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf mkMerge mkLuaBinding mkBinding nvim;
|
||||
inherit (lib) mkIf mkMerge mkLuaBinding mkBinding nvim pushDownDefault;
|
||||
|
||||
cfg = config.vim.tabline.nvimBufferline;
|
||||
self = import ./nvim-bufferline.nix {
|
||||
|
@ -40,6 +40,13 @@ in {
|
|||
(mkBinding cfg.mappings.movePrevious ":BufferLineMovePrev<CR>" mappings.movePrevious.description)
|
||||
];
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>b" = "+Buffer";
|
||||
"<leader>bm" = "BufferLineMove";
|
||||
"<leader>bs" = "BufferLineSort";
|
||||
"<leader>bsi" = "BufferLineSortById";
|
||||
};
|
||||
|
||||
vim.luaConfigRC.nvimBufferline = nvim.dag.entryAnywhere ''
|
||||
require("bufferline").setup{
|
||||
options = {
|
||||
|
|
|
@ -3,14 +3,17 @@
|
|||
lib,
|
||||
...
|
||||
}: 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;
|
||||
in {
|
||||
config = mkIf (cfg.enable) {
|
||||
vim.startPlugins = ["which-key"];
|
||||
|
||||
vim.luaConfigRC.whichkey = nvim.dag.entryAnywhere ''
|
||||
vim.luaConfigRC.whichkey = entryAnywhere ''
|
||||
local wk = require("which-key")
|
||||
wk.setup ({
|
||||
key_labels = {
|
||||
|
@ -20,108 +23,14 @@ in {
|
|||
["<tab>"] = "TAB",
|
||||
},
|
||||
|
||||
${lib.optionalString (config.vim.ui.borders.plugins.which-key.enable) ''
|
||||
${optionalString (config.vim.ui.borders.plugins.which-key.enable) ''
|
||||
window = {
|
||||
border = "${config.vim.ui.borders.plugins.which-key.style}",
|
||||
},
|
||||
''}
|
||||
})
|
||||
|
||||
wk.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 ""
|
||||
}
|
||||
|
||||
})
|
||||
wk.register(${toLuaObject cfg.register})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,18 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib) mkEnableOption;
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) attrsOf str;
|
||||
in {
|
||||
options.vim.binds.whichKey = {
|
||||
enable = mkEnableOption "which-key keybind helper menu";
|
||||
|
||||
register = mkOption {
|
||||
description = "Register label for which-key keybind helper menu";
|
||||
type = attrsOf str;
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) nvim mkIf mkMerge mkBinding;
|
||||
inherit (lib) nvim mkIf mkMerge mkBinding pushDownDefault;
|
||||
|
||||
cfg = config.vim.utility.preview.glow;
|
||||
self = import ./glow.nix {
|
||||
|
@ -19,6 +19,10 @@ in {
|
|||
(mkBinding cfg.mappings.openPreview ":Glow<CR>" mappings.openPreview.description)
|
||||
];
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>pm" = "+Preview Markdown";
|
||||
};
|
||||
|
||||
vim.luaConfigRC.glow = nvim.dag.entryAnywhere ''
|
||||
require('glow').setup({
|
||||
glow_path = "${pkgs.glow}/bin/glow"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim;
|
||||
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim pushDownDefault;
|
||||
|
||||
cfg = config.vim.telescope;
|
||||
self = import ./telescope.nix {inherit lib;};
|
||||
|
@ -52,6 +52,14 @@ in {
|
|||
)
|
||||
];
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>f" = "+Telescope";
|
||||
"<leader>fl" = "Telescope LSP";
|
||||
"<leader>fm" = "Cellular Automaton";
|
||||
"<leader>fv" = "Telescope Git";
|
||||
"<leader>fvc" = "Commits";
|
||||
};
|
||||
|
||||
vim.luaConfigRC.telescope = nvim.dag.entryAnywhere ''
|
||||
local telescope = require('telescope')
|
||||
telescope.setup {
|
||||
|
|
Loading…
Reference in a new issue