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 = { settingsOptions = {
keymaps = keymaps =
helpers.defaultNullOpts.mkAttrsOf (with helpers.nixvimTypes; attrsOf (either str rawLua)) helpers.defaultNullOpts.mkAttrsOf (with helpers.nixvimTypes; attrsOf (either str rawLua))
'' {
{ normal = {
normal = { plain_below = "g?p";
plain_below = "g?p"; plain_above = "g?P";
plain_above = "g?P"; variable_below = "g?v";
variable_below = "g?v"; variable_above = "g?V";
variable_above = "g?V"; variable_below_alwaysprompt.__raw = "nil";
variable_below_alwaysprompt.__raw = "nil"; variable_above_alwaysprompt.__raw = "nil";
variable_above_alwaysprompt.__raw = "nil"; textobj_below = "g?o";
textobj_below = "g?o"; textobj_above = "g?O";
textobj_above = "g?O"; toggle_comment_debug_prints.__raw = "nil";
toggle_comment_debug_prints.__raw = "nil"; delete_debug_prints.__raw = "nil";
delete_debug_prints.__raw = "nil"; };
}; visual = {
visual = { variable_below = "g?v";
variable_below = "g?v"; variable_above = "g?V";
variable_above = "g?V"; };
}; }
}
''
'' ''
By default, the plugin will create some keymappings for use 'out of the box'. 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 There are also some function invocations which are not mapped to any keymappings by
@ -83,12 +81,10 @@ helpers.neovim-plugin.mkNeovimPlugin config {
commands = commands =
helpers.defaultNullOpts.mkAttrsOf types.str helpers.defaultNullOpts.mkAttrsOf types.str
'' {
{ toggle_comment_debug_prints = "ToggleCommentDebugPrints";
toggle_comment_debug_prints = "ToggleCommentDebugPrints"; delete_debug_prints = "DeleteDebugPrints";
delete_debug_prints = "DeleteDebugPrints"; }
}
''
'' ''
By default, the plugin will create some commands for use 'out of the box'. 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, 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. Custom filetypes.
Your new file format will be merged in with those that already exist. 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 = { ft = {
default = helpers.defaultNullOpts.mkStr "lean" '' default = helpers.defaultNullOpts.mkStr "lean" ''
@ -66,7 +66,7 @@ in
Whether to enable expanding of unicode abbreviations. Whether to enable expanding of unicode abbreviations.
''; '';
extra = helpers.defaultNullOpts.mkNullable (with types; attrsOf str) "{}" '' extra = helpers.defaultNullOpts.mkAttrsOf types.str { } ''
Additional abbreviations. Additional abbreviations.
Example: Example:
@ -159,20 +159,18 @@ in
useWidgets = helpers.defaultNullOpts.mkBool true "Whether to use widgets."; useWidgets = helpers.defaultNullOpts.mkBool true "Whether to use widgets.";
mappings = helpers.defaultNullOpts.mkNullable (with types; attrsOf str) '' mappings = helpers.defaultNullOpts.mkAttrsOf types.str {
{ K = "click";
K = "click"; "<CR>" = "click";
"<CR>" = "click"; gd = "go_to_def";
gd = "go_to_def"; gD = "go_to_decl";
gD = "go_to_decl"; gy = "go_to_type";
gy = "go_to_type"; I = "mouse_enter";
I = "mouse_enter"; i = "mouse_leave";
i = "mouse_leave"; "<Esc>" = "clear_all";
"<Esc>" = "clear_all"; C = "clear_all";
C = "clear_all"; "<LocalLeader><Tab>" = "goto_last_window";
"<LocalLeader><Tab>" = "goto_last_window"; } "Mappings.";
}
'' "Mappings.";
}; };
progressBars = { progressBars = {
@ -222,7 +220,7 @@ in
on_attach = helpers.mkNullOrOption types.str "The LSP handler."; on_attach = helpers.mkNullOrOption types.str "The LSP handler.";
}; };
} }
) "{}" "Legacy Lean3 LSP settings."; ) { } "Legacy Lean3 LSP settings.";
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {

View file

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

View file

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

View file

@ -20,7 +20,7 @@ in
"fzf" "fzf"
] defaultFuzzyFinder "fuzzy finder to find documentation"; ] 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 ""; 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. 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. By default we use the auto mode of jupytext.
This will create a script with the correct extension for each language. 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. 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`). `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 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. existing dictionary, see [key_map.lua](https://github.com/codethread/qmk.nvim/blob/main/lua/qmk/config/key_map.lua) for details.
''; '';
symbols = symbols =
helpers.defaultNullOpts.mkAttrsOf types.str helpers.defaultNullOpts.mkAttrsOf types.str
'' {
{ space = " ";
space = " "; horz = "";
horz = ""; vert = "";
vert = ""; tl = "";
tl = ""; tm = "";
tm = ""; tr = "";
tr = ""; ml = "";
ml = ""; mm = "";
mm = ""; mr = "";
mr = ""; bl = "";
bl = ""; bm = "";
bm = ""; br = "";
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. 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"; maxLenAlign = helpers.defaultNullOpts.mkBool false "whether to align to the length of the longest line in the file";
maxLenAlignPadding = maxLenAlignPadding =
helpers.defaultNullOpts.mkInt 1 helpers.defaultNullOpts.mkUnsignedInt 1
"padding from the left if max_len_align is true"; "padding from the left if max_len_align is true";
rightAlign = helpers.defaultNullOpts.mkBool false "whether to align to the extreme right or not"; rightAlign = helpers.defaultNullOpts.mkBool false "whether to align to the extreme right or not";
@ -58,26 +58,44 @@ in
}; };
hoverActions = { 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 = maxWidth = helpers.defaultNullOpts.mkUnsignedInt null "Maximal width of the hover window. null means no max.";
helpers.defaultNullOpts.mkNullable types.int null
"Maximal width of the hover window. null means no max.";
maxHeight = maxHeight = helpers.defaultNullOpts.mkUnsignedInt null "Maximal height of the hover window. null means no max.";
helpers.defaultNullOpts.mkNullable types.int null
"Maximal height of the hover window. null means no max.";
autoFocus = helpers.defaultNullOpts.mkBool false "whether the hover action window gets automatically focused"; autoFocus = helpers.defaultNullOpts.mkBool false "whether the hover action window gets automatically focused";
}; };

View file

@ -137,15 +137,62 @@ with lib;
enabled_graphviz_backends = enabled_graphviz_backends =
helpers.defaultNullOpts.mkListOf types.str helpers.defaultNullOpts.mkListOf types.str
'' [
[ "bmp"
"bmp" "cgimage" "canon" "dot" "gv" "xdot" "xdot1.2" "xdot1.4" "eps" "exr" "fig" "gd" "cgimage"
"gd2" "gif" "gtk" "ico" "cmap" "ismap" "imap" "cmapx" "imap_np" "cmapx_np" "jpg" "canon"
"jpeg" "jpe" "jp2" "json" "json0" "dot_json" "xdot_json" "pdf" "pic" "pct" "pict" "dot"
"plain" "plain-ext" "png" "pov" "ps" "ps2" "psd" "sgi" "svg" "svgz" "tga" "tiff" "gv"
"tif" "tk" "vml" "vmlz" "wbmp" "webp" "xlib" "x11" "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. 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. 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. 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; package = helpers.mkPluginPackageOption "rainbow-delimiters.nvim" pkgs.vimPlugins.rainbow-delimiters-nvim;
strategy = strategy = helpers.defaultNullOpts.mkAttrsOf' {
helpers.defaultNullOpts.mkNullable type = types.enum [
( "global"
with types; "local"
attrsOf ( "noop"
either helpers.nixvimTypes.rawLua (enum [ ];
"global" pluginDefault = {
"local" default = "global";
"noop" };
]) description = ''
) Attrs mapping Tree-sitter language names to strategies.
) See `|rb-delimiters-strategy|` for more information about strategies.
'' '';
{ example = literalMD ''
default = "global"; ```nix
} {
'' # Use global strategy by default
'' default = "global";
Attrs mapping Tree-sitter language names to strategies.
See `|rb-delimiters-strategy|` for more information about strategies.
Example: # Use local for HTML
```nix html = "local";
{
# Use global strategy by default
default = "global";
# Use local for HTML # Pick the strategy for LaTeX dynamically based on the buffer size
html = "local"; latex.__raw = '''
function()
# Pick the strategy for LaTeX dynamically based on the buffer size -- Disabled for very large files, global strategy for large files,
latex.__raw = \'\' -- local strategy otherwise
function() if vim.fn.line('$') > 10000 then
-- Disabled for very large files, global strategy for large files, return nil
-- local strategy otherwise elseif vim.fn.line('$') > 1000 then
if vim.fn.line('$') > 10000 then return require 'rainbow-delimiters'.strategy['global']
return nil end
elseif vim.fn.line('$') > 1000 then return require 'rainbow-delimiters'.strategy['local']
return require 'rainbow-delimiters'.strategy['global'] end
end ''';
return require 'rainbow-delimiters'.strategy['local'] }
end ```
\'\'; '';
} };
```
'';
query = query =
helpers.defaultNullOpts.mkNullable (with types; attrsOf str) helpers.defaultNullOpts.mkAttrsOf types.str
'' {
{ default = "rainbow-delimiters";
default = "rainbow-delimiters"; lua = "rainbow-blocks";
lua = "rainbow-blocks"; }
}
''
'' ''
Attrs mapping Tree-sitter language names to queries. Attrs mapping Tree-sitter language names to queries.
See `|rb-delimiters-query|` for more information about queries. See `|rb-delimiters-query|` for more information about queries.
''; '';
highlight = highlight =
helpers.defaultNullOpts.mkNullable (with types; listOf str) helpers.defaultNullOpts.mkListOf types.str
'' [
[ "RainbowDelimiterRed"
"RainbowDelimiterRed" "RainbowDelimiterYellow"
"RainbowDelimiterYellow" "RainbowDelimiterBlue"
"RainbowDelimiterBlue" "RainbowDelimiterOrange"
"RainbowDelimiterOrange" "RainbowDelimiterGreen"
"RainbowDelimiterGreen" "RainbowDelimiterViolet"
"RainbowDelimiterViolet" "RainbowDelimiterCyan"
"RainbowDelimiterCyan" ]
]
''
'' ''
List of names of the highlight groups to use for highlighting, for more information see List of names of the highlight groups to use for highlighting, for more information see
`|rb-delimiters-colors|`. `|rb-delimiters-colors|`.
@ -102,12 +91,7 @@ with lib;
log = { log = {
file = file =
helpers.defaultNullOpts.mkNullable (with types; either str helpers.nixvimTypes.rawLua) helpers.defaultNullOpts.mkStr { __raw = "vim.fn.stdpath('log') .. '/rainbow-delimiters.log'"; }
''
{
__raw = "vim.fn.stdpath('log') .. '/rainbow-delimiters.log'";
}
''
'' ''
Path to the log file, default is `rainbow-delimiters.log` in your standard log path Path to the log file, default is `rainbow-delimiters.log` in your standard log path
(see `|standard-path|`). (see `|standard-path|`).

View file

@ -9,35 +9,33 @@ with lib;
{ {
options.plugins.treesitter-textobjects = options.plugins.treesitter-textobjects =
let let
disable = helpers.defaultNullOpts.mkNullable (with types; listOf str) "[]" '' disable = helpers.defaultNullOpts.mkListOf types.str [ ] ''
List of languages to disable this module for. List of languages to disable this module for.
''; '';
mkKeymapsOption = mkKeymapsOption =
desc: desc:
helpers.defaultNullOpts.mkNullable ( helpers.defaultNullOpts.mkAttrsOf (
with types; with types;
attrsOf ( either str (submodule {
either str (submodule { options = {
options = { query = mkOption {
query = mkOption { type = str;
type = str; description = "";
description = ""; example = "@class.inner";
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.
'';
}; };
})
) queryGroup = helpers.mkNullOrOption str ''
) "{}" desc; 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 in
helpers.neovim-plugin.extraOptionsOptions helpers.neovim-plugin.extraOptionsOptions
// { // {
@ -65,22 +63,22 @@ with lib;
''; '';
selectionModes = selectionModes =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkAttrsOf
( (
with types; with types;
attrsOf (enum [ enum [
"v" "v"
"V" "V"
"<c-v>" "<c-v>"
]) ]
) )
"{}" { }
'' ''
Map of capture group to `v`(charwise), `V`(linewise), or `<c-v>`(blockwise), choose a Map of capture group to `v`(charwise), `V`(linewise), or `<c-v>`(blockwise), choose a
selection mode per capture, default is `v`(charwise). 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 `true` or `false`, when `true` textobjects are extended to include preceding or
succeeding whitespace. succeeding whitespace.
@ -177,7 +175,7 @@ with lib;
(when https://github.com/neovim/neovim/pull/12720 or its successor is merged). (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`. Options to pass to `vim.lsp.util.open_floating_preview`.
For example, `maximum_height`. For example, `maximum_height`.
''; '';

View file

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