{ config, lib, options, ... }: let inherit (lib.modules) mkIf; inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLznBinding pushDownDefault; cfg = config.vim.lsp; mappingDefinitions = options.vim.lsp.trouble.mappings; mappings = addDescriptionsToMappings cfg.trouble.mappings mappingDefinitions; in { config = mkIf (cfg.enable && cfg.trouble.enable) { vim = { lazy.plugins.trouble = { package = "trouble"; setupModule = "trouble"; inherit (cfg.trouble) setupOpts; cmd = "Trouble"; keys = [ (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") ]; }; binds.whichKey.register = pushDownDefault { "l" = "Trouble"; "x" = "+Trouble"; "lw" = "Workspace"; }; }; }; }