plugins/ui: normalize plugin defaults

This commit is contained in:
Matt Sturgeon 2024-06-11 16:54:41 +01:00
parent d7b0cf8014
commit b10a391bd0
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
8 changed files with 288 additions and 243 deletions

View file

@ -56,9 +56,12 @@ in
}; };
in in
mapAttrs mkIntegrationOptions { mapAttrs mkIntegrationOptions {
markdown = ''["markdown" "vimwiki"]''; markdown = [
neorg = ''["norg"]''; "markdown"
syslang = ''["syslang"]''; "vimwiki"
];
neorg = [ "norg" ];
syslang = [ "syslang" ];
}; };
maxWidth = helpers.mkNullOrOption types.ints.unsigned "Image maximum width."; maxWidth = helpers.mkNullOrOption types.ints.unsigned "Image maximum width.";
@ -78,7 +81,12 @@ in
''; '';
windowOverlapClearFtIgnore = windowOverlapClearFtIgnore =
helpers.defaultNullOpts.mkListOf types.str ''["cmp_menu" "cmp_docs" ""]'' helpers.defaultNullOpts.mkListOf types.str
[
"cmp_menu"
"cmp_docs"
""
]
'' ''
Toggles images when windows are overlapped. Toggles images when windows are overlapped.
''; '';
@ -92,7 +100,14 @@ in
''; '';
hijackFilePatterns = hijackFilePatterns =
helpers.defaultNullOpts.mkListOf types.str ''["*.png" "*.jpg" "*.jpeg" "*.gif" "*.webp"]'' helpers.defaultNullOpts.mkListOf types.str
[
"*.png"
"*.jpg"
"*.jpeg"
"*.gif"
"*.webp"
]
'' ''
Render image files as images when opened. Render image files as images when opened.
''; '';

View file

@ -16,19 +16,17 @@ helpers.neovim-plugin.mkNeovimPlugin config {
settingsOptions = { settingsOptions = {
mappings = mappings =
helpers.defaultNullOpts.mkListOf types.str helpers.defaultNullOpts.mkListOf types.str
'' [
[ "<C-u>"
"<C-u>" "<C-d>"
"<C-d>" "<C-b>"
"<C-b>" "<C-f>"
"<C-f>" "<C-y>"
"<C-y>" "<C-e>"
"<C-e>" "zt"
"zt" "zz"
"zz" "zb"
"zb" ]
]
''
'' ''
All the keys defined in this option will be mapped to their corresponding default All the keys defined in this option will be mapped to their corresponding default
scrolling animation. To no map any key pass an empty table: scrolling animation. To no map any key pass an empty table:

View file

@ -22,20 +22,43 @@ with lib;
cmdline = { cmdline = {
enabled = helpers.defaultNullOpts.mkBool true "enables Noice cmdline UI"; enabled = helpers.defaultNullOpts.mkBool true "enables Noice cmdline UI";
view = helpers.defaultNullOpts.mkStr "cmdline_popup" ""; view = helpers.defaultNullOpts.mkStr "cmdline_popup" "";
opts = helpers.defaultNullOpts.mkNullable types.anything "{}" ""; opts = helpers.defaultNullOpts.mkAttrsOf types.anything { } "";
format = format =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) helpers.defaultNullOpts.mkAttrsOf types.anything
'' {
{ cmdline = {
cmdline = {pattern = "^:"; icon = ""; lang = "vim";}; pattern = "^:";
search_down = {kind = "search"; pattern = "^/"; icon = " "; lang = "regex";}; icon = "";
search_up = {kind = "search"; pattern = "?%?"; icon = " "; lang = "regex";}; lang = "vim";
filter = {pattern = "^:%s*!"; icon = "$"; lang = "bash";}; };
lua = {pattern = "^:%s*lua%s+"; icon = ""; lang = "lua";}; search_down = {
help = {pattern = "^:%s*he?l?p?%s+"; icon = "";}; kind = "search";
input = {}; pattern = "^/";
} icon = " ";
'' lang = "regex";
};
search_up = {
kind = "search";
pattern = "?%?";
icon = " ";
lang = "regex";
};
filter = {
pattern = "^:%s*!";
icon = "$";
lang = "bash";
};
lua = {
pattern = "^:%s*lua%s+";
icon = "";
lang = "lua";
};
help = {
pattern = "^:%s*he?l?p?%s+";
icon = "";
};
input = { };
}
'' ''
conceal: (default=true) This will hide the text in the cmdline that matches the pattern. conceal: (default=true) This will hide the text in the cmdline that matches the pattern.
view: (default is cmdline view) view: (default is cmdline view)
@ -64,55 +87,80 @@ with lib;
"nui" "nui"
"cmp" "cmp"
] ""; ] "";
kindIcons = helpers.defaultNullOpts.mkNullable (types.either types.bool ( kindIcons = helpers.defaultNullOpts.mkNullable (
types.attrsOf types.anything with types; either bool (attrsOf anything)
)) "{}" "Icons for completion item kinds. set to `false` to disable icons"; ) { } "Icons for completion item kinds. set to `false` to disable icons";
}; };
redirect = helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) '' redirect = helpers.defaultNullOpts.mkAttrsOf types.anything {
{ view = "popup";
view = "popup"; filter = {
filter = {event = "msg_show";}; event = "msg_show";
} };
'' "default options for require('noice').redirect"; } "default options for require('noice').redirect";
commands = helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) '' commands = helpers.defaultNullOpts.mkAttrsOf types.anything {
{ history = {
history = { view = "split";
view = "split"; opts = {
opts = {enter = true; format = "details";}; enter = true;
filter = { format = "details";
any = [
{event = "notify";}
{error = true;}
{warning = true;}
{event = "msg_show"; kind = [""];}
{event = "lsp"; kind = "message";}
];
};
}; };
last = { filter = {
view = "popup"; any = [
opts = {enter = true; format = "details";}; { event = "notify"; }
filter = { { error = true; }
any = [ { warning = true; }
{event = "notify";} {
{error = true;} event = "msg_show";
{warning = true;} kind = [ "" ];
{event = "msg_show"; kind = [""];} }
{event = "lsp"; kind = "message";} {
]; event = "lsp";
}; kind = "message";
filter_opts = {count = 1;}; }
];
}; };
errors = { };
view = "popup"; last = {
opts = {enter = true; format = "details";}; view = "popup";
filter = {error = true;}; opts = {
filter_opts = {reverse = true;}; enter = true;
format = "details";
}; };
} filter = {
'' "You can add any custom commands that will be available with `:Noice command`"; any = [
{ event = "notify"; }
{ error = true; }
{ warning = true; }
{
event = "msg_show";
kind = [ "" ];
}
{
event = "lsp";
kind = "message";
}
];
};
filter_opts = {
count = 1;
};
};
errors = {
view = "popup";
opts = {
enter = true;
format = "details";
};
filter = {
error = true;
};
filter_opts = {
reverse = true;
};
};
} "You can add any custom commands that will be available with `:Noice command`";
notify = { notify = {
enabled = helpers.defaultNullOpts.mkBool true '' enabled = helpers.defaultNullOpts.mkBool true ''
@ -131,35 +179,27 @@ with lib;
progress = { progress = {
enabled = helpers.defaultNullOpts.mkBool true "enable LSP progress"; enabled = helpers.defaultNullOpts.mkBool true "enable LSP progress";
format = format = helpers.defaultNullOpts.mkNullable (with types; either str anything) "lsp_progress" ''
helpers.defaultNullOpts.mkNullable (types.either types.str types.anything) ''"lsp_progress"'' Lsp Progress is formatted using the builtins for lsp_progress
'' '';
Lsp Progress is formatted using the builtins for lsp_progress formatDone = helpers.defaultNullOpts.mkNullable (with types; either str anything) "lsp_progress" "";
'';
formatDone =
helpers.defaultNullOpts.mkNullable (types.either types.str types.anything) ''"lsp_progress"''
"";
throttle = helpers.defaultNullOpts.mkNum "1000 / 30" "frequency to update lsp progress message"; throttle = helpers.defaultNullOpts.mkNum (literalExpression "1000 / 30") "frequency to update lsp progress message";
view = helpers.defaultNullOpts.mkStr "mini" ""; view = helpers.defaultNullOpts.mkStr "mini" "";
}; };
override = helpers.defaultNullOpts.mkNullable (types.attrsOf types.bool) '' override = helpers.defaultNullOpts.mkAttrsOf types.bool {
{ "vim.lsp.util.convert_input_to_markdown_lines" = false;
"vim.lsp.util.convert_input_to_markdown_lines" = false; "vim.lsp.util.stylize_markdown" = false;
"vim.lsp.util.stylize_markdown" = false; "cmp.entry.get_documentation" = false;
"cmp.entry.get_documentation" = false; } "";
}
'' "";
hover = { hover = {
enabled = helpers.defaultNullOpts.mkBool true "enable hover UI"; enabled = helpers.defaultNullOpts.mkBool true "enable hover UI";
view = view = helpers.defaultNullOpts.mkStr (literalMD "use defaults from documentation") ""; # TODO: description
helpers.defaultNullOpts.mkNullable types.str null
"when null, use defaults from documentation";
opts = opts =
helpers.defaultNullOpts.mkNullable types.anything "{}" helpers.defaultNullOpts.mkAttrsOf types.anything { }
"merged with defaults from documentation"; "merged with defaults from documentation";
}; };
@ -175,11 +215,9 @@ with lib;
''; '';
}; };
view = view = helpers.defaultNullOpts.mkStr null "when null, use defaults from documentation";
helpers.defaultNullOpts.mkNullable types.str null
"when null, use defaults from documentation";
opts = opts =
helpers.defaultNullOpts.mkNullable types.anything "{}" helpers.defaultNullOpts.mkAttrsOf types.anything { }
"merged with defaults from documentation"; "merged with defaults from documentation";
}; };
@ -187,42 +225,39 @@ with lib;
enabled = helpers.defaultNullOpts.mkBool true "enable display of messages"; enabled = helpers.defaultNullOpts.mkBool true "enable display of messages";
view = helpers.defaultNullOpts.mkStr "notify" ""; view = helpers.defaultNullOpts.mkStr "notify" "";
opts = helpers.defaultNullOpts.mkNullable types.anything "{}" ""; opts = helpers.defaultNullOpts.mkAttrsOf types.anything { } "";
}; };
documentation = { documentation = {
view = helpers.defaultNullOpts.mkStr "hover" ""; view = helpers.defaultNullOpts.mkStr "hover" "";
opts = helpers.defaultNullOpts.mkNullable types.anything '' opts = helpers.defaultNullOpts.mkAttrsOf types.anything {
{ lang = "markdown";
lang = "markdown"; replace = true;
replace = true; render = "plain";
render = "plain"; format = [ "{message}" ];
format = ["{message}"]; win_options = {
win_options = { concealcursor = "n"; conceallevel = 3; }; concealcursor = "n";
} conceallevel = 3;
'' ""; };
} "";
}; };
}; };
markdown = { markdown = {
hover = helpers.defaultNullOpts.mkNullable (types.attrsOf types.str) '' hover = helpers.defaultNullOpts.mkAttrsOf types.str {
{ "|(%S-)|".__raw = "vim.cmd.help"; # vim help links
"|(%S-)|" = helpers.mkRaw "vim.cmd.help"; // vim help links "%[.-%]%((%S-)%)".__raw = "require('noice.util').open"; # markdown links
"%[.-%]%((%S-)%)" = helpers.mkRaw "require("noice.util").open"; // markdown links } "set handlers for hover (lua code)";
}
'' "set handlers for hover (lua code)";
highlights = helpers.defaultNullOpts.mkNullable (types.attrsOf types.str) '' highlights = helpers.defaultNullOpts.mkAttrsOf types.str {
{ "|%S-|" = "@text.reference";
"|%S-|" = "@text.reference"; "@%S+" = "@parameter";
"@%S+" = "@parameter"; "^%s*(Parameters:)" = "@text.title";
"^%s*(Parameters:)" = "@text.title"; "^%s*(Return:)" = "@text.title";
"^%s*(Return:)" = "@text.title"; "^%s*(See also:)" = "@text.title";
"^%s*(See also:)" = "@text.title"; "{%S-}" = "@parameter";
"{%S-}" = "@parameter"; } "set highlight groups";
}
'' "set highlight groups";
}; };
health = { health = {
@ -235,37 +270,40 @@ with lib;
You can disable this behaviour here You can disable this behaviour here
''; '';
excludedFiletypes = excludedFiletypes =
helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''[ "cmp_menu" "cmp_docs" "notify"]'' helpers.defaultNullOpts.mkListOf types.str
[
"cmp_menu"
"cmp_docs"
"notify"
]
'' ''
add any filetypes here, that shouldn't trigger smart move add any filetypes here, that shouldn't trigger smart move
''; '';
}; };
presets = presets =
helpers.defaultNullOpts.mkNullable (types.either types.bool types.anything) helpers.defaultNullOpts.mkNullable (with types; either bool anything)
'' {
{ bottom_search = false;
bottom_search = false; command_palette = false;
command_palette = false; long_message_to_split = false;
long_message_to_split = false; inc_rename = false;
inc_rename = false; lsp_doc_border = false;
lsp_doc_border = false; }
}
''
" "
you can enable a preset by setting it to true, or a table that will override the preset you can enable a preset by setting it to true, or a table that will override the preset
config. you can also add custom presets that you can enable/disable with enabled=true config. you can also add custom presets that you can enable/disable with enabled=true
"; ";
throttle = helpers.defaultNullOpts.mkNum "1000 / 30" '' throttle = helpers.defaultNullOpts.mkNum (literalExpression "1000 / 30") ''
how frequently does Noice need to check for ui updates? This has no effect when in blocking how frequently does Noice need to check for ui updates? This has no effect when in blocking
mode mode
''; '';
views = helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}" ""; views = helpers.defaultNullOpts.mkAttrsOf types.anything { } "";
routes = helpers.defaultNullOpts.mkNullable (types.listOf (types.attrsOf types.anything)) "[]" ""; routes = helpers.defaultNullOpts.mkListOf (types.attrsOf types.anything) [ ] "";
status = helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}" ""; status = helpers.defaultNullOpts.mkAttrsOf types.anything { } "";
format = helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}" ""; format = helpers.defaultNullOpts.mkAttrsOf types.anything { } "";
}; };
config = config =

View file

@ -21,7 +21,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
benefit from the performance optimizations in this plugin. benefit from the performance optimizations in this plugin.
''; '';
thousands = helpers.defaultNullOpts.mkNullable (with types; either str (enum [ false ])) "false" '' thousands = helpers.defaultNullOpts.mkNullable (with types; either str (enum [ false ])) false ''
`false` or line number thousands separator string ("." / ","). `false` or line number thousands separator string ("." / ",").
''; '';
@ -62,15 +62,15 @@ helpers.neovim-plugin.mkNeovimPlugin config {
) "Table of booleans or functions returning a boolean."; ) "Table of booleans or functions returning a boolean.";
sign = { sign = {
name = helpers.defaultNullOpts.mkListOf types.str "[]" '' name = helpers.defaultNullOpts.mkListOf types.str [ ] ''
List of lua patterns to match the sign name against. List of lua patterns to match the sign name against.
''; '';
text = helpers.defaultNullOpts.mkListOf types.str "[]" '' text = helpers.defaultNullOpts.mkListOf types.str [ ] ''
List of lua patterns to match the extmark sign text against. List of lua patterns to match the extmark sign text against.
''; '';
namespace = helpers.defaultNullOpts.mkListOf types.str "[]" '' namespace = helpers.defaultNullOpts.mkListOf types.str [ ] ''
List of lua patterns to match the extmark sign namespace against. List of lua patterns to match the extmark sign namespace against.
''; '';
@ -98,29 +98,27 @@ helpers.neovim-plugin.mkNeovimPlugin config {
}; };
}; };
in in
helpers.defaultNullOpts.mkListOf segmentType '' helpers.defaultNullOpts.mkListOf segmentType [
[ {
{ text = [ "%C" ];
text = ["%C"]; click = "v:lua.ScFa";
click = "v:lua.ScFa"; }
} {
{ text = [ "%s" ];
text = ["%s"]; click = "v:lua.ScSa";
click = "v:lua.ScSa"; }
} {
{ text = [
text = [ { __raw = "require('statuscol.builtin').lnumfunc"; }
{__raw = "require('statuscol.builtin').lnumfunc";} " "
" " ];
]; condition = [
condition = [ true
true { __raw = "require('statuscol.builtin').not_empty"; }
{__raw = "require('statuscol.builtin').not_empty";} ];
]; click = "v:lua.ScLa";
click = "v:lua.ScLa"; }
} ] "The statuscolumn can be customized through the `segments` option.";
]
'' "The statuscolumn can be customized through the `segments` option.";
clickmod = helpers.defaultNullOpts.mkStr "c" '' clickmod = helpers.defaultNullOpts.mkStr "c" ''
Modifier used for certain actions in the builtin clickhandlers: Modifier used for certain actions in the builtin clickhandlers:

View file

@ -16,44 +16,42 @@ helpers.neovim-plugin.mkNeovimPlugin config {
settingsOptions = { settingsOptions = {
groups = groups =
helpers.defaultNullOpts.mkListOf types.str helpers.defaultNullOpts.mkListOf types.str
'' [
[ "Normal"
"Normal" "NormalNC"
"NormalNC" "Comment"
"Comment" "Constant"
"Constant" "Special"
"Special" "Identifier"
"Identifier" "Statement"
"Statement" "PreProc"
"PreProc" "Type"
"Type" "Underlined"
"Underlined" "Todo"
"Todo" "String"
"String" "Function"
"Function" "Conditional"
"Conditional" "Repeat"
"Repeat" "Operator"
"Operator" "Structure"
"Structure" "LineNr"
"LineNr" "NonText"
"NonText" "SignColumn"
"SignColumn" "CursorLine"
"CursorLine" "CursorLineNr"
"CursorLineNr" "StatusLine"
"StatusLine" "StatusLineNC"
"StatusLineNC" "EndOfBuffer"
"EndOfBuffer" ]
]
''
'' ''
The list of transparent groups. The list of transparent groups.
''; '';
extra_groups = helpers.defaultNullOpts.mkListOf types.str "[]" '' extra_groups = helpers.defaultNullOpts.mkListOf types.str [ ] ''
Additional groups that should be cleared. Additional groups that should be cleared.
''; '';
exclude_groups = helpers.defaultNullOpts.mkListOf types.str "[]" '' exclude_groups = helpers.defaultNullOpts.mkListOf types.str [ ] ''
Groups that you don't want to clear. Groups that you don't want to clear.
''; '';
}; };

View file

@ -15,13 +15,19 @@ helpers.neovim-plugin.mkNeovimPlugin config {
settingsOptions = { settingsOptions = {
dimming = { dimming = {
alpha = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) "0.25" '' alpha = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.25 ''
Amount of dimming. Amount of dimming.
''; '';
color = helpers.defaultNullOpts.mkListOf types.str ''["Normal" "#ffffff"]'' '' color =
Highlight groups / colors to use. helpers.defaultNullOpts.mkListOf types.str
''; [
"Normal"
"#ffffff"
]
''
Highlight groups / colors to use.
'';
term_bg = helpers.defaultNullOpts.mkStr "#000000" '' term_bg = helpers.defaultNullOpts.mkStr "#000000" ''
If `guibg=NONE`, this will be used to calculate text color. If `guibg=NONE`, this will be used to calculate text color.
@ -42,16 +48,14 @@ helpers.neovim-plugin.mkNeovimPlugin config {
the types of nodes that should always be fully expanded. the types of nodes that should always be fully expanded.
''; '';
expand = helpers.defaultNullOpts.mkListOf types.str '' expand = helpers.defaultNullOpts.mkListOf types.str [
[ "function"
"function" "method"
"method" "table"
"table" "if_statement"
"if_statement" ] "For treesitter, we will always try to expand to the top-most ancestor with these types.";
]
'' "For treesitter, we will always try to expand to the top-most ancestor with these types.";
exclude = helpers.defaultNullOpts.mkListOf types.str "[]" '' exclude = helpers.defaultNullOpts.mkListOf types.str [ ] ''
Exclude these filetypes. Exclude these filetypes.
''; '';
}; };

View file

@ -18,7 +18,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
Enables or disables virt-column. Enables or disables virt-column.
''; '';
char = helpers.defaultNullOpts.mkNullable (with types; either str (listOf str)) ''[""]'' '' char = helpers.defaultNullOpts.mkNullable (with types; either str (listOf str)) [ "" ] ''
Character, or list of characters, that get used to display the virtual column. Character, or list of characters, that get used to display the virtual column.
Each character has to have a display width of 0 or 1. Each character has to have a display width of 0 or 1.
''; '';
@ -32,26 +32,22 @@ helpers.neovim-plugin.mkNeovimPlugin config {
''; '';
exclude = { exclude = {
filetypes = helpers.defaultNullOpts.mkListOf types.str '' filetypes = helpers.defaultNullOpts.mkListOf types.str [
[ "lspinfo"
"lspinfo" "packer"
"packer" "checkhealth"
"checkhealth" "help"
"help" "man"
"man" "TelescopePrompt"
"TelescopePrompt" "TelescopeResults"
"TelescopeResults" ] "List of `filetype`s for which virt-column is disabled.";
]
'' "List of `filetype`s for which virt-column is disabled.";
buftypes = helpers.defaultNullOpts.mkListOf types.str '' buftypes = helpers.defaultNullOpts.mkListOf types.str [
[ "nofile"
"nofile" "quickfix"
"quickfix" "terminal"
"terminal" "prompt"
"prompt" ] "List of `buftype`s for which virt-column is disabled.";
]
'' "List of `buftype`s for which virt-column is disabled.";
}; };
}; };

View file

@ -16,7 +16,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
# Optionally, explicitly declare some options. You don't have to. # Optionally, explicitly declare some options. You don't have to.
settingsOptions = { settingsOptions = {
window = { window = {
backdrop = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) "0.95" '' backdrop = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) 0.95 ''
Shade the backdrop of the Zen window. Shade the backdrop of the Zen window.
Set to 1 to keep the same as Normal. Set to 1 to keep the same as Normal.
''; '';
@ -31,7 +31,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
rawLua rawLua
] ]
) )
"120" 120
'' ''
Width of the zen window. Width of the zen window.
@ -51,7 +51,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
rawLua rawLua
] ]
) )
"1" 1
'' ''
Height of the Zen window. Height of the Zen window.
@ -61,7 +61,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
- a function that returns the width or the height - a function that returns the width or the height
''; '';
options = helpers.defaultNullOpts.mkAttrsOf types.anything "{}" '' options = helpers.defaultNullOpts.mkAttrsOf types.anything { } ''
By default, no options are changed for the Zen window. By default, no options are changed for the Zen window.
You can set any `vim.wo` option here. You can set any `vim.wo` option here.
@ -82,14 +82,12 @@ helpers.neovim-plugin.mkNeovimPlugin config {
plugins = { plugins = {
options = options =
helpers.defaultNullOpts.mkAttrsOf types.anything helpers.defaultNullOpts.mkAttrsOf types.anything
'' {
{ enabled = true;
enabled = true; ruler = false;
ruler = false; showcmd = false;
showcmd = false; laststatus = 0;
laststatus = 0; }
}
''
'' ''
Disable some global vim options (`vim.o`...). Disable some global vim options (`vim.o`...).
''; '';