plugins/trouble: fix regressions introduced #213 (#215)

This commit is contained in:
Gaétan Lepage 2023-03-12 18:50:09 +01:00 committed by GitHub
parent e89d919e4d
commit 7c6f71199b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 170 additions and 107 deletions

View file

@ -47,88 +47,91 @@ in
padding = helpers.defaultNullOpts.mkBool true "Add an extra new line on top of the list"; padding = helpers.defaultNullOpts.mkBool true "Add an extra new line on top of the list";
# key mappings for actions in the trouble list
# map to {} to remove a mapping, for example:
# close = {}
actionKeys = actionKeys =
mapAttrs helpers.mkCompositeOption
( ''
action: config: Key mappings for actions in the trouble list.
helpers.defaultNullOpts.mkNullable Map to `{}` to remove a mapping, for example:
(with types; either str (listOf str)) `close = {};`
config.default ''
config.description (mapAttrs
) (
{ action: config:
close = { helpers.defaultNullOpts.mkNullable
default = "q"; (with types; either str (listOf str))
description = "Close the list"; config.default
}; config.description
cancel = { )
default = "<esc>"; {
description = "Cancel the preview and get back to your last window / buffer / cursor"; close = {
}; default = "q";
refresh = { description = "Close the list";
default = "r"; };
description = "Manually refresh"; cancel = {
}; default = "<esc>";
jump = { description = "Cancel the preview and get back to your last window / buffer / cursor";
default = "[ \"<cr>\" \"<tab>\" ]"; };
description = "Jump to the diagnostic or open / close folds"; refresh = {
}; default = "r";
openSplit = { description = "Manually refresh";
default = "[ \"<c-x>\" ]"; };
description = "Open buffer in new split"; jump = {
}; default = "[ \"<cr>\" \"<tab>\" ]";
openVsplit = { description = "Jump to the diagnostic or open / close folds";
default = "[ \"<c-v>\" ]"; };
description = "Open buffer in new vsplit"; openSplit = {
}; default = "[ \"<c-x>\" ]";
openTab = { description = "Open buffer in new split";
default = "[ \"<c-t>\" ]"; };
description = "Open buffer in new tab"; openVsplit = {
}; default = "[ \"<c-v>\" ]";
jumpClose = { description = "Open buffer in new vsplit";
default = "[ \"o\" ]"; };
description = "Jump to the diagnostic and close the list"; openTab = {
}; default = "[ \"<c-t>\" ]";
toggleMode = { description = "Open buffer in new tab";
default = "m"; };
description = "toggle between 'workspace' and 'document' diagnostics mode"; jumpClose = {
}; default = "[ \"o\" ]";
togglePreview = { description = "Jump to the diagnostic and close the list";
default = "P"; };
description = "Toggle auto_preview"; toggleMode = {
}; default = "m";
hover = { description = "toggle between 'workspace' and 'document' diagnostics mode";
default = "K"; };
description = "Opens a small popup with the full multiline message"; togglePreview = {
}; default = "P";
preview = { description = "Toggle auto_preview";
default = "p"; };
description = "Preview the diagnostic location"; hover = {
}; default = "K";
closeFolds = { description = "Opens a small popup with the full multiline message";
default = "[ \"zM\" \"zm\" ]"; };
description = "Close all folds"; preview = {
}; default = "p";
openFolds = { description = "Preview the diagnostic location";
default = "[ \"zR\" \"zr\" ]"; };
description = "Open all folds"; closeFolds = {
}; default = "[ \"zM\" \"zm\" ]";
toggleFold = { description = "Close all folds";
default = "[ \"zA\" \"za\" ]"; };
description = "Toggle fold of current file"; openFolds = {
}; default = "[ \"zR\" \"zr\" ]";
previous = { description = "Open all folds";
default = "k"; };
description = "Previous item"; toggleFold = {
}; default = "[ \"zA\" \"za\" ]";
next = { description = "Toggle fold of current file";
default = "j"; };
description = "Next item"; previous = {
}; default = "k";
}; description = "Previous item";
};
next = {
default = "j";
description = "Next item";
};
});
indentLines = helpers.defaultNullOpts.mkBool true '' indentLines = helpers.defaultNullOpts.mkBool true ''
Add an indent guide below the fold icons. Add an indent guide below the fold icons.
@ -157,20 +160,22 @@ in
"[ \"lsp_definitions\" ]" "[ \"lsp_definitions\" ]"
"For the given modes, automatically jump if there is only a single result."; "For the given modes, automatically jump if there is only a single result.";
# icons / text used for a diagnostic
signs = signs =
mapAttrs helpers.mkCompositeOption "Incons/text used for the different diagnostics."
( (
diagnostic: default: mapAttrs
helpers.defaultNullOpts.mkStr default "Icon/text for ${diagnostic} diagnostics." (
) diagnostic: default:
{ helpers.defaultNullOpts.mkStr default "Icon/text for ${diagnostic} diagnostics."
error = ""; )
warning = ""; {
hint = ""; error = "";
information = ""; warning = "";
other = ""; hint = "";
}; information = "";
other = "";
}
);
useDiagnosticSigns = helpers.defaultNullOpts.mkBool false '' useDiagnosticSigns = helpers.defaultNullOpts.mkBool false ''
Enabling this will use the signs defined in your lsp client Enabling this will use the signs defined in your lsp client
@ -192,20 +197,22 @@ in
fold_open = cfg.foldOpen; fold_open = cfg.foldOpen;
fold_closed = cfg.foldClosed; fold_closed = cfg.foldClosed;
inherit (cfg) group padding; inherit (cfg) group padding;
action_keys = with cfg.actionKeys; { action_keys =
inherit close cancel refresh jump; helpers.ifNonNull' cfg.actionKeys
open_split = openSplit; (with cfg.actionKeys; {
open_vsplit = openVsplit; inherit close cancel refresh jump;
open_tab = openTab; open_split = openSplit;
jump_close = jumpClose; open_vsplit = openVsplit;
toggle_mode = toggleMode; open_tab = openTab;
toggle_preview = togglePreview; jump_close = jumpClose;
inherit hover preview; toggle_mode = toggleMode;
close_folds = closeFolds; toggle_preview = togglePreview;
open_folds = openFolds; inherit hover preview;
toggle_fold = toggleFold; close_folds = closeFolds;
inherit next; open_folds = openFolds;
}; toggle_fold = toggleFold;
inherit next;
});
indent_lines = cfg.indentLines; indent_lines = cfg.indentLines;
auto_open = cfg.autoOpen; auto_open = cfg.autoOpen;
auto_close = cfg.autoClose; auto_close = cfg.autoClose;

56
tests/plugins/trouble.nix Normal file
View file

@ -0,0 +1,56 @@
{
# Empty configuration
empty = {
plugins.trouble.enable = true;
};
# All the upstream default options of trouble
defaults = {
plugins.trouble = {
enable = true;
position = "bottom";
height = 10;
width = 50;
icons = true;
mode = "workspace_diagnostics";
foldOpen = "";
foldClosed = "";
group = true;
padding = true;
actionKeys = {
close = "q";
cancel = "<esc>";
refresh = "r";
jump = ["<cr>" "<tab>"];
openSplit = ["<c-x>"];
openVsplit = ["<c-v>"];
openTab = ["<c-t>"];
jumpClose = ["o"];
toggleMode = "m";
togglePreview = "P";
hover = "K";
preview = "p";
closeFolds = ["zM" "zm"];
openFolds = ["zR" "zr"];
toggleFold = ["zA" "za"];
previous = "k";
next = "j";
};
indentLines = true;
autoOpen = false;
autoClose = false;
autoPreview = true;
autoFold = false;
autoJump = ["lsp_definitions"];
signs = {
error = "";
warning = "";
hint = "";
information = "";
other = "";
};
useDiagnosticSigns = false;
};
};
}