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; with lib;
{ {
enabled = enabled =
helpers.defaultNullOpts.mkNullable (with types; either bool (listOf str)) helpers.defaultNullOpts.mkNullableWithRaw
''["bibtex" "context" "context.tex" "html" "latex" "markdown" "org" "restructuredtext" "rsweave"]'' (with helpers.nixvimTypes; either bool (listOf (maybeRaw str)))
[
"bibtex"
"context"
"context.tex"
"html"
"latex"
"markdown"
"org"
"restructuredtext"
"rsweave"
]
'' ''
Controls whether the extension is enabled. Controls whether the extension is enabled.
Allows disabling LanguageTool on specific workspaces or for specific code language modes Allows disabling LanguageTool on specific workspaces or for specific code language modes
@ -91,161 +102,169 @@ with lib;
- "zh-CN": Chinese - "zh-CN": Chinese
''; '';
dictionary = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf str)) "{}" '' dictionary =
Lists of additional words that should not be counted as spelling errors. helpers.defaultNullOpts.mkAttrsOf (with helpers.nixvimTypes; listOf (maybeRaw str)) { }
This setting is language-specific, so use an attrs of the format ''
```nix Lists of additional words that should not be counted as spelling errors.
{ This setting is language-specific, so use an attrs of the format
"<LANGUAGE1>" = [ ```nix
"<WORD1>" {
"<WORD2>" "<LANGUAGE1>" = [
... "<WORD1>"
]; "<WORD2>"
"<LANGUAGE2>" = [ ...
"<WORD1>" ];
"<WORD2>" "<LANGUAGE2>" = [
]; "<WORD1>"
... "<WORD2>"
}; ];
``` ...
where <LANGUAGE> denotes the language code in `settings.language`. };
```
where <LANGUAGE> denotes the language code in `settings.language`.
This setting is a multi-scope setting. See the documentation for details. This setting is a multi-scope setting. See the documentation for details.
This setting supports external files. See the documentation for details. This setting supports external files. See the documentation for details.
By default, no additional spelling errors will be ignored. By default, no additional spelling errors will be ignored.
Example: Example:
```nix ```nix
{ {
"en-US" = [ "en-US" = [
"adaptivity" "adaptivity"
"precomputed" "precomputed"
"subproblem" "subproblem"
]; ];
"de-DE" = [ "de-DE" = [
"B-Splines" "B-Splines"
":/path/to/externalFile.txt" ":/path/to/externalFile.txt"
]; ];
} }
``` ```
''; '';
disabledRules = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf str)) "{}" '' disabledRules =
Lists of rules that should be disabled (if enabled by default by LanguageTool). helpers.defaultNullOpts.mkAttrsOf (with helpers.nixvimTypes; listOf (maybeRaw str)) { }
This setting is language-specific, so use an attrs of the format ''
```nix 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
"<LANGUAGE1>" = [ ```nix
"<WORD1>" {
"<WORD2>" "<LANGUAGE1>" = [
... "<WORD1>"
]; "<WORD2>"
"<LANGUAGE2>" = [ ...
"<WORD1>" ];
"<WORD2>" "<LANGUAGE2>" = [
]; "<WORD1>"
... "<WORD2>"
}; ];
``` ...
where `<LANGUAGE>` denotes the language code in `settings.language` and `<RULE>` the ID of };
the LanguageTool rule. ```
where `<LANGUAGE>` denotes the language code in `settings.language` and `<RULE>` the ID of
the LanguageTool rule.
This setting is a multi-scope setting. See the documentation for details. This setting is a multi-scope setting. See the documentation for details.
This setting supports external files. See the documentation for details. This setting supports external files. See the documentation for details.
By default, no additional rules will be disabled. By default, no additional rules will be disabled.
Example: Example:
```nix ```nix
{ {
"en-US" = [ "en-US" = [
"EN_QUOTES" "EN_QUOTES"
"UPPERCASE_SENTENCE_START" "UPPERCASE_SENTENCE_START"
":/path/to/externalFile.txt" ":/path/to/externalFile.txt"
]; ];
} }
``` ```
''; '';
enabledRules = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf str)) "{}" '' enabledRules =
Lists of rules that should be enabled (if disabled by default by LanguageTool). helpers.defaultNullOpts.mkAttrsOf (with helpers.nixvimTypes; listOf (maybeRaw str)) { }
This setting is language-specific, so use an attrs of the format ''
```nix 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
"<LANGUAGE1>" = [ ```nix
"<WORD1>" {
"<WORD2>" "<LANGUAGE1>" = [
... "<WORD1>"
]; "<WORD2>"
"<LANGUAGE2>" = [ ...
"<WORD1>" ];
"<WORD2>" "<LANGUAGE2>" = [
]; "<WORD1>"
... "<WORD2>"
}; ];
``` ...
where `<LANGUAGE>` denotes the language code in `settings.language` and `<RULE>` the ID of };
the LanguageTool rule. ```
where `<LANGUAGE>` denotes the language code in `settings.language` and `<RULE>` the ID of
the LanguageTool rule.
This setting is a multi-scope setting. See the documentation for details. This setting is a multi-scope setting. See the documentation for details.
This setting supports external files. See the documentation for details. This setting supports external files. See the documentation for details.
By default, no additional rules will be enabled. By default, no additional rules will be enabled.
Example: Example:
```nix ```nix
{ {
"en-GB" = [ "en-GB" = [
"PASSIVE_VOICE" "PASSIVE_VOICE"
"OXFORD_SPELLING_NOUNS" "OXFORD_SPELLING_NOUNS"
":/path/to/externalFile.txt" ":/path/to/externalFile.txt"
]; ];
} }
``` ```
''; '';
hiddenFalsePositives = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf str)) "{}" '' hiddenFalsePositives =
Lists of false-positive diagnostics to hide (by hiding all diagnostics of a specific rule helpers.defaultNullOpts.mkAttrsOf (with helpers.nixvimTypes; listOf (maybeRaw str)) { }
within a specific sentence). ''
This setting is language-specific, so use an attrs of the format Lists of false-positive diagnostics to hide (by hiding all diagnostics of a specific rule
```nix within a specific sentence).
{ This setting is language-specific, so use an attrs of the format
"<LANGUAGE1>" = [ ```nix
"<JSON1>" {
"<JSON2>" "<LANGUAGE1>" = [
... "<JSON1>"
]; "<JSON2>"
"<LANGUAGE2>" = [ ...
"<JSON1>" ];
"<JSON2>" "<LANGUAGE2>" = [
]; "<JSON1>"
... "<JSON2>"
}; ];
``` ...
where `<LANGUAGE>` denotes the language code in `settings.language` and `<JSON>` is a JSON };
string containing information about the rule and sentence. ```
where `<LANGUAGE>` denotes the language code in `settings.language` and `<JSON>` is a JSON
string containing information about the rule and sentence.
Although it is possible to manually edit this setting, the intended way is the Although it is possible to manually edit this setting, the intended way is the
`Hide false positive` quick fix. `Hide false positive` quick fix.
The JSON string currently has the form `{"rule": "<RULE>", "sentence": "<SENTENCE>"}`, where The JSON string currently has the form `{"rule": "<RULE>", "sentence": "<SENTENCE>"}`, where
`<RULE>` is the ID of the LanguageTool rule and `<SENTENCE>` is a Java-compatible regular `<RULE>` is the ID of the LanguageTool rule and `<SENTENCE>` is a Java-compatible regular
expression. expression.
All occurrences of the given rule are hidden in sentences (as determined by the LanguageTool All occurrences of the given rule are hidden in sentences (as determined by the LanguageTool
tokenizer) that match the regular expression. tokenizer) that match the regular expression.
See the documentation for details. See the documentation for details.
This setting is a multi-scope setting. See the documentation for details. This setting is a multi-scope setting. See the documentation for details.
This setting supports external files. See the documentation for details. This setting supports external files. See the documentation for details.
If this list is very large, performance may suffer. If this list is very large, performance may suffer.
Example: Example:
```nix ```nix
{ {
"en-US" = [ ":/path/to/externalFile.txt" ]; "en-US" = [ ":/path/to/externalFile.txt" ];
} }
``` ```
''; '';
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. 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 This setting is an attrs with the field names as keys (not restricted to classical BibTEX
@ -264,7 +283,7 @@ with lib;
''; '';
latex = { 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 List of LATEX commands to be handled by the LATEX parser, listed together with empty arguments
(e.g., `"ref{}"`, `"\documentclass[]{}"`). (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. 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 This setting is an attrs with the environment names as keys and corresponding actions as
@ -307,7 +326,7 @@ with lib;
}; };
markdown = { 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. 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. This setting is an attrs with the node types as keys and corresponding actions as values.
@ -332,14 +351,12 @@ with lib;
}; };
configurationTarget = configurationTarget =
helpers.defaultNullOpts.mkNullable (with types; attrsOf str) helpers.defaultNullOpts.mkAttrsOf types.str
'' {
{ dictionary = "workspaceFolderExternalFile";
dictionary = "workspaceFolderExternalFile"; disabledRules = "workspaceFolderExternalFile";
disabledRules = "workspaceFolderExternalFile"; hiddenFalsePositives = "workspaceFolderExternalFile";
hiddenFalsePositives = "workspaceFolderExternalFile"; }
}
''
'' ''
Controls which `settings.json` or external setting file (see documentation) to update when Controls which `settings.json` or external setting file (see documentation) to update when
using one of the quick fixes. using one of the quick fixes.
@ -505,7 +522,7 @@ with lib;
Changes require restarting LTEX to take effect. 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 Initial size of the Java heap memory in megabytes (corresponds to Javas -Xms option, must be
a positive integer). a positive integer).
@ -514,7 +531,7 @@ with lib;
Changes require restarting LTEX to take effect. 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 Maximum size of the Java heap memory in megabytes (corresponds to Javas -Xmx option, must be
a positive integer). 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). 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), 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 = 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. Severity of the diagnostics corresponding to the grammar and spelling errors.