plugins/lsp/ltex: refactoring of the settings options

This commit is contained in:
Gaetan Lepage 2024-04-30 14:51:26 +02:00 committed by Gaétan Lepage
parent 9a9d6c69d8
commit e58380adcd

View file

@ -2,8 +2,19 @@
with lib;
{
enabled =
helpers.defaultNullOpts.mkNullable (with types; either bool (listOf str))
''["bibtex" "context" "context.tex" "html" "latex" "markdown" "org" "restructuredtext" "rsweave"]''
helpers.defaultNullOpts.mkNullableWithRaw
(with helpers.nixvimTypes; either bool (listOf (maybeRaw str)))
[
"bibtex"
"context"
"context.tex"
"html"
"latex"
"markdown"
"org"
"restructuredtext"
"rsweave"
]
''
Controls whether the extension is enabled.
Allows disabling LanguageTool on specific workspaces or for specific code language modes
@ -91,7 +102,9 @@ with lib;
- "zh-CN": Chinese
'';
dictionary = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf str)) "{}" ''
dictionary =
helpers.defaultNullOpts.mkAttrsOf (with helpers.nixvimTypes; listOf (maybeRaw str)) { }
''
Lists of additional words that should not be counted as spelling errors.
This setting is language-specific, so use an attrs of the format
```nix
@ -130,7 +143,9 @@ with lib;
```
'';
disabledRules = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf str)) "{}" ''
disabledRules =
helpers.defaultNullOpts.mkAttrsOf (with helpers.nixvimTypes; listOf (maybeRaw str)) { }
''
Lists of rules that should be disabled (if enabled by default by LanguageTool).
This setting is language-specific, so use an attrs of the format
```nix
@ -166,7 +181,9 @@ with lib;
```
'';
enabledRules = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf str)) "{}" ''
enabledRules =
helpers.defaultNullOpts.mkAttrsOf (with helpers.nixvimTypes; listOf (maybeRaw str)) { }
''
Lists of rules that should be enabled (if disabled by default by LanguageTool).
This setting is language-specific, so use an attrs of the format
```nix
@ -202,7 +219,9 @@ with lib;
```
'';
hiddenFalsePositives = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf str)) "{}" ''
hiddenFalsePositives =
helpers.defaultNullOpts.mkAttrsOf (with helpers.nixvimTypes; listOf (maybeRaw str)) { }
''
Lists of false-positive diagnostics to hide (by hiding all diagnostics of a specific rule
within a specific sentence).
This setting is language-specific, so use an attrs of the format
@ -245,7 +264,7 @@ with lib;
```
'';
fields = helpers.defaultNullOpts.mkNullable (with types; attrsOf bool) "{}" ''
fields = helpers.defaultNullOpts.mkAttrsOf types.bool { } ''
List of BibTEX fields whose values are to be checked in BibTEX files.
This setting is an attrs with the field names as keys (not restricted to classical BibTEX
@ -264,7 +283,7 @@ with lib;
'';
latex = {
commands = helpers.defaultNullOpts.mkNullable (with types; attrsOf str) "{}" ''
commands = helpers.defaultNullOpts.mkAttrsOf types.str { } ''
List of LATEX commands to be handled by the LATEX parser, listed together with empty arguments
(e.g., `"ref{}"`, `"\documentclass[]{}"`).
@ -287,7 +306,7 @@ with lib;
```
'';
environments = helpers.defaultNullOpts.mkNullable (with types; attrsOf str) "{}" ''
environments = helpers.defaultNullOpts.mkAttrsOf types.str { } ''
List of names of LATEX environments to be handled by the LATEX parser.
This setting is an attrs with the environment names as keys and corresponding actions as
@ -307,7 +326,7 @@ with lib;
};
markdown = {
nodes = helpers.defaultNullOpts.mkNullable (with types; attrsOf str) "{}" ''
nodes = helpers.defaultNullOpts.mkAttrsOf types.str { } ''
List of Markdown node types to be handled by the Markdown parser.
This setting is an attrs with the node types as keys and corresponding actions as values.
@ -332,14 +351,12 @@ with lib;
};
configurationTarget =
helpers.defaultNullOpts.mkNullable (with types; attrsOf str)
''
helpers.defaultNullOpts.mkAttrsOf types.str
{
dictionary = "workspaceFolderExternalFile";
disabledRules = "workspaceFolderExternalFile";
hiddenFalsePositives = "workspaceFolderExternalFile";
}
''
''
Controls which `settings.json` or external setting file (see documentation) to update when
using one of the quick fixes.
@ -505,7 +522,7 @@ with lib;
Changes require restarting LTEX to take effect.
'';
initialHeapSize = helpers.defaultNullOpts.mkInt 64 ''
initialHeapSize = helpers.defaultNullOpts.mkUnsignedInt 64 ''
Initial size of the Java heap memory in megabytes (corresponds to Javas -Xms option, must be
a positive integer).
@ -514,7 +531,7 @@ with lib;
Changes require restarting LTEX to take effect.
'';
maximumHeapSize = helpers.defaultNullOpts.mkInt 512 ''
maximumHeapSize = helpers.defaultNullOpts.mkUnsignedInt 512 ''
Maximum size of the Java heap memory in megabytes (corresponds to Javas -Xmx option, must be
a positive integer).
@ -526,7 +543,7 @@ with lib;
'';
};
sentenceCacheSize = helpers.defaultNullOpts.mkInt 2000 ''
sentenceCacheSize = helpers.defaultNullOpts.mkUnsignedInt 2000 ''
Size of the LanguageTool ResultCache in sentences (must be a positive integer).
If only a small portion of the text changed (e.g., a single key press in the editor),
@ -554,7 +571,9 @@ with lib;
'';
diagnosticSeverity =
helpers.defaultNullOpts.mkNullable (with types; either str (attrsOf str)) "information"
helpers.defaultNullOpts.mkNullableWithRaw
(with helpers.nixvimTypes; either str (attrsOf (maybeRaw str)))
"information"
''
Severity of the diagnostics corresponding to the grammar and spelling errors.