plugins/languages: normalize plugin defaults

This commit is contained in:
Matt Sturgeon 2024-06-11 16:52:49 +01:00
parent a208c7181c
commit 6f408f2bd0
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
12 changed files with 255 additions and 210 deletions

View file

@ -47,26 +47,24 @@ helpers.neovim-plugin.mkNeovimPlugin config {
settingsOptions = {
keymaps =
helpers.defaultNullOpts.mkAttrsOf (with helpers.nixvimTypes; attrsOf (either str rawLua))
''
{
normal = {
plain_below = "g?p";
plain_above = "g?P";
variable_below = "g?v";
variable_above = "g?V";
variable_below_alwaysprompt.__raw = "nil";
variable_above_alwaysprompt.__raw = "nil";
textobj_below = "g?o";
textobj_above = "g?O";
toggle_comment_debug_prints.__raw = "nil";
delete_debug_prints.__raw = "nil";
};
visual = {
variable_below = "g?v";
variable_above = "g?V";
};
}
''
{
normal = {
plain_below = "g?p";
plain_above = "g?P";
variable_below = "g?v";
variable_above = "g?V";
variable_below_alwaysprompt.__raw = "nil";
variable_above_alwaysprompt.__raw = "nil";
textobj_below = "g?o";
textobj_above = "g?O";
toggle_comment_debug_prints.__raw = "nil";
delete_debug_prints.__raw = "nil";
};
visual = {
variable_below = "g?v";
variable_above = "g?V";
};
}
''
By default, the plugin will create some keymappings for use 'out of the box'.
There are also some function invocations which are not mapped to any keymappings by
@ -83,12 +81,10 @@ helpers.neovim-plugin.mkNeovimPlugin config {
commands =
helpers.defaultNullOpts.mkAttrsOf types.str
''
{
toggle_comment_debug_prints = "ToggleCommentDebugPrints";
delete_debug_prints = "DeleteDebugPrints";
}
''
{
toggle_comment_debug_prints = "ToggleCommentDebugPrints";
delete_debug_prints = "DeleteDebugPrints";
}
''
By default, the plugin will create some commands for use 'out of the box'.
There are also some function invocations which are not mapped to any commands by default,
@ -140,7 +136,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
};
})
)
"{}"
{ }
''
Custom filetypes.
Your new file format will be merged in with those that already exist.

View file

@ -44,7 +44,7 @@ in
'';
};
}
) "{}" "LSP settings.";
) { } "LSP settings.";
ft = {
default = helpers.defaultNullOpts.mkStr "lean" ''
@ -66,7 +66,7 @@ in
Whether to enable expanding of unicode abbreviations.
'';
extra = helpers.defaultNullOpts.mkNullable (with types; attrsOf str) "{}" ''
extra = helpers.defaultNullOpts.mkAttrsOf types.str { } ''
Additional abbreviations.
Example:
@ -159,20 +159,18 @@ in
useWidgets = helpers.defaultNullOpts.mkBool true "Whether to use widgets.";
mappings = helpers.defaultNullOpts.mkNullable (with types; attrsOf str) ''
{
K = "click";
"<CR>" = "click";
gd = "go_to_def";
gD = "go_to_decl";
gy = "go_to_type";
I = "mouse_enter";
i = "mouse_leave";
"<Esc>" = "clear_all";
C = "clear_all";
"<LocalLeader><Tab>" = "goto_last_window";
}
'' "Mappings.";
mappings = helpers.defaultNullOpts.mkAttrsOf types.str {
K = "click";
"<CR>" = "click";
gd = "go_to_def";
gD = "go_to_decl";
gy = "go_to_type";
I = "mouse_enter";
i = "mouse_leave";
"<Esc>" = "clear_all";
C = "clear_all";
"<LocalLeader><Tab>" = "goto_last_window";
} "Mappings.";
};
progressBars = {
@ -222,7 +220,7 @@ in
on_attach = helpers.mkNullOrOption types.str "The LSP handler.";
};
}
) "{}" "Legacy Lean3 LSP settings.";
) { } "Legacy Lean3 LSP settings.";
};
config = mkIf cfg.enable {

View file

@ -97,19 +97,19 @@ mkVimPlugin config {
freeformType = types.attrs;
options = {
mkit = helpers.defaultNullOpts.mkListOf types.str "[]" ''
mkit = helpers.defaultNullOpts.mkListOf types.str [ ] ''
`markdown-it` options for render.
'';
katex = helpers.defaultNullOpts.mkListOf types.str "[]" ''
katex = helpers.defaultNullOpts.mkListOf types.str [ ] ''
`katex` options for math.
'';
uml = helpers.defaultNullOpts.mkListOf types.str "[]" ''
uml = helpers.defaultNullOpts.mkListOf types.str [ ] ''
`markdown-it-plantuml` options.
'';
maid = helpers.defaultNullOpts.mkListOf types.str "[]" ''
maid = helpers.defaultNullOpts.mkListOf types.str [ ] ''
`mermaid` options.
'';
@ -135,11 +135,11 @@ mkVimPlugin config {
Hide yaml metadata.
'';
sequence_diagrams = helpers.defaultNullOpts.mkListOf types.str "[]" ''
sequence_diagrams = helpers.defaultNullOpts.mkListOf types.str [ ] ''
`js-sequence-diagrams` options.
'';
flowchart_diagrams = helpers.defaultNullOpts.mkListOf types.str "[]" ''
flowchart_diagrams = helpers.defaultNullOpts.mkListOf types.str [ ] ''
`flowcharts` diagrams options.
'';
@ -151,7 +151,7 @@ mkVimPlugin config {
Disable filename header for the preview page.
'';
toc = helpers.defaultNullOpts.mkListOf types.str "[]" ''
toc = helpers.defaultNullOpts.mkListOf types.str [ ] ''
Toc options.
'';
};
@ -182,20 +182,20 @@ mkVimPlugin config {
Use a custom location for images.
'';
filetypes = helpers.defaultNullOpts.mkListOf types.str ''["markdown"]'' ''
filetypes = helpers.defaultNullOpts.mkListOf types.str [ "markdown" ] ''
Recognized filetypes. These filetypes will have `MarkdownPreview...` commands.
'';
theme =
helpers.mkNullOrOption
(types.enum [
"dark"
"light"
])
''
Default theme (dark or light).
By default the theme is define according to the preferences of the system.
'';
theme = helpers.defaultNullOpts.mkEnum' {
values = [
"dark"
"light"
];
description = ''
Default theme (dark or light).
'';
pluginDefault = literalMD "chosen based on system preferences";
};
combine_preview = helpers.defaultNullOpts.mkBool false ''
Combine preview window.

View file

@ -62,8 +62,8 @@ in
};
rootDir =
helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua)
''{ __raw = "require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew'})"; }''
helpers.defaultNullOpts.mkStr
{ __raw = "require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew'})"; }
''
This is the default if not provided, you can remove it. Or adjust as needed.
One dedicated LSP server & client will be started per unique root_dir

View file

@ -20,7 +20,7 @@ in
"fzf"
] defaultFuzzyFinder "fuzzy finder to find documentation";
cheatsheetWindowBlend = helpers.defaultNullOpts.mkNullable (types.ints.between 0 100) "15" "";
cheatsheetWindowBlend = helpers.defaultNullOpts.mkNullable (types.ints.between 0 100) 15 "";
loadSnippets = helpers.defaultNullOpts.mkBool false "";

View file

@ -32,7 +32,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
Default filetype. Don't change unless you know what you are doing.
'';
custom_language_formatting = helpers.defaultNullOpts.mkAttrsOf types.anything "{}" ''
custom_language_formatting = helpers.defaultNullOpts.mkAttrsOf types.anything { } ''
By default we use the auto mode of jupytext.
This will create a script with the correct extension for each language.
However, this can be overridden in a per language basis if you want to.

View file

@ -74,29 +74,27 @@ helpers.neovim-plugin.mkNeovimPlugin config {
`variant=qmk`).
'';
keymap_overrides = helpers.defaultNullOpts.mkAttrsOf types.str "{}" ''
keymap_overrides = helpers.defaultNullOpts.mkAttrsOf types.str { } ''
A dictionary of key codes to text replacements, any provided value will be merged with the
existing dictionary, see [key_map.lua](https://github.com/codethread/qmk.nvim/blob/main/lua/qmk/config/key_map.lua) for details.
'';
symbols =
helpers.defaultNullOpts.mkAttrsOf types.str
''
{
space = " ";
horz = "";
vert = "";
tl = "";
tm = "";
tr = "";
ml = "";
mm = "";
mr = "";
bl = "";
bm = "";
br = "";
}
''
{
space = " ";
horz = "";
vert = "";
tl = "";
tm = "";
tr = "";
ml = "";
mm = "";
mr = "";
bl = "";
bm = "";
br = "";
}
''
A dictionary of symbols used for the preview comment border chars see [default.lua](https://github.com/codethread/qmk.nvim/blob/main/lua/qmk/config/default.lua) for details.
'';

View file

@ -47,7 +47,7 @@ in
maxLenAlign = helpers.defaultNullOpts.mkBool false "whether to align to the length of the longest line in the file";
maxLenAlignPadding =
helpers.defaultNullOpts.mkInt 1
helpers.defaultNullOpts.mkUnsignedInt 1
"padding from the left if max_len_align is true";
rightAlign = helpers.defaultNullOpts.mkBool false "whether to align to the extreme right or not";
@ -58,26 +58,44 @@ in
};
hoverActions = {
border = helpers.defaultNullOpts.mkBorder ''
border = helpers.defaultNullOpts.mkBorder [
[
[ "" "FloatBorder" ]
[ "" "FloatBorder" ]
[ "" "FloatBorder" ]
[ "" "FloatBorder" ]
[ "" "FloatBorder" ]
[ "" "FloatBorder" ]
[ "" "FloatBorder" ]
[ "" "FloatBorder" ]
""
"FloatBorder"
]
'' "rust-tools hover window" "";
[
""
"FloatBorder"
]
[
""
"FloatBorder"
]
[
""
"FloatBorder"
]
[
""
"FloatBorder"
]
[
""
"FloatBorder"
]
[
""
"FloatBorder"
]
[
""
"FloatBorder"
]
] "rust-tools hover window" "";
maxWidth =
helpers.defaultNullOpts.mkNullable types.int null
"Maximal width of the hover window. null means no max.";
maxWidth = helpers.defaultNullOpts.mkUnsignedInt null "Maximal width of the hover window. null means no max.";
maxHeight =
helpers.defaultNullOpts.mkNullable types.int null
"Maximal height of the hover window. null means no max.";
maxHeight = helpers.defaultNullOpts.mkUnsignedInt null "Maximal height of the hover window. null means no max.";
autoFocus = helpers.defaultNullOpts.mkBool false "whether the hover action window gets automatically focused";
};

View file

@ -137,15 +137,62 @@ with lib;
enabled_graphviz_backends =
helpers.defaultNullOpts.mkListOf types.str
''
[
"bmp" "cgimage" "canon" "dot" "gv" "xdot" "xdot1.2" "xdot1.4" "eps" "exr" "fig" "gd"
"gd2" "gif" "gtk" "ico" "cmap" "ismap" "imap" "cmapx" "imap_np" "cmapx_np" "jpg"
"jpeg" "jpe" "jp2" "json" "json0" "dot_json" "xdot_json" "pdf" "pic" "pct" "pict"
"plain" "plain-ext" "png" "pov" "ps" "ps2" "psd" "sgi" "svg" "svgz" "tga" "tiff"
"tif" "tk" "vml" "vmlz" "wbmp" "webp" "xlib" "x11"
]
''
[
"bmp"
"cgimage"
"canon"
"dot"
"gv"
"xdot"
"xdot1.2"
"xdot1.4"
"eps"
"exr"
"fig"
"gd"
"gd2"
"gif"
"gtk"
"ico"
"cmap"
"ismap"
"imap"
"cmapx"
"imap_np"
"cmapx_np"
"jpg"
"jpeg"
"jpe"
"jp2"
"json"
"json0"
"dot_json"
"xdot_json"
"pdf"
"pic"
"pct"
"pict"
"plain"
"plain-ext"
"png"
"pov"
"ps"
"ps2"
"psd"
"sgi"
"svg"
"svgz"
"tga"
"tiff"
"tif"
"tk"
"vml"
"vmlz"
"wbmp"
"webp"
"xlib"
"x11"
]
''
Override the enabled graphviz backends list, used for input validation and autocompletion.
'';
@ -235,7 +282,7 @@ with lib;
Disabling it may improve rust-analyzer's startup time.
'';
logfile = helpers.defaultNullOpts.mkStr ''{__raw = "vim.fn.tempname() .. '-rust-analyzer.log'";}'' ''
logfile = helpers.defaultNullOpts.mkStr { __raw = "vim.fn.tempname() .. '-rust-analyzer.log'"; } ''
The path to the rust-analyzer log file.
'';

View file

@ -12,79 +12,68 @@ with lib;
package = helpers.mkPluginPackageOption "rainbow-delimiters.nvim" pkgs.vimPlugins.rainbow-delimiters-nvim;
strategy =
helpers.defaultNullOpts.mkNullable
(
with types;
attrsOf (
either helpers.nixvimTypes.rawLua (enum [
"global"
"local"
"noop"
])
)
)
''
{
default = "global";
}
''
''
Attrs mapping Tree-sitter language names to strategies.
See `|rb-delimiters-strategy|` for more information about strategies.
strategy = helpers.defaultNullOpts.mkAttrsOf' {
type = types.enum [
"global"
"local"
"noop"
];
pluginDefault = {
default = "global";
};
description = ''
Attrs mapping Tree-sitter language names to strategies.
See `|rb-delimiters-strategy|` for more information about strategies.
'';
example = literalMD ''
```nix
{
# Use global strategy by default
default = "global";
Example:
```nix
{
# Use global strategy by default
default = "global";
# Use local for HTML
html = "local";
# Use local for HTML
html = "local";
# Pick the strategy for LaTeX dynamically based on the buffer size
latex.__raw = \'\'
function()
-- Disabled for very large files, global strategy for large files,
-- local strategy otherwise
if vim.fn.line('$') > 10000 then
return nil
elseif vim.fn.line('$') > 1000 then
return require 'rainbow-delimiters'.strategy['global']
end
return require 'rainbow-delimiters'.strategy['local']
end
\'\';
}
```
'';
# Pick the strategy for LaTeX dynamically based on the buffer size
latex.__raw = '''
function()
-- Disabled for very large files, global strategy for large files,
-- local strategy otherwise
if vim.fn.line('$') > 10000 then
return nil
elseif vim.fn.line('$') > 1000 then
return require 'rainbow-delimiters'.strategy['global']
end
return require 'rainbow-delimiters'.strategy['local']
end
''';
}
```
'';
};
query =
helpers.defaultNullOpts.mkNullable (with types; attrsOf str)
''
{
default = "rainbow-delimiters";
lua = "rainbow-blocks";
}
''
helpers.defaultNullOpts.mkAttrsOf types.str
{
default = "rainbow-delimiters";
lua = "rainbow-blocks";
}
''
Attrs mapping Tree-sitter language names to queries.
See `|rb-delimiters-query|` for more information about queries.
'';
highlight =
helpers.defaultNullOpts.mkNullable (with types; listOf str)
''
[
"RainbowDelimiterRed"
"RainbowDelimiterYellow"
"RainbowDelimiterBlue"
"RainbowDelimiterOrange"
"RainbowDelimiterGreen"
"RainbowDelimiterViolet"
"RainbowDelimiterCyan"
]
''
helpers.defaultNullOpts.mkListOf types.str
[
"RainbowDelimiterRed"
"RainbowDelimiterYellow"
"RainbowDelimiterBlue"
"RainbowDelimiterOrange"
"RainbowDelimiterGreen"
"RainbowDelimiterViolet"
"RainbowDelimiterCyan"
]
''
List of names of the highlight groups to use for highlighting, for more information see
`|rb-delimiters-colors|`.
@ -102,12 +91,7 @@ with lib;
log = {
file =
helpers.defaultNullOpts.mkNullable (with types; either str helpers.nixvimTypes.rawLua)
''
{
__raw = "vim.fn.stdpath('log') .. '/rainbow-delimiters.log'";
}
''
helpers.defaultNullOpts.mkStr { __raw = "vim.fn.stdpath('log') .. '/rainbow-delimiters.log'"; }
''
Path to the log file, default is `rainbow-delimiters.log` in your standard log path
(see `|standard-path|`).

View file

@ -9,35 +9,33 @@ with lib;
{
options.plugins.treesitter-textobjects =
let
disable = helpers.defaultNullOpts.mkNullable (with types; listOf str) "[]" ''
disable = helpers.defaultNullOpts.mkListOf types.str [ ] ''
List of languages to disable this module for.
'';
mkKeymapsOption =
desc:
helpers.defaultNullOpts.mkNullable (
helpers.defaultNullOpts.mkAttrsOf (
with types;
attrsOf (
either str (submodule {
options = {
query = mkOption {
type = str;
description = "";
example = "@class.inner";
};
queryGroup = helpers.mkNullOrOption str ''
You can also use captures from other query groups like `locals.scm`
'';
desc = helpers.mkNullOrOption str ''
You can optionally set descriptions to the mappings (used in the `desc`
parameter of `nvim_buf_set_keymap`) which plugins like _which-key_ display.
'';
either str (submodule {
options = {
query = mkOption {
type = str;
description = "";
example = "@class.inner";
};
})
)
) "{}" desc;
queryGroup = helpers.mkNullOrOption str ''
You can also use captures from other query groups like `locals.scm`
'';
desc = helpers.mkNullOrOption str ''
You can optionally set descriptions to the mappings (used in the `desc`
parameter of `nvim_buf_set_keymap`) which plugins like _which-key_ display.
'';
};
})
) { } desc;
in
helpers.neovim-plugin.extraOptionsOptions
// {
@ -65,22 +63,22 @@ with lib;
'';
selectionModes =
helpers.defaultNullOpts.mkNullable
helpers.defaultNullOpts.mkAttrsOf
(
with types;
attrsOf (enum [
enum [
"v"
"V"
"<c-v>"
])
]
)
"{}"
{ }
''
Map of capture group to `v`(charwise), `V`(linewise), or `<c-v>`(blockwise), choose a
selection mode per capture, default is `v`(charwise).
'';
includeSurroundingWhitespace = helpers.defaultNullOpts.mkStrLuaFnOr types.bool "`false`" ''
includeSurroundingWhitespace = helpers.defaultNullOpts.mkStrLuaFnOr types.bool false ''
`true` or `false`, when `true` textobjects are extended to include preceding or
succeeding whitespace.
@ -177,7 +175,7 @@ with lib;
(when https://github.com/neovim/neovim/pull/12720 or its successor is merged).
'';
floatingPreviewOpts = helpers.defaultNullOpts.mkNullable (with types; attrsOf anything) "{}" ''
floatingPreviewOpts = helpers.defaultNullOpts.mkAttrsOf types.anything { } ''
Options to pass to `vim.lsp.util.open_floating_preview`.
For example, `maximum_height`.
'';

View file

@ -141,9 +141,15 @@ in
enable = helpers.defaultNullOpts.mkBool false ''
Functions similarly to `nvim-ts-autotag`. This is disabled by default to avoid conflicts.
'';
filetypes = helpers.defaultNullOpts.mkListOf types.str ''["javascriptreact" "typescriptreact"]'' ''
Filetypes this should apply to.
'';
filetypes =
helpers.defaultNullOpts.mkListOf types.str
[
"javascriptreact"
"typescriptreact"
]
''
Filetypes this should apply to.
'';
};
};
};