mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-23 17:28:39 +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,26 +4,72 @@
|
||||||
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
|
||||||
|
];
|
||||||
|
|
||||||
|
maintainers = [maintainers.loicreynier];
|
||||||
|
|
||||||
|
# TODO introduced 2024-03-15: remove 2024-05-15
|
||||||
|
optionsRenamedToSettings = [
|
||||||
|
"autoClose"
|
||||||
|
"autoFold"
|
||||||
|
"autoOpen"
|
||||||
|
"autoJump"
|
||||||
|
"autoPreview"
|
||||||
|
"foldClosed"
|
||||||
|
"foldOpen"
|
||||||
|
"group"
|
||||||
|
"height"
|
||||||
|
"icons"
|
||||||
|
"indentLines"
|
||||||
|
"mode"
|
||||||
|
"padding"
|
||||||
|
"position"
|
||||||
|
"width"
|
||||||
|
"useDiagnosticSigns"
|
||||||
|
|
||||||
|
["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"]
|
||||||
|
];
|
||||||
|
|
||||||
|
settingsOptions = {
|
||||||
position = helpers.defaultNullOpts.mkEnum ["top" "left" "right" "bottom"] "bottom" ''
|
position = helpers.defaultNullOpts.mkEnum ["top" "left" "right" "bottom"] "bottom" ''
|
||||||
Position of the list
|
Position of the list.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
height = helpers.defaultNullOpts.mkInt 10 ''
|
height = helpers.defaultNullOpts.mkInt 10 ''
|
||||||
Height of the trouble list when position is top or bottom
|
Height of the trouble list when position is top or bottom.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
width = helpers.defaultNullOpts.mkInt 50 "Width of the list when position is left or right";
|
width = helpers.defaultNullOpts.mkInt 50 ''
|
||||||
|
Width of the list when position is left or right.
|
||||||
|
'';
|
||||||
|
|
||||||
icons = helpers.defaultNullOpts.mkBool true "Use devicons for filenames";
|
icons = helpers.defaultNullOpts.mkBool true "Use devicons for filenames";
|
||||||
|
|
||||||
|
@ -37,17 +83,19 @@ in
|
||||||
"loclist"
|
"loclist"
|
||||||
]
|
]
|
||||||
"workspace_diagnostics"
|
"workspace_diagnostics"
|
||||||
"Use devicons for filenames";
|
"Mode for default list";
|
||||||
|
|
||||||
foldOpen = helpers.defaultNullOpts.mkStr "" "Icon used for open folds";
|
fold_open = helpers.defaultNullOpts.mkStr "" "Icon used for open folds";
|
||||||
|
|
||||||
foldClosed = helpers.defaultNullOpts.mkStr "" "Icon used for closed folds";
|
fold_closed = helpers.defaultNullOpts.mkStr "" "Icon used for closed folds";
|
||||||
|
|
||||||
group = helpers.defaultNullOpts.mkBool true "Group results by file";
|
group = helpers.defaultNullOpts.mkBool true "Group results by file";
|
||||||
|
|
||||||
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";
|
||||||
|
|
||||||
actionKeys =
|
cycle_results = helpers.defaultNullOpts.mkBool true "Whether to cycle item list when reaching beginning or end of list";
|
||||||
|
|
||||||
|
action_keys =
|
||||||
mapAttrs
|
mapAttrs
|
||||||
(
|
(
|
||||||
action: config:
|
action: config:
|
||||||
|
@ -73,27 +121,27 @@ in
|
||||||
default = "[ \"<cr>\" \"<tab>\" ]";
|
default = "[ \"<cr>\" \"<tab>\" ]";
|
||||||
description = "Jump to the diagnostic or open / close folds";
|
description = "Jump to the diagnostic or open / close folds";
|
||||||
};
|
};
|
||||||
openSplit = {
|
open_split = {
|
||||||
default = "[ \"<c-x>\" ]";
|
default = "[ \"<c-x>\" ]";
|
||||||
description = "Open buffer in new split";
|
description = "Open buffer in new split";
|
||||||
};
|
};
|
||||||
openVsplit = {
|
open_vsplit = {
|
||||||
default = "[ \"<c-v>\" ]";
|
default = "[ \"<c-v>\" ]";
|
||||||
description = "Open buffer in new vsplit";
|
description = "Open buffer in new vsplit";
|
||||||
};
|
};
|
||||||
openTab = {
|
open_tab = {
|
||||||
default = "[ \"<c-t>\" ]";
|
default = "[ \"<c-t>\" ]";
|
||||||
description = "Open buffer in new tab";
|
description = "Open buffer in new tab";
|
||||||
};
|
};
|
||||||
jumpClose = {
|
jump_close = {
|
||||||
default = "[ \"o\" ]";
|
default = "[ \"o\" ]";
|
||||||
description = "Jump to the diagnostic and close the list";
|
description = "Jump to the diagnostic and close the list";
|
||||||
};
|
};
|
||||||
toggleMode = {
|
toggle_mode = {
|
||||||
default = "m";
|
default = "m";
|
||||||
description = "toggle between 'workspace' and 'document' diagnostics mode";
|
description = "toggle between 'workspace' and 'document' diagnostics mode";
|
||||||
};
|
};
|
||||||
togglePreview = {
|
toggle_preview = {
|
||||||
default = "P";
|
default = "P";
|
||||||
description = "Toggle auto_preview";
|
description = "Toggle auto_preview";
|
||||||
};
|
};
|
||||||
|
@ -105,15 +153,15 @@ in
|
||||||
default = "p";
|
default = "p";
|
||||||
description = "Preview the diagnostic location";
|
description = "Preview the diagnostic location";
|
||||||
};
|
};
|
||||||
closeFolds = {
|
close_folds = {
|
||||||
default = "[ \"zM\" \"zm\" ]";
|
default = "[ \"zM\" \"zm\" ]";
|
||||||
description = "Close all folds";
|
description = "Close all folds";
|
||||||
};
|
};
|
||||||
openFolds = {
|
open_folds = {
|
||||||
default = "[ \"zR\" \"zr\" ]";
|
default = "[ \"zR\" \"zr\" ]";
|
||||||
description = "Open all folds";
|
description = "Open all folds";
|
||||||
};
|
};
|
||||||
toggleFold = {
|
toggle_fold = {
|
||||||
default = "[ \"zA\" \"za\" ]";
|
default = "[ \"zA\" \"za\" ]";
|
||||||
description = "Toggle fold of current file";
|
description = "Toggle fold of current file";
|
||||||
};
|
};
|
||||||
|
@ -127,32 +175,44 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
indentLines = helpers.defaultNullOpts.mkBool true ''
|
indent_lines = helpers.defaultNullOpts.mkBool true ''
|
||||||
Add an indent guide below the fold icons.
|
Add an indent guide below the fold icons.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
autoOpen = helpers.defaultNullOpts.mkBool false ''
|
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.
|
Automatically open the list when you have diagnostics.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
autoClose = helpers.defaultNullOpts.mkBool false ''
|
auto_close = helpers.defaultNullOpts.mkBool false ''
|
||||||
Automatically close the list when you have no diagnostics.
|
Automatically close the list when you have no diagnostics.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
autoPreview = helpers.defaultNullOpts.mkBool true ''
|
auto_preview = helpers.defaultNullOpts.mkBool true ''
|
||||||
Automatically preview the location of the diagnostic.
|
Automatically preview the location of the diagnostic.
|
||||||
<esc> to close preview and go back to last window.
|
<esc> to close preview and go back to last window.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
autoFold = helpers.defaultNullOpts.mkBool false ''
|
auto_fold = helpers.defaultNullOpts.mkBool false ''
|
||||||
Automatically fold a file trouble list at creation.
|
Automatically fold a file trouble list at creation.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
autoJump =
|
auto_jump = helpers.defaultNullOpts.mkListOf types.str ''["lsp_definitions"]'' ''
|
||||||
helpers.defaultNullOpts.mkNullable
|
For the given modes, automatically jump if there is only a single result.
|
||||||
(types.listOf 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 =
|
signs =
|
||||||
mapAttrs
|
mapAttrs
|
||||||
|
@ -168,60 +228,8 @@ in
|
||||||
other = "";
|
other = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
useDiagnosticSigns = helpers.defaultNullOpts.mkBool false ''
|
use_diagnostic_signs = 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
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
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; [
|
|
||||||
cfg.package
|
|
||||||
nvim-web-devicons
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
# Empty configuration
|
|
||||||
empty = {
|
empty = {
|
||||||
plugins.trouble.enable = true;
|
plugins.trouble.enable = true;
|
||||||
};
|
};
|
||||||
|
@ -13,45 +12,46 @@
|
||||||
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;
|
||||||
|
|
||||||
|
settings = {
|
||||||
position = "bottom";
|
position = "bottom";
|
||||||
height = 10;
|
height = 10;
|
||||||
width = 50;
|
width = 50;
|
||||||
icons = true;
|
icons = true;
|
||||||
mode = "workspace_diagnostics";
|
mode = "workspace_diagnostics";
|
||||||
foldOpen = "";
|
fold_open = "";
|
||||||
foldClosed = "";
|
fold_closed = "";
|
||||||
group = true;
|
group = true;
|
||||||
padding = true;
|
padding = true;
|
||||||
actionKeys = {
|
action_keys = {
|
||||||
close = "q";
|
close = "q";
|
||||||
cancel = "<esc>";
|
cancel = "<esc>";
|
||||||
refresh = "r";
|
refresh = "r";
|
||||||
jump = ["<cr>" "<tab>"];
|
jump = ["<cr>" "<tab>"];
|
||||||
openSplit = ["<c-x>"];
|
open_split = ["<c-x>"];
|
||||||
openVsplit = ["<c-v>"];
|
open_vsplit = ["<c-v>"];
|
||||||
openTab = ["<c-t>"];
|
open_tab = ["<c-t>"];
|
||||||
jumpClose = ["o"];
|
jump_close = ["o"];
|
||||||
toggleMode = "m";
|
toggle_mode = "m";
|
||||||
togglePreview = "P";
|
toggle_preview = "P";
|
||||||
hover = "K";
|
hover = "K";
|
||||||
preview = "p";
|
preview = "p";
|
||||||
closeFolds = ["zM" "zm"];
|
close_folds = ["zM" "zm"];
|
||||||
openFolds = ["zR" "zr"];
|
open_folds = ["zR" "zr"];
|
||||||
toggleFold = ["zA" "za"];
|
toggle_fold = ["zA" "za"];
|
||||||
previous = "k";
|
previous = "k";
|
||||||
next = "j";
|
next = "j";
|
||||||
};
|
};
|
||||||
indentLines = true;
|
indent_lines = true;
|
||||||
autoOpen = false;
|
win_config = {border = "single";};
|
||||||
autoClose = false;
|
auto_open = false;
|
||||||
autoPreview = true;
|
auto_close = false;
|
||||||
autoFold = false;
|
auto_preview = true;
|
||||||
autoJump = ["lsp_definitions"];
|
auto_fold = false;
|
||||||
|
auto_jump = ["lsp_definitions"];
|
||||||
signs = {
|
signs = {
|
||||||
error = "";
|
error = "";
|
||||||
warning = "";
|
warning = "";
|
||||||
|
@ -59,7 +59,8 @@
|
||||||
information = "";
|
information = "";
|
||||||
other = "";
|
other = "";
|
||||||
};
|
};
|
||||||
useDiagnosticSigns = false;
|
use_diagnostic_signs = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue