From 351803ace076a31eba456ab79101fa9b3aefc1f1 Mon Sep 17 00:00:00 2001 From: n3oney Date: Tue, 2 May 2023 23:28:40 +0200 Subject: [PATCH] feat: add trouble keybindings --- modules/lsp/trouble/config.nix | 21 +++++++++++++-------- modules/lsp/trouble/trouble.nix | 18 +++++++++++------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/modules/lsp/trouble/config.nix b/modules/lsp/trouble/config.nix index bb6536c..0f3aa11 100644 --- a/modules/lsp/trouble/config.nix +++ b/modules/lsp/trouble/config.nix @@ -6,18 +6,23 @@ with lib; with builtins; let cfg = config.vim.lsp; + + self = import ./trouble.nix {inherit lib;}; + + mappingDefinitions = self.options.vim.lsp.trouble.mappings; + mappings = addDescriptionsToMappings cfg.trouble.mappings mappingDefinitions; in { config = mkIf (cfg.enable && cfg.trouble.enable) { vim.startPlugins = ["trouble"]; - vim.maps.normal = { - "xx" = {action = "TroubleToggle";}; - "lwd" = {action = "TroubleToggle workspace_diagnostics";}; - "ld" = {action = "TroubleToggle document_diagnostics";}; - "lr" = {action = "TroubleToggle lsp_references";}; - "xq" = {action = "TroubleToggle quickfix";}; - "xl" = {action = "TroubleToggle loclist";}; - }; + vim.maps.normal = mkMerge [ + (mkSetBinding mappings.toggle "TroubleToggle") + (mkSetBinding mappings.workspaceDiagnostics "TroubleToggle workspace_diagnostics") + (mkSetBinding mappings.documentDiagnostics "TroubleToggle document_diagnostics") + (mkSetBinding mappings.lspReferences "TroubleToggle lsp_references") + (mkSetBinding mappings.quickfix "TroubleToggle quickfix") + (mkSetBinding mappings.locList "TroubleToggle loclist") + ]; vim.luaConfigRC.trouble = nvim.dag.entryAnywhere '' -- Enable trouble diagnostics viewer diff --git a/modules/lsp/trouble/trouble.nix b/modules/lsp/trouble/trouble.nix index 2a5c392..85bf3a3 100644 --- a/modules/lsp/trouble/trouble.nix +++ b/modules/lsp/trouble/trouble.nix @@ -1,13 +1,17 @@ -{ - config, - lib, - ... -}: -with lib; -with builtins; { +{lib, ...}: +with lib; { options.vim.lsp = { trouble = { enable = mkEnableOption "Enable trouble diagnostics viewer"; + + mappings = { + toggle = mkMappingOption "Toggle trouble [trouble]" "xx"; + workspaceDiagnostics = mkMappingOption "Workspace diagnostics [trouble]" "lwd"; + documentDiagnostics = mkMappingOption "Document diagnostics [trouble]" "ld"; + lspReferences = mkMappingOption "LSP References [trouble]" "lr"; + quickfix = mkMappingOption "QuickFix [trouble]" "xq"; + locList = mkMappingOption "LOCList [trouble]" "xl"; + }; }; }; }