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 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 = {
"<leader>xx" = {action = "<cmd>TroubleToggle<CR>";};
"<leader>lwd" = {action = "<cmd>TroubleToggle workspace_diagnostics<CR>";};
"<leader>ld" = {action = "<cmd>TroubleToggle document_diagnostics<CR>";};
"<leader>lr" = {action = "<cmd>TroubleToggle lsp_references<CR>";};
"<leader>xq" = {action = "<cmd>TroubleToggle quickfix<CR>";};
"<leader>xl" = {action = "<cmd>TroubleToggle loclist<CR>";};
};
vim.maps.normal = mkMerge [
(mkSetBinding mappings.toggle "<cmd>TroubleToggle<CR>")
(mkSetBinding mappings.workspaceDiagnostics "<cmd>TroubleToggle workspace_diagnostics<CR>")
(mkSetBinding mappings.documentDiagnostics "<cmd>TroubleToggle document_diagnostics<CR>")
(mkSetBinding mappings.lspReferences "<cmd>TroubleToggle lsp_references<CR>")
(mkSetBinding mappings.quickfix "<cmd>TroubleToggle quickfix<CR>")
(mkSetBinding mappings.locList "<cmd>TroubleToggle loclist<CR>")
];
vim.luaConfigRC.trouble = nvim.dag.entryAnywhere ''
-- Enable trouble diagnostics viewer

View file

@ -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]" "<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";
};
};
};
}