feat: add trouble keybindings

This commit is contained in:
n3oney 2023-05-02 23:28:40 +02:00
parent 46c602f74d
commit 351803ace0
No known key found for this signature in database
GPG key ID: C786693DE727850E
2 changed files with 24 additions and 15 deletions

View file

@ -6,18 +6,23 @@
with lib; with lib;
with builtins; let with builtins; let
cfg = config.vim.lsp; cfg = config.vim.lsp;
self = import ./trouble.nix {inherit lib;};
mappingDefinitions = self.options.vim.lsp.trouble.mappings;
mappings = addDescriptionsToMappings cfg.trouble.mappings mappingDefinitions;
in { in {
config = mkIf (cfg.enable && cfg.trouble.enable) { config = mkIf (cfg.enable && cfg.trouble.enable) {
vim.startPlugins = ["trouble"]; vim.startPlugins = ["trouble"];
vim.maps.normal = { vim.maps.normal = mkMerge [
"<leader>xx" = {action = "<cmd>TroubleToggle<CR>";}; (mkSetBinding mappings.toggle "<cmd>TroubleToggle<CR>")
"<leader>lwd" = {action = "<cmd>TroubleToggle workspace_diagnostics<CR>";}; (mkSetBinding mappings.workspaceDiagnostics "<cmd>TroubleToggle workspace_diagnostics<CR>")
"<leader>ld" = {action = "<cmd>TroubleToggle document_diagnostics<CR>";}; (mkSetBinding mappings.documentDiagnostics "<cmd>TroubleToggle document_diagnostics<CR>")
"<leader>lr" = {action = "<cmd>TroubleToggle lsp_references<CR>";}; (mkSetBinding mappings.lspReferences "<cmd>TroubleToggle lsp_references<CR>")
"<leader>xq" = {action = "<cmd>TroubleToggle quickfix<CR>";}; (mkSetBinding mappings.quickfix "<cmd>TroubleToggle quickfix<CR>")
"<leader>xl" = {action = "<cmd>TroubleToggle loclist<CR>";}; (mkSetBinding mappings.locList "<cmd>TroubleToggle loclist<CR>")
}; ];
vim.luaConfigRC.trouble = nvim.dag.entryAnywhere '' vim.luaConfigRC.trouble = nvim.dag.entryAnywhere ''
-- Enable trouble diagnostics viewer -- Enable trouble diagnostics viewer

View file

@ -1,13 +1,17 @@
{ {lib, ...}:
config, with lib; {
lib,
...
}:
with lib;
with builtins; {
options.vim.lsp = { options.vim.lsp = {
trouble = { trouble = {
enable = mkEnableOption "Enable trouble diagnostics viewer"; enable = mkEnableOption "Enable trouble diagnostics viewer";
mappings = {
toggle = mkMappingOption "Toggle trouble [trouble]" "<leader>xx";
workspaceDiagnostics = mkMappingOption "Workspace diagnostics [trouble]" "<leader>lwd";
documentDiagnostics = mkMappingOption "Document diagnostics [trouble]" "<leader>ld";
lspReferences = mkMappingOption "LSP References [trouble]" "<leader>lr";
quickfix = mkMappingOption "QuickFix [trouble]" "<leader>xq";
locList = mkMappingOption "LOCList [trouble]" "<leader>xl";
};
}; };
}; };
} }