mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-23 09:18:38 +02:00
plugins/trouble: switch to settingsOptions
This commit is contained in:
parent
9f7c78852f
commit
ab3a8a2840
2 changed files with 264 additions and 255 deletions
|
@ -4,224 +4,232 @@
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}:
|
||||||
cfg = config.plugins.trouble;
|
with lib;
|
||||||
in
|
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||||
with lib; {
|
name = "trouble";
|
||||||
options.plugins.trouble =
|
originalName = "trouble-nvim";
|
||||||
helpers.neovim-plugin.extraOptionsOptions
|
defaultPackage = pkgs.vimPlugins.trouble-nvim;
|
||||||
// {
|
|
||||||
enable = mkEnableOption "trouble.nvim";
|
|
||||||
|
|
||||||
package = helpers.mkPackageOption "trouble-nvim" pkgs.vimPlugins.trouble-nvim;
|
extraPlugins = with pkgs.vimPlugins; [
|
||||||
|
nvim-web-devicons
|
||||||
|
];
|
||||||
|
|
||||||
position = helpers.defaultNullOpts.mkEnum ["top" "left" "right" "bottom"] "bottom" ''
|
maintainers = [maintainers.loicreynier];
|
||||||
Position of the list
|
|
||||||
'';
|
|
||||||
|
|
||||||
height = helpers.defaultNullOpts.mkInt 10 ''
|
# TODO introduced 2024-03-15: remove 2024-05-15
|
||||||
Height of the trouble list when position is top or bottom
|
optionsRenamedToSettings = [
|
||||||
'';
|
"autoClose"
|
||||||
|
"autoFold"
|
||||||
|
"autoOpen"
|
||||||
|
"autoJump"
|
||||||
|
"autoPreview"
|
||||||
|
"foldClosed"
|
||||||
|
"foldOpen"
|
||||||
|
"group"
|
||||||
|
"height"
|
||||||
|
"icons"
|
||||||
|
"indentLines"
|
||||||
|
"mode"
|
||||||
|
"padding"
|
||||||
|
"position"
|
||||||
|
"width"
|
||||||
|
"useDiagnosticSigns"
|
||||||
|
|
||||||
width = helpers.defaultNullOpts.mkInt 50 "Width of the list when position is left or right";
|
["actionKeys" "cancel"]
|
||||||
|
["actionKeys" "close"]
|
||||||
|
["actionKeys" "closeFolds"]
|
||||||
|
["actionKeys" "hover"]
|
||||||
|
["actionKeys" "jump"]
|
||||||
|
["actionKeys" "jumpClose"]
|
||||||
|
["actionKeys" "next"]
|
||||||
|
["actionKeys" "openFolds"]
|
||||||
|
["actionKeys" "openSplit"]
|
||||||
|
["actionKeys" "openTab"]
|
||||||
|
["actionKeys" "openVsplit"]
|
||||||
|
["actionKeys" "previous"]
|
||||||
|
["actionKeys" "refresh"]
|
||||||
|
["actionKeys" "toggleFold"]
|
||||||
|
["actionKeys" "toggleMode"]
|
||||||
|
["actionKeys" "togglePreview"]
|
||||||
|
["signs" "error"]
|
||||||
|
["signs" "hint"]
|
||||||
|
["signs" "other"]
|
||||||
|
["signs" "warning"]
|
||||||
|
];
|
||||||
|
|
||||||
icons = helpers.defaultNullOpts.mkBool true "Use devicons for filenames";
|
settingsOptions = {
|
||||||
|
position = helpers.defaultNullOpts.mkEnum ["top" "left" "right" "bottom"] "bottom" ''
|
||||||
mode =
|
Position of the list.
|
||||||
helpers.defaultNullOpts.mkEnum
|
|
||||||
[
|
|
||||||
"workspace_diagnostics"
|
|
||||||
"document_diagnostics"
|
|
||||||
"quickfix"
|
|
||||||
"lsp_references"
|
|
||||||
"loclist"
|
|
||||||
]
|
|
||||||
"workspace_diagnostics"
|
|
||||||
"Use devicons for filenames";
|
|
||||||
|
|
||||||
foldOpen = helpers.defaultNullOpts.mkStr "" "Icon used for open folds";
|
|
||||||
|
|
||||||
foldClosed = helpers.defaultNullOpts.mkStr "" "Icon used for closed folds";
|
|
||||||
|
|
||||||
group = helpers.defaultNullOpts.mkBool true "Group results by file";
|
|
||||||
|
|
||||||
padding = helpers.defaultNullOpts.mkBool true "Add an extra new line on top of the list";
|
|
||||||
|
|
||||||
actionKeys =
|
|
||||||
mapAttrs
|
|
||||||
(
|
|
||||||
action: config:
|
|
||||||
helpers.defaultNullOpts.mkNullable
|
|
||||||
(with types; either str (listOf str))
|
|
||||||
config.default
|
|
||||||
config.description
|
|
||||||
)
|
|
||||||
{
|
|
||||||
close = {
|
|
||||||
default = "q";
|
|
||||||
description = "Close the list";
|
|
||||||
};
|
|
||||||
cancel = {
|
|
||||||
default = "<esc>";
|
|
||||||
description = "Cancel the preview and get back to your last window / buffer / cursor";
|
|
||||||
};
|
|
||||||
refresh = {
|
|
||||||
default = "r";
|
|
||||||
description = "Manually refresh";
|
|
||||||
};
|
|
||||||
jump = {
|
|
||||||
default = "[ \"<cr>\" \"<tab>\" ]";
|
|
||||||
description = "Jump to the diagnostic or open / close folds";
|
|
||||||
};
|
|
||||||
openSplit = {
|
|
||||||
default = "[ \"<c-x>\" ]";
|
|
||||||
description = "Open buffer in new split";
|
|
||||||
};
|
|
||||||
openVsplit = {
|
|
||||||
default = "[ \"<c-v>\" ]";
|
|
||||||
description = "Open buffer in new vsplit";
|
|
||||||
};
|
|
||||||
openTab = {
|
|
||||||
default = "[ \"<c-t>\" ]";
|
|
||||||
description = "Open buffer in new tab";
|
|
||||||
};
|
|
||||||
jumpClose = {
|
|
||||||
default = "[ \"o\" ]";
|
|
||||||
description = "Jump to the diagnostic and close the list";
|
|
||||||
};
|
|
||||||
toggleMode = {
|
|
||||||
default = "m";
|
|
||||||
description = "toggle between 'workspace' and 'document' diagnostics mode";
|
|
||||||
};
|
|
||||||
togglePreview = {
|
|
||||||
default = "P";
|
|
||||||
description = "Toggle auto_preview";
|
|
||||||
};
|
|
||||||
hover = {
|
|
||||||
default = "K";
|
|
||||||
description = "Opens a small popup with the full multiline message";
|
|
||||||
};
|
|
||||||
preview = {
|
|
||||||
default = "p";
|
|
||||||
description = "Preview the diagnostic location";
|
|
||||||
};
|
|
||||||
closeFolds = {
|
|
||||||
default = "[ \"zM\" \"zm\" ]";
|
|
||||||
description = "Close all folds";
|
|
||||||
};
|
|
||||||
openFolds = {
|
|
||||||
default = "[ \"zR\" \"zr\" ]";
|
|
||||||
description = "Open all folds";
|
|
||||||
};
|
|
||||||
toggleFold = {
|
|
||||||
default = "[ \"zA\" \"za\" ]";
|
|
||||||
description = "Toggle fold of current file";
|
|
||||||
};
|
|
||||||
previous = {
|
|
||||||
default = "k";
|
|
||||||
description = "Previous item";
|
|
||||||
};
|
|
||||||
next = {
|
|
||||||
default = "j";
|
|
||||||
description = "Next item";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
indentLines = helpers.defaultNullOpts.mkBool true ''
|
|
||||||
Add an indent guide below the fold icons.
|
|
||||||
'';
|
|
||||||
|
|
||||||
autoOpen = helpers.defaultNullOpts.mkBool false ''
|
|
||||||
Automatically open the list when you have diagnostics.
|
|
||||||
'';
|
|
||||||
|
|
||||||
autoClose = helpers.defaultNullOpts.mkBool false ''
|
|
||||||
Automatically close the list when you have no diagnostics.
|
|
||||||
'';
|
|
||||||
|
|
||||||
autoPreview = helpers.defaultNullOpts.mkBool true ''
|
|
||||||
Automatically preview the location of the diagnostic.
|
|
||||||
<esc> to close preview and go back to last window.
|
|
||||||
'';
|
|
||||||
|
|
||||||
autoFold = helpers.defaultNullOpts.mkBool false ''
|
|
||||||
Automatically fold a file trouble list at creation.
|
|
||||||
'';
|
|
||||||
|
|
||||||
autoJump =
|
|
||||||
helpers.defaultNullOpts.mkNullable
|
|
||||||
(types.listOf types.str)
|
|
||||||
"[ \"lsp_definitions\" ]"
|
|
||||||
"For the given modes, automatically jump if there is only a single result.";
|
|
||||||
|
|
||||||
signs =
|
|
||||||
mapAttrs
|
|
||||||
(
|
|
||||||
diagnostic: default:
|
|
||||||
helpers.defaultNullOpts.mkStr default "Icon/text for ${diagnostic} diagnostics."
|
|
||||||
)
|
|
||||||
{
|
|
||||||
error = "";
|
|
||||||
warning = "";
|
|
||||||
hint = "";
|
|
||||||
information = "";
|
|
||||||
other = "";
|
|
||||||
};
|
|
||||||
|
|
||||||
useDiagnosticSigns = helpers.defaultNullOpts.mkBool false ''
|
|
||||||
Enabling this will use the signs defined in your lsp client
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
|
||||||
extraConfigLua = let
|
|
||||||
options =
|
|
||||||
{
|
|
||||||
inherit
|
|
||||||
(cfg)
|
|
||||||
position
|
|
||||||
height
|
|
||||||
width
|
|
||||||
icons
|
|
||||||
mode
|
|
||||||
;
|
|
||||||
fold_open = cfg.foldOpen;
|
|
||||||
fold_closed = cfg.foldClosed;
|
|
||||||
inherit (cfg) group padding;
|
|
||||||
indent_lines = cfg.indentLines;
|
|
||||||
auto_open = cfg.autoOpen;
|
|
||||||
auto_close = cfg.autoClose;
|
|
||||||
auto_preview = cfg.autoPreview;
|
|
||||||
auto_fold = cfg.autoFold;
|
|
||||||
auto_jump = cfg.autoJump;
|
|
||||||
inherit (cfg) signs;
|
|
||||||
action_keys = with cfg.actionKeys; {
|
|
||||||
inherit close cancel refresh jump;
|
|
||||||
open_split = openSplit;
|
|
||||||
open_vsplit = openVsplit;
|
|
||||||
open_tab = openTab;
|
|
||||||
jump_close = jumpClose;
|
|
||||||
toggle_mode = toggleMode;
|
|
||||||
toggle_preview = togglePreview;
|
|
||||||
inherit
|
|
||||||
hover
|
|
||||||
preview
|
|
||||||
;
|
|
||||||
close_folds = closeFolds;
|
|
||||||
open_folds = openFolds;
|
|
||||||
toggle_fold = toggleFold;
|
|
||||||
inherit next;
|
|
||||||
};
|
|
||||||
use_diagnostic_signs = cfg.useDiagnosticSigns;
|
|
||||||
}
|
|
||||||
// cfg.extraOptions;
|
|
||||||
in ''
|
|
||||||
require('trouble').setup(${helpers.toLuaObject options})
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
extraPlugins = with pkgs.vimPlugins; [
|
height = helpers.defaultNullOpts.mkInt 10 ''
|
||||||
cfg.package
|
Height of the trouble list when position is top or bottom.
|
||||||
nvim-web-devicons
|
'';
|
||||||
];
|
|
||||||
|
width = helpers.defaultNullOpts.mkInt 50 ''
|
||||||
|
Width of the list when position is left or right.
|
||||||
|
'';
|
||||||
|
|
||||||
|
icons = helpers.defaultNullOpts.mkBool true "Use devicons for filenames";
|
||||||
|
|
||||||
|
mode =
|
||||||
|
helpers.defaultNullOpts.mkEnum
|
||||||
|
[
|
||||||
|
"workspace_diagnostics"
|
||||||
|
"document_diagnostics"
|
||||||
|
"quickfix"
|
||||||
|
"lsp_references"
|
||||||
|
"loclist"
|
||||||
|
]
|
||||||
|
"workspace_diagnostics"
|
||||||
|
"Mode for default list";
|
||||||
|
|
||||||
|
fold_open = helpers.defaultNullOpts.mkStr "" "Icon used for open folds";
|
||||||
|
|
||||||
|
fold_closed = helpers.defaultNullOpts.mkStr "" "Icon used for closed folds";
|
||||||
|
|
||||||
|
group = helpers.defaultNullOpts.mkBool true "Group results by file";
|
||||||
|
|
||||||
|
padding = helpers.defaultNullOpts.mkBool true "Add an extra new line on top of the list";
|
||||||
|
|
||||||
|
cycle_results = helpers.defaultNullOpts.mkBool true "Whether to cycle item list when reaching beginning or end of list";
|
||||||
|
|
||||||
|
action_keys =
|
||||||
|
mapAttrs
|
||||||
|
(
|
||||||
|
action: config:
|
||||||
|
helpers.defaultNullOpts.mkNullable
|
||||||
|
(with types; either str (listOf str))
|
||||||
|
config.default
|
||||||
|
config.description
|
||||||
|
)
|
||||||
|
{
|
||||||
|
close = {
|
||||||
|
default = "q";
|
||||||
|
description = "Close the list";
|
||||||
|
};
|
||||||
|
cancel = {
|
||||||
|
default = "<esc>";
|
||||||
|
description = "Cancel the preview and get back to your last window / buffer / cursor";
|
||||||
|
};
|
||||||
|
refresh = {
|
||||||
|
default = "r";
|
||||||
|
description = "Manually refresh";
|
||||||
|
};
|
||||||
|
jump = {
|
||||||
|
default = "[ \"<cr>\" \"<tab>\" ]";
|
||||||
|
description = "Jump to the diagnostic or open / close folds";
|
||||||
|
};
|
||||||
|
open_split = {
|
||||||
|
default = "[ \"<c-x>\" ]";
|
||||||
|
description = "Open buffer in new split";
|
||||||
|
};
|
||||||
|
open_vsplit = {
|
||||||
|
default = "[ \"<c-v>\" ]";
|
||||||
|
description = "Open buffer in new vsplit";
|
||||||
|
};
|
||||||
|
open_tab = {
|
||||||
|
default = "[ \"<c-t>\" ]";
|
||||||
|
description = "Open buffer in new tab";
|
||||||
|
};
|
||||||
|
jump_close = {
|
||||||
|
default = "[ \"o\" ]";
|
||||||
|
description = "Jump to the diagnostic and close the list";
|
||||||
|
};
|
||||||
|
toggle_mode = {
|
||||||
|
default = "m";
|
||||||
|
description = "toggle between 'workspace' and 'document' diagnostics mode";
|
||||||
|
};
|
||||||
|
toggle_preview = {
|
||||||
|
default = "P";
|
||||||
|
description = "Toggle auto_preview";
|
||||||
|
};
|
||||||
|
hover = {
|
||||||
|
default = "K";
|
||||||
|
description = "Opens a small popup with the full multiline message";
|
||||||
|
};
|
||||||
|
preview = {
|
||||||
|
default = "p";
|
||||||
|
description = "Preview the diagnostic location";
|
||||||
|
};
|
||||||
|
close_folds = {
|
||||||
|
default = "[ \"zM\" \"zm\" ]";
|
||||||
|
description = "Close all folds";
|
||||||
|
};
|
||||||
|
open_folds = {
|
||||||
|
default = "[ \"zR\" \"zr\" ]";
|
||||||
|
description = "Open all folds";
|
||||||
|
};
|
||||||
|
toggle_fold = {
|
||||||
|
default = "[ \"zA\" \"za\" ]";
|
||||||
|
description = "Toggle fold of current file";
|
||||||
|
};
|
||||||
|
previous = {
|
||||||
|
default = "k";
|
||||||
|
description = "Previous item";
|
||||||
|
};
|
||||||
|
next = {
|
||||||
|
default = "j";
|
||||||
|
description = "Next item";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
indent_lines = helpers.defaultNullOpts.mkBool true ''
|
||||||
|
Add an indent guide below the fold icons.
|
||||||
|
'';
|
||||||
|
|
||||||
|
win_config =
|
||||||
|
helpers.defaultNullOpts.mkAttrsOf types.anything
|
||||||
|
''
|
||||||
|
{
|
||||||
|
border = "single";
|
||||||
|
}
|
||||||
|
''
|
||||||
|
"Configuration for floating windows. See `|nvim_open_win()|`.";
|
||||||
|
|
||||||
|
auto_open = helpers.defaultNullOpts.mkBool false ''
|
||||||
|
Automatically open the list when you have diagnostics.
|
||||||
|
'';
|
||||||
|
|
||||||
|
auto_close = helpers.defaultNullOpts.mkBool false ''
|
||||||
|
Automatically close the list when you have no diagnostics.
|
||||||
|
'';
|
||||||
|
|
||||||
|
auto_preview = helpers.defaultNullOpts.mkBool true ''
|
||||||
|
Automatically preview the location of the diagnostic.
|
||||||
|
<esc> to close preview and go back to last window.
|
||||||
|
'';
|
||||||
|
|
||||||
|
auto_fold = helpers.defaultNullOpts.mkBool false ''
|
||||||
|
Automatically fold a file trouble list at creation.
|
||||||
|
'';
|
||||||
|
|
||||||
|
auto_jump = helpers.defaultNullOpts.mkListOf types.str ''["lsp_definitions"]'' ''
|
||||||
|
For the given modes, automatically jump if there is only a single result.
|
||||||
|
'';
|
||||||
|
|
||||||
|
include_declaration =
|
||||||
|
helpers.defaultNullOpts.mkListOf types.str
|
||||||
|
''["lsp_references" "lsp_implementations" "lsp_definitions"]''
|
||||||
|
"For the given modes, include the declaration of the current symbol in the results.";
|
||||||
|
|
||||||
|
signs =
|
||||||
|
mapAttrs
|
||||||
|
(
|
||||||
|
diagnostic: default:
|
||||||
|
helpers.defaultNullOpts.mkStr default "Icon/text for ${diagnostic} diagnostics."
|
||||||
|
)
|
||||||
|
{
|
||||||
|
error = "";
|
||||||
|
warning = "";
|
||||||
|
hint = "";
|
||||||
|
information = "";
|
||||||
|
other = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
use_diagnostic_signs = helpers.defaultNullOpts.mkBool false ''
|
||||||
|
Enabling this will use the signs defined in your lsp client
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
# Empty configuration
|
|
||||||
empty = {
|
empty = {
|
||||||
plugins.trouble.enable = true;
|
plugins.trouble.enable = true;
|
||||||
};
|
};
|
||||||
|
@ -13,53 +12,55 @@
|
||||||
plugins.trouble.enable = true;
|
plugins.trouble.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
# All the upstream default options of trouble
|
|
||||||
defaults = {
|
defaults = {
|
||||||
plugins.trouble = {
|
plugins.trouble = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
position = "bottom";
|
settings = {
|
||||||
height = 10;
|
position = "bottom";
|
||||||
width = 50;
|
height = 10;
|
||||||
icons = true;
|
width = 50;
|
||||||
mode = "workspace_diagnostics";
|
icons = true;
|
||||||
foldOpen = "";
|
mode = "workspace_diagnostics";
|
||||||
foldClosed = "";
|
fold_open = "";
|
||||||
group = true;
|
fold_closed = "";
|
||||||
padding = true;
|
group = true;
|
||||||
actionKeys = {
|
padding = true;
|
||||||
close = "q";
|
action_keys = {
|
||||||
cancel = "<esc>";
|
close = "q";
|
||||||
refresh = "r";
|
cancel = "<esc>";
|
||||||
jump = ["<cr>" "<tab>"];
|
refresh = "r";
|
||||||
openSplit = ["<c-x>"];
|
jump = ["<cr>" "<tab>"];
|
||||||
openVsplit = ["<c-v>"];
|
open_split = ["<c-x>"];
|
||||||
openTab = ["<c-t>"];
|
open_vsplit = ["<c-v>"];
|
||||||
jumpClose = ["o"];
|
open_tab = ["<c-t>"];
|
||||||
toggleMode = "m";
|
jump_close = ["o"];
|
||||||
togglePreview = "P";
|
toggle_mode = "m";
|
||||||
hover = "K";
|
toggle_preview = "P";
|
||||||
preview = "p";
|
hover = "K";
|
||||||
closeFolds = ["zM" "zm"];
|
preview = "p";
|
||||||
openFolds = ["zR" "zr"];
|
close_folds = ["zM" "zm"];
|
||||||
toggleFold = ["zA" "za"];
|
open_folds = ["zR" "zr"];
|
||||||
previous = "k";
|
toggle_fold = ["zA" "za"];
|
||||||
next = "j";
|
previous = "k";
|
||||||
|
next = "j";
|
||||||
|
};
|
||||||
|
indent_lines = true;
|
||||||
|
win_config = {border = "single";};
|
||||||
|
auto_open = false;
|
||||||
|
auto_close = false;
|
||||||
|
auto_preview = true;
|
||||||
|
auto_fold = false;
|
||||||
|
auto_jump = ["lsp_definitions"];
|
||||||
|
signs = {
|
||||||
|
error = "";
|
||||||
|
warning = "";
|
||||||
|
hint = "";
|
||||||
|
information = "";
|
||||||
|
other = "";
|
||||||
|
};
|
||||||
|
use_diagnostic_signs = false;
|
||||||
};
|
};
|
||||||
indentLines = true;
|
|
||||||
autoOpen = false;
|
|
||||||
autoClose = false;
|
|
||||||
autoPreview = true;
|
|
||||||
autoFold = false;
|
|
||||||
autoJump = ["lsp_definitions"];
|
|
||||||
signs = {
|
|
||||||
error = "";
|
|
||||||
warning = "";
|
|
||||||
hint = "";
|
|
||||||
information = "";
|
|
||||||
other = "";
|
|
||||||
};
|
|
||||||
useDiagnosticSigns = false;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue