From 56dd5f3f1174c53d3e151fd4288b21df40c0afa5 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Mon, 11 Nov 2024 01:06:09 +0100 Subject: [PATCH] lib/binds: update lzn bind functions --- lib/binds.nix | 8 ++-- modules/plugins/debugger/nvim-dap/config.nix | 2 +- modules/plugins/lsp/trouble/config.nix | 12 +++--- .../plugins/terminal/toggleterm/config.nix | 1 + modules/plugins/utility/telescope/config.nix | 38 +++++++++---------- 5 files changed, 31 insertions(+), 30 deletions(-) diff --git a/lib/binds.nix b/lib/binds.nix index 298cd30..22bca73 100644 --- a/lib/binds.nix +++ b/lib/binds.nix @@ -79,14 +79,14 @@ expr = true; }; - mkSetLznBinding = binding: action: { - inherit action; + mkSetLznBinding = mode: binding: action: { + inherit action mode; key = binding.value; desc = binding.description; }; - mkSetLuaLznBinding = binding: action: { - inherit action; + mkSetLuaLznBinding = mode: binding: action: { + inherit action mode; key = binding.value; lua = true; desc = binding.description; diff --git a/modules/plugins/debugger/nvim-dap/config.nix b/modules/plugins/debugger/nvim-dap/config.nix index 7e9e8f7..b99fb3d 100644 --- a/modules/plugins/debugger/nvim-dap/config.nix +++ b/modules/plugins/debugger/nvim-dap/config.nix @@ -60,7 +60,7 @@ in { inherit (cfg.ui) setupOpts; keys = [ - (mkSetLuaLznBinding mappings.toggleDapUI "function() require('dapui').toggle() end") + (mkSetLuaLznBinding "n" mappings.toggleDapUI "function() require('dapui').toggle() end") ]; }; diff --git a/modules/plugins/lsp/trouble/config.nix b/modules/plugins/lsp/trouble/config.nix index cae0c7a..9bbc71c 100644 --- a/modules/plugins/lsp/trouble/config.nix +++ b/modules/plugins/lsp/trouble/config.nix @@ -21,12 +21,12 @@ in { cmd = "Trouble"; keys = [ - (mkSetLznBinding mappings.toggle "TroubleToggle") - (mkSetLznBinding mappings.workspaceDiagnostics "TroubleToggle workspace_diagnostics") - (mkSetLznBinding mappings.documentDiagnostics "TroubleToggle document_diagnostics") - (mkSetLznBinding mappings.lspReferences "TroubleToggle lsp_references") - (mkSetLznBinding mappings.quickfix "TroubleToggle quickfix") - (mkSetLznBinding mappings.locList "TroubleToggle loclist") + (mkSetLznBinding "n" mappings.toggle "TroubleToggle") + (mkSetLznBinding "n" mappings.workspaceDiagnostics "TroubleToggle workspace_diagnostics") + (mkSetLznBinding "n" mappings.documentDiagnostics "TroubleToggle document_diagnostics") + (mkSetLznBinding "n" mappings.lspReferences "TroubleToggle lsp_references") + (mkSetLznBinding "n" mappings.quickfix "TroubleToggle quickfix") + (mkSetLznBinding "n" mappings.locList "TroubleToggle loclist") ]; }; diff --git a/modules/plugins/terminal/toggleterm/config.nix b/modules/plugins/terminal/toggleterm/config.nix index f0ebd72..d3a71fb 100644 --- a/modules/plugins/terminal/toggleterm/config.nix +++ b/modules/plugins/terminal/toggleterm/config.nix @@ -22,6 +22,7 @@ in { [(mkLznBinding ["n"] cfg.mappings.open "execute v:count . \"ToggleTerm\"" "Toggle terminal")] ++ optional cfg.lazygit.enable { key = cfg.lazygit.mappings.open; + mode = "n"; desc = lazygitMapDesc; }; diff --git a/modules/plugins/utility/telescope/config.nix b/modules/plugins/utility/telescope/config.nix index 6143627..d5881fa 100644 --- a/modules/plugins/utility/telescope/config.nix +++ b/modules/plugins/utility/telescope/config.nix @@ -34,36 +34,36 @@ in { keys = [ - (mkSetLznBinding mappings.findFiles " Telescope find_files") - (mkSetLznBinding mappings.liveGrep " Telescope live_grep") - (mkSetLznBinding mappings.buffers " Telescope buffers") - (mkSetLznBinding mappings.helpTags " Telescope help_tags") - (mkSetLznBinding mappings.open " Telescope") + (mkSetLznBinding "n" mappings.findFiles " Telescope find_files") + (mkSetLznBinding "n" mappings.liveGrep " Telescope live_grep") + (mkSetLznBinding "n" mappings.buffers " Telescope buffers") + (mkSetLznBinding "n" mappings.helpTags " Telescope help_tags") + (mkSetLznBinding "n" mappings.open " Telescope") - (mkSetLznBinding mappings.gitCommits " Telescope git_commits") - (mkSetLznBinding mappings.gitBufferCommits " Telescope git_bcommits") - (mkSetLznBinding mappings.gitBranches " Telescope git_branches") - (mkSetLznBinding mappings.gitStatus " Telescope git_status") - (mkSetLznBinding mappings.gitStash " Telescope git_stash") + (mkSetLznBinding "n" mappings.gitCommits " Telescope git_commits") + (mkSetLznBinding "n" mappings.gitBufferCommits " Telescope git_bcommits") + (mkSetLznBinding "n" mappings.gitBranches " Telescope git_branches") + (mkSetLznBinding "n" mappings.gitStatus " Telescope git_status") + (mkSetLznBinding "n" mappings.gitStash " Telescope git_stash") ] ++ (optionals config.vim.lsp.enable [ - (mkSetLznBinding mappings.lspDocumentSymbols " Telescope lsp_document_symbols") - (mkSetLznBinding mappings.lspWorkspaceSymbols " Telescope lsp_workspace_symbols") + (mkSetLznBinding "n" mappings.lspDocumentSymbols " Telescope lsp_document_symbols") + (mkSetLznBinding "n" mappings.lspWorkspaceSymbols " Telescope lsp_workspace_symbols") - (mkSetLznBinding mappings.lspReferences " Telescope lsp_references") - (mkSetLznBinding mappings.lspImplementations " Telescope lsp_implementations") - (mkSetLznBinding mappings.lspDefinitions " Telescope lsp_definitions") - (mkSetLznBinding mappings.lspTypeDefinitions " Telescope lsp_type_definitions") - (mkSetLznBinding mappings.diagnostics " Telescope diagnostics") + (mkSetLznBinding "n" mappings.lspReferences " Telescope lsp_references") + (mkSetLznBinding "n" mappings.lspImplementations " Telescope lsp_implementations") + (mkSetLznBinding "n" mappings.lspDefinitions " Telescope lsp_definitions") + (mkSetLznBinding "n" mappings.lspTypeDefinitions " Telescope lsp_type_definitions") + (mkSetLznBinding "n" mappings.diagnostics " Telescope diagnostics") ]) ++ ( optionals config.vim.treesitter.enable [ - (mkSetLznBinding mappings.treesitter " Telescope treesitter") + (mkSetLznBinding "n" mappings.treesitter " Telescope treesitter") ] ) ++ ( optionals config.vim.projects.project-nvim.enable [ - (mkSetLznBinding mappings.findProjects "") + (mkSetLznBinding "n" mappings.findProjects "") ] ); };