From 4354cabc39ba79821d7837f71d175a3f7cad9374 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 17 Feb 2023 12:40:58 +0300 Subject: [PATCH 1/5] feat: group names for which-key --- modules/utility/binds/which-key.nix | 31 ++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/modules/utility/binds/which-key.nix b/modules/utility/binds/which-key.nix index ef9fdf60..ce65134b 100644 --- a/modules/utility/binds/which-key.nix +++ b/modules/utility/binds/which-key.nix @@ -15,6 +15,35 @@ in { config = mkIf (cfg.enable) { vim.startPlugins = ["which-key"]; - vim.luaConfigRC.whichkey = nvim.dag.entryAnywhere ''local wk = require("which-key").setup {}''; + vim.luaConfigRC.whichkey = nvim.dag.entryAnywhere '' + require("which-key").setup {} + + local wk = require("which-key") + wk.register({ + ["b"] = { name = "+Buffer" }, + ["c"] = { name = "+CodeAction" }, + ["b"] = { name = "+Buffer" }, + ["f"] = { name = "+Telescope" }, + ["m"] = { name = "+Minimap" }, + ["o"] = { name = "+Notes" }, + ["t"] = { name = "+NvimTree" }, + ["x"] = { name = "+Trouble" }, -- TODO: move all trouble binds to the same parent group + ["l"] = { name = "+Trouble" }, + + -- Buffer + ["bm"] = { name = "BufferLineMove" }, + ["bm"] = { name = "BufferLineSort" }, + + -- Telescope + ["fl"] = { name = "Telescope LSP" }, + ["fm"] = { name = "Cellular Automaton" }, -- TODO: mvoe this to its own parent group + ["fv"] = { name = "Telescope Git" }, + ["fvc"] = { name = "Commits" }, + + -- Trouble + ["lw"] = { name = "Workspace" }, + }) + + ''; }; } From b4027c4bbafc921258d24f0f6aa09807f38f3c56 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 17 Feb 2023 13:49:29 +0300 Subject: [PATCH 2/5] feat: conditionally write which-key registers --- modules/utility/binds/which-key.nix | 49 -------- .../cheatsheet/default.nix} | 0 .../utility/{binds => utility}/default.nix | 4 +- modules/utility/utility/which-key/default.nix | 109 ++++++++++++++++++ 4 files changed, 111 insertions(+), 51 deletions(-) delete mode 100644 modules/utility/binds/which-key.nix rename modules/utility/{binds/cheatsheet.nix => utility/cheatsheet/default.nix} (100%) rename modules/utility/{binds => utility}/default.nix (59%) create mode 100644 modules/utility/utility/which-key/default.nix diff --git a/modules/utility/binds/which-key.nix b/modules/utility/binds/which-key.nix deleted file mode 100644 index ce65134b..00000000 --- a/modules/utility/binds/which-key.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: -with lib; -with builtins; let - cfg = config.vim.binds.whichKey; -in { - options.vim.binds.whichKey = { - enable = mkEnableOption "which-key menu"; - }; - - config = mkIf (cfg.enable) { - vim.startPlugins = ["which-key"]; - - vim.luaConfigRC.whichkey = nvim.dag.entryAnywhere '' - require("which-key").setup {} - - local wk = require("which-key") - wk.register({ - ["b"] = { name = "+Buffer" }, - ["c"] = { name = "+CodeAction" }, - ["b"] = { name = "+Buffer" }, - ["f"] = { name = "+Telescope" }, - ["m"] = { name = "+Minimap" }, - ["o"] = { name = "+Notes" }, - ["t"] = { name = "+NvimTree" }, - ["x"] = { name = "+Trouble" }, -- TODO: move all trouble binds to the same parent group - ["l"] = { name = "+Trouble" }, - - -- Buffer - ["bm"] = { name = "BufferLineMove" }, - ["bm"] = { name = "BufferLineSort" }, - - -- Telescope - ["fl"] = { name = "Telescope LSP" }, - ["fm"] = { name = "Cellular Automaton" }, -- TODO: mvoe this to its own parent group - ["fv"] = { name = "Telescope Git" }, - ["fvc"] = { name = "Commits" }, - - -- Trouble - ["lw"] = { name = "Workspace" }, - }) - - ''; - }; -} diff --git a/modules/utility/binds/cheatsheet.nix b/modules/utility/utility/cheatsheet/default.nix similarity index 100% rename from modules/utility/binds/cheatsheet.nix rename to modules/utility/utility/cheatsheet/default.nix diff --git a/modules/utility/binds/default.nix b/modules/utility/utility/default.nix similarity index 59% rename from modules/utility/binds/default.nix rename to modules/utility/utility/default.nix index 9dd64ac2..7c08cc6a 100644 --- a/modules/utility/binds/default.nix +++ b/modules/utility/utility/default.nix @@ -5,7 +5,7 @@ ... }: { imports = [ - ./which-key.nix - ./cheatsheet.nix + ./which-key + ./cheatsheet ]; } diff --git a/modules/utility/utility/which-key/default.nix b/modules/utility/utility/which-key/default.nix new file mode 100644 index 00000000..66b3f3f9 --- /dev/null +++ b/modules/utility/utility/which-key/default.nix @@ -0,0 +1,109 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.binds.whichKey; +in { + options.vim.binds.whichKey = { + enable = mkEnableOption "which-key menu"; + }; + + config = mkIf (cfg.enable) { + vim.startPlugins = ["which-key"]; + + vim.luaConfigRC.whichkey = nvim.dag.entryAnywhere '' + require("which-key").setup {} + + local wk = require("which-key") + wk.register({ + + ${ + if config.vim.tabline.nvimBufferline.enable + then '' + -- Buffer + ["b"] = { name = "+Buffer" }, + ["bm"] = { name = "BufferLineMove" }, + '' + else "" + } + + ${ + if config.vim.telescope.enable + then '' + ["f"] = { name = "+Telescope" }, + -- Telescope + ["fl"] = { name = "Telescope LSP" }, + ["fm"] = { name = "Cellular Automaton" }, -- TODO: mvoe this to its own parent group + ["fv"] = { name = "Telescope Git" }, + ["fvc"] = { name = "Commits" }, + '' + else "" + } + + ${ + if config.vim.lsp.trouble.enable + then '' + -- Trouble + ["lw"] = { name = "Workspace" }, + ["x"] = { name = "+Trouble" }, -- TODO: move all trouble binds to the same parent group + ["l"] = { name = "+Trouble" }, + '' + else "" + } + + ${ + if config.vim.lsp.nvimCodeActionMenu.enable + then '' + -- Parent Groups + ["c"] = { name = "+CodeAction" }, + '' + else "" + } + + ${ + if config.vim.minimap.codewindow.enable || config.vim.minimap.minimap-vim.enable + then '' + -- Minimap + ["m"] = { name = "+Minimap" }, + '' + else "" + } + + ${ + if config.vim.notes.mind-nvim.enable || config.vim.notes.obsidian.enable || config.vim.notes.orgmode.enable + then '' + -- Notes + ["o"] = { name = "+Notes" }, + -- TODO: options for other note taking plugins and their individual binds + -- TODO: move all note-taker binds under leader + o + '' + else "" + } + + ${ + if config.vim.filetree.nvimTreeLua.enable + then '' + -- NvimTree + ["t"] = { name = "+NvimTree" }, + '' + else "" + } + + ${ + if config.vim.git.gitsigns.enable + then '' + -- Git + ["g"] = { name = "+Gitsigns" }, + '' + else "" + } + + }) + + ''; + }; +} From 85b663f6c9cda9460231cea22e0be0e513595d92 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 17 Feb 2023 13:51:15 +0300 Subject: [PATCH 3/5] fix: accidental dir rename --- modules/utility/{utility => binds}/cheatsheet/default.nix | 0 modules/utility/{utility => binds}/default.nix | 0 modules/utility/{utility => binds}/which-key/default.nix | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename modules/utility/{utility => binds}/cheatsheet/default.nix (100%) rename modules/utility/{utility => binds}/default.nix (100%) rename modules/utility/{utility => binds}/which-key/default.nix (100%) diff --git a/modules/utility/utility/cheatsheet/default.nix b/modules/utility/binds/cheatsheet/default.nix similarity index 100% rename from modules/utility/utility/cheatsheet/default.nix rename to modules/utility/binds/cheatsheet/default.nix diff --git a/modules/utility/utility/default.nix b/modules/utility/binds/default.nix similarity index 100% rename from modules/utility/utility/default.nix rename to modules/utility/binds/default.nix diff --git a/modules/utility/utility/which-key/default.nix b/modules/utility/binds/which-key/default.nix similarity index 100% rename from modules/utility/utility/which-key/default.nix rename to modules/utility/binds/which-key/default.nix From 50a58d1d5f2f783d6fbcff5b4908636344dcf593 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 17 Feb 2023 13:52:17 +0300 Subject: [PATCH 4/5] disable kommentary by default --- extra.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra.nix b/extra.nix index b5231fb7..e767e1e8 100644 --- a/extra.nix +++ b/extra.nix @@ -163,7 +163,7 @@ inputs: let vim.comments = { comment-nvim.enable = true; - kommentary = builtins.trace "WARNING: kommentary is deprecated and will be removed in the future, use comment-nvim instead" {enable = true;}; + kommentary = builtins.trace "WARNING: kommentary is deprecated and will be removed in the future, use comment-nvim instead" {enable = false;}; }; }; }; From 5916a392b61f22105aadfd44cd268f9efe75bb74 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 17 Feb 2023 14:20:32 +0300 Subject: [PATCH 5/5] feat: which-key sortById key for bufferline --- modules/utility/binds/which-key/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/utility/binds/which-key/default.nix b/modules/utility/binds/which-key/default.nix index 66b3f3f9..bd06bf33 100644 --- a/modules/utility/binds/which-key/default.nix +++ b/modules/utility/binds/which-key/default.nix @@ -27,6 +27,9 @@ in { -- Buffer ["b"] = { name = "+Buffer" }, ["bm"] = { name = "BufferLineMove" }, + ["bs"] = { name = "BufferLineSort" }, + ["bsi"] = { name = "BufferLineSortById" }, + '' else "" }