mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-23 09:18:38 +02:00
plugins/languages: normalize plugin defaults
This commit is contained in:
parent
a208c7181c
commit
6f408f2bd0
12 changed files with 255 additions and 210 deletions
|
@ -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|`).
|
||||
|
|
|
@ -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`.
|
||||
'';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue