plugins/lsp: modernize implem of language-servers

This commit is contained in:
Gaetan Lepage 2024-12-14 21:09:46 +01:00 committed by nix-infra-bot
parent 57464f22bb
commit e6018ac195
12 changed files with 618 additions and 598 deletions

View file

@ -1,18 +1,18 @@
{
lib,
helpers,
config,
...
}:
with lib;
let
cfg = config.plugins.lsp.servers.ccls;
inherit (lib.nixvim) defaultNullOpts;
inherit (lib) types;
in
{
# Options: https://github.com/MaskRay/ccls/wiki/Customization#initialization-options
options.plugins.lsp.servers.ccls.initOptions = {
cache = {
directory = helpers.defaultNullOpts.mkStr ".ccls-cache" ''
directory = defaultNullOpts.mkStr ".ccls-cache" ''
If your project is `/a/b`, cache directories will be created at `/a/b/.ccls-cache/@a@b/`
(files under the project root) `/a/b/.ccls-cache/@@a@b/` (files outside the project root,
e.g. /usr/include/stdio.h).
@ -36,7 +36,7 @@ in
Example: `"/tmp/ccls-cache"`
'';
format = helpers.defaultNullOpts.mkStr "binary" ''
format = defaultNullOpts.mkStr "binary" ''
Specify the format of the cached index files.
Binary is a compact binary serialization format.
@ -45,7 +45,7 @@ in
'';
retainInMemory =
helpers.defaultNullOpts.mkEnum
defaultNullOpts.mkEnum
[
0
1
@ -69,13 +69,13 @@ in
};
clang = {
extraArgs = helpers.defaultNullOpts.mkListOf types.str [ ] ''
extraArgs = defaultNullOpts.mkListOf types.str [ ] ''
Additional arguments for `compile_commands.json` entries.
Example: `["-frounding-math"]`
'';
excludeArgs = helpers.defaultNullOpts.mkListOf types.str [ ] ''
excludeArgs = defaultNullOpts.mkListOf types.str [ ] ''
Excluded arguments for `compile_commands.json` entries.
If your compiler is not Clang and it supports arguments which Clang doesn't understand, then
@ -84,7 +84,7 @@ in
Example: `["-frounding-math"]`
'';
pathMappings = helpers.defaultNullOpts.mkListOf types.str [ ] ''
pathMappings = defaultNullOpts.mkListOf types.str [ ] ''
A list of `src>dest` path conversions used to remap the paths of files in the project.
This can be used to move a project to a new location without re-indexing.
@ -104,7 +104,7 @@ in
`/tmp/remote` paths any more.
'';
resourceDir = helpers.defaultNullOpts.mkStr "" ''
resourceDir = defaultNullOpts.mkStr "" ''
The clang resource directory (something like `.../lib/clang/9.0.0`) is hard-coded into ccls
at compile time.
You should be able to find `<resourceDir>/include/stddef.h`.
@ -115,7 +115,7 @@ in
};
client = {
snippetSupport = helpers.defaultNullOpts.mkBool true ''
snippetSupport = defaultNullOpts.mkBool true ''
`client.snippetSupport` and `completion.placeholder` (default: true) decide the completion
style.
@ -130,7 +130,7 @@ in
};
completion = {
placeholder = helpers.defaultNullOpts.mkBool false ''
placeholder = defaultNullOpts.mkBool false ''
`client.snippetSupport` and `completion.placeholder` (default: true) decide the completion
style.
@ -143,7 +143,7 @@ in
forced to `false`.
'';
detailedLabel = helpers.defaultNullOpts.mkBool true ''
detailedLabel = defaultNullOpts.mkBool true ''
When this option is enabled, `label` and `detailed` are re-purposed:
- `label`: detailed function signature, e.g. `foo(int a, int b) -> bool`
@ -151,7 +151,7 @@ in
context is `S`.
'';
filterAndSort = helpers.defaultNullOpts.mkBool true ''
filterAndSort = defaultNullOpts.mkBool true ''
`ccls` filters and sorts completions to try to be nicer to clients that can't handle big
numbers of completion candidates.
This behaviour can be disabled by specifying `false` for the option.
@ -160,7 +160,7 @@ in
'';
};
compilationDatabaseDirectory = helpers.defaultNullOpts.mkStr "" ''
compilationDatabaseDirectory = defaultNullOpts.mkStr "" ''
If not empty, look for `compile_commands.json` in it, otherwise the file is retrieved in the
project root.
@ -171,12 +171,12 @@ in
'';
diagnostics = {
onOpen = helpers.defaultNullOpts.mkInt 0 ''
onOpen = defaultNullOpts.mkInt 0 ''
Time (in milliseconds) to wait before computing diagnostics for `textDocument/didOpen`.
How long to wait before diagnostics are emitted when a document is opened.
'';
onChange = helpers.defaultNullOpts.mkInt 1000 ''
onChange = defaultNullOpts.mkInt 1000 ''
Time (in milliseconds) to wait before computing diagnostics for `textDocument/didChange`.
After receiving a `textDocument/didChange`, wait up to this long before reporting
diagnostics.
@ -186,21 +186,21 @@ in
If `1000` makes you feel slow, consider setting this to `1`.
'';
onSave = helpers.defaultNullOpts.mkInt 0 ''
onSave = defaultNullOpts.mkInt 0 ''
Time (in milliseconds) to wait before computing diagnostics for `textDocument/didSave`.
How long to wait before diagnostics are emitted after a document is saved.
'';
};
index = {
threads = helpers.defaultNullOpts.mkInt 0 ''
threads = defaultNullOpts.mkInt 0 ''
How many threads to start when indexing a project.
`0` means use `std::thread::hardware_concurrency()` (the number of cores the system has).
If you want to reduce peak CPU and memory usage, set it to a small integer.
'';
comments =
helpers.defaultNullOpts.mkEnum
defaultNullOpts.mkEnum
[
0
1
@ -218,7 +218,7 @@ in
'';
multiVersion =
helpers.defaultNullOpts.mkEnumFirstDefault
defaultNullOpts.mkEnumFirstDefault
[
0
1
@ -238,7 +238,7 @@ in
Also consider using `index.multiVersionBlacklist` to exclude system headers.
'';
multiVersionBlacklist = helpers.defaultNullOpts.mkListOf types.str [ ] ''
multiVersionBlacklist = defaultNullOpts.mkListOf types.str [ ] ''
A list of regular expressions matching files that should not be indexed via multi-version
if `index.multiVersion` is set to `1`.
@ -248,7 +248,7 @@ in
Example: `["^/usr/include"]`
'';
initialBlacklist = helpers.defaultNullOpts.mkListOf types.str [ ] ''
initialBlacklist = defaultNullOpts.mkListOf types.str [ ] ''
A list of regular expressions matching files that should not be indexed when the `ccls`
server starts up, but will still be indexed if a client opens them.
If there are areas of the project that you have no interest in indexing you can use this to
@ -265,7 +265,7 @@ in
Example: `["."]` (matches all files)
'';
onChange = helpers.defaultNullOpts.mkBool false ''
onChange = defaultNullOpts.mkBool false ''
If `false`, a file is re-indexed when saved, updating the global index incrementally.
If set to `true`, a document is re-indexed for every (unsaved) change.
@ -275,7 +275,7 @@ in
'';
trackDependency =
helpers.defaultNullOpts.mkEnum
defaultNullOpts.mkEnum
[
0
1
@ -297,5 +297,7 @@ in
};
};
config = mkIf cfg.enable { plugins.lsp.servers.ccls.extraOptions.init_options = cfg.initOptions; };
config = lib.mkIf cfg.enable {
plugins.lsp.servers.ccls.extraOptions.init_options = cfg.initOptions;
};
}

View file

@ -1,32 +1,35 @@
{ lib, helpers }:
with lib;
{ lib, ... }:
let
inherit (lib.nixvim) mkNullOrOption;
inherit (lib) types;
in
{
analysisExcludedFolders = helpers.mkNullOrOption (with types; listOf str) ''
analysisExcludedFolders = mkNullOrOption (with types; listOf str) ''
An array of paths (absolute or relative to each workspace folder) that should be excluded from
analysis.
'';
enableSdkFormatter = helpers.mkNullOrOption types.bool ''
enableSdkFormatter = mkNullOrOption types.bool ''
When set to false, prevents registration (or unregisters) the SDK formatter.
When set to true or not supplied, will register/reregister the SDK formatter
'';
lineLength = helpers.mkNullOrOption types.ints.unsigned ''
lineLength = mkNullOrOption types.ints.unsigned ''
The number of characters the formatter should wrap code at.
If unspecified, code will be wrapped at 80 characters.
'';
completeFunctionCalls = helpers.mkNullOrOption types.bool ''
completeFunctionCalls = mkNullOrOption types.bool ''
When set to true, completes functions/methods with their required parameters.
'';
showTodos = helpers.mkNullOrOption types.bool ''
showTodos = mkNullOrOption types.bool ''
Whether to generate diagnostics for TODO comments.
If unspecified, diagnostics will not be generated.
'';
renameFilesWithClasses =
helpers.mkNullOrOption
mkNullOrOption
(types.enum [
"always"
"prompt"
@ -41,18 +44,18 @@ with lib;
included in the resulting `WorkspaceEdit` and must be handled by the client.
'';
enableSnippets = helpers.mkNullOrOption types.bool ''
enableSnippets = mkNullOrOption types.bool ''
Whether to include code snippets (such as class, stful, switch) in code completion.
When unspecified, snippets will be included.
'';
updateImportsOnRename = helpers.mkNullOrOption types.bool ''
updateImportsOnRename = mkNullOrOption types.bool ''
Whether to update imports and other directives when files are renamed.
When unspecified, imports will be updated if the client supports `willRenameFiles` requests.
'';
documentation =
helpers.mkNullOrOption
mkNullOrOption
(types.enum [
"none"
"summary"
@ -64,7 +67,7 @@ with lib;
If not set, defaults to `"full"`.
'';
includeDependenciesInWorkspaceSymbols = helpers.mkNullOrOption types.bool ''
includeDependenciesInWorkspaceSymbols = mkNullOrOption types.bool ''
Whether to include symbols from dependencies and Dart/Flutter SDKs in Workspace Symbol results.
If not set, defaults to true.
'';

View file

@ -4,24 +4,24 @@
pkgs,
...
}:
with lib;
let
cfg = config.plugins.lsp.servers.hls;
inherit (lib) types;
in
{
options.plugins.lsp.servers.hls = {
installGhc = mkOption {
installGhc = lib.mkOption {
type = with types; nullOr bool;
default = null;
example = true;
description = "Whether to install `ghc`.";
};
ghcPackage = mkPackageOption pkgs "ghc" { };
ghcPackage = lib.mkPackageOption pkgs "ghc" { };
};
config = mkIf cfg.enable {
warnings = optional (cfg.installGhc == null) ''
config = lib.mkIf cfg.enable {
warnings = lib.optional (cfg.installGhc == null) ''
`hls` relies on `ghc` (the Glasgow Haskell Compiler).
- Set `plugins.lsp.servers.hls.installGhc = true` to install it automatically with Nixvim.
You can customize which package to install by changing `plugins.lsp.servers.hls.ghcPackage`.
@ -29,6 +29,6 @@ in
By doing so, you will dismiss this warning.
'';
extraPackages = with pkgs; (optional ((isBool cfg.installGhc) && cfg.installGhc) cfg.ghcPackage);
extraPackages = lib.optional ((lib.isBool cfg.installGhc) && cfg.installGhc) cfg.ghcPackage;
};
}

View file

@ -1,25 +1,28 @@
{ lib, helpers }:
{ lib, ... }:
# Options:
# - https://github.com/grafana/jsonnet-language-server/tree/main/editor/vim
# - https://github.com/grafana/jsonnet-language-server/blob/main/pkg/server/configuration.go
# - https://github.com/google/go-jsonnet/blob/master/internal/formatter/jsonnetfmt.go#L55
with lib;
let
inherit (lib.nixvim) defaultNullOpts;
inherit (lib) types;
in
{
ext_vars = helpers.defaultNullOpts.mkAttrsOf types.str { } ''
ext_vars = defaultNullOpts.mkAttrsOf types.str { } ''
External variables.
'';
formatting = {
Indent = helpers.defaultNullOpts.mkUnsignedInt 2 ''
Indent = defaultNullOpts.mkUnsignedInt 2 ''
The number of spaces for each level of indenation.
'';
MaxBlankLines = helpers.defaultNullOpts.mkUnsignedInt 2 ''
MaxBlankLines = defaultNullOpts.mkUnsignedInt 2 ''
Max allowed number of consecutive blank lines.
'';
StringStyle =
helpers.defaultNullOpts.mkEnum
defaultNullOpts.mkEnum
[
"double"
"single"
@ -31,7 +34,7 @@ with lib;
'';
CommentStyle =
helpers.defaultNullOpts.mkEnum
defaultNullOpts.mkEnum
[
"hash"
"slash"
@ -42,35 +45,35 @@ with lib;
Whether comments should use hash `#`, slash `//`, or be left as-is.
'';
PrettyFieldNames = helpers.defaultNullOpts.mkBool true ''
PrettyFieldNames = defaultNullOpts.mkBool true ''
Causes fields to only be wrapped in `'''` when needed.
'';
PadArrays = helpers.defaultNullOpts.mkBool false ''
PadArrays = defaultNullOpts.mkBool false ''
Causes arrays to be written like `[ this ]` instead of `[this]`.
'';
PadObjects = helpers.defaultNullOpts.mkBool true ''
PadObjects = defaultNullOpts.mkBool true ''
Causes objects to be written like `{ this }` instead of `{this}`.
'';
SortImports = helpers.defaultNullOpts.mkBool true ''
SortImports = defaultNullOpts.mkBool true ''
Causes imports at the top of the file to be sorted in groups by filename.
'';
UseImplicitPlus = helpers.defaultNullOpts.mkBool true ''
UseImplicitPlus = defaultNullOpts.mkBool true ''
Removes plus sign where it is not required.
'';
StripEverything = helpers.defaultNullOpts.mkBool false ''
StripEverything = defaultNullOpts.mkBool false ''
Removes all comments and newlines.
'';
StripComments = helpers.defaultNullOpts.mkBool false ''
StripComments = defaultNullOpts.mkBool false ''
Removes all comments.
'';
StripAllButComments = helpers.defaultNullOpts.mkBool false ''
StripAllButComments = defaultNullOpts.mkBool false ''
Removes everything, other than comments.
'';
};

View file

@ -1,8 +1,11 @@
{ lib, helpers }:
with lib;
{ lib, ... }:
let
inherit (lib.nixvim) defaultNullOpts;
inherit (lib) types;
in
{
enabled =
helpers.defaultNullOpts.mkNullableWithRaw (with lib.types; either bool (listOf (maybeRaw str)))
defaultNullOpts.mkNullableWithRaw (with types; either bool (listOf (maybeRaw str)))
[
"bibtex"
"context"
@ -41,7 +44,7 @@ with lib;
- ["latex" "markdown"]
'';
language = helpers.defaultNullOpts.mkStr "en-US" ''
language = defaultNullOpts.mkStr "en-US" ''
The language (e.g., "en-US") LanguageTool should check against.
Use a specific variant like "en-US" or "de-DE" instead of the generic language code like "en" or
"de" to obtain spelling corrections (in addition to grammar corrections).
@ -101,250 +104,239 @@ with lib;
- "zh-CN": Chinese
'';
dictionary = helpers.defaultNullOpts.mkAttrsOf (with lib.types; 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
{
"<LANGUAGE1>" = [
"<WORD1>"
"<WORD2>"
...
];
"<LANGUAGE2>" = [
"<WORD1>"
"<WORD2>"
];
...
};
```
where <LANGUAGE> denotes the language code in `settings.language`.
dictionary = defaultNullOpts.mkAttrsOf' {
type = with types; listOf (maybeRaw str);
pluginDefault = { };
example = {
This setting is a multi-scope setting. See the documentation for details.
This setting supports external files. See the documentation for details.
By default, no additional spelling errors will be ignored.
Example:
```nix
{
"en-US" = [
"adaptivity"
"precomputed"
"subproblem"
"<LANGUAGE1>" = [
"<WORD1>"
"<WORD2>"
];
"de-DE" = [
"B-Splines"
":/path/to/externalFile.txt"
"<LANGUAGE2>" = [
"<WORD1>"
"<WORD2>"
];
}
```
'';
disabledRules = helpers.defaultNullOpts.mkAttrsOf (with lib.types; 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
{
"<LANGUAGE1>" = [
"<WORD1>"
"<WORD2>"
};
description = ''
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
{
...
];
"<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`.
This setting is a multi-scope setting. See the documentation for details.
This setting supports external files. See the documentation for details.
By default, no additional rules will be disabled.
This setting is a multi-scope setting. See the documentation for details.
This setting supports external files. See the documentation for details.
By default, no additional spelling errors will be ignored.
'';
};
Example:
```nix
{
disabledRules = defaultNullOpts.mkAttrsOf' {
type = with types; listOf (maybeRaw str);
pluginDefault = { };
example = {
"en-US" = [
"EN_QUOTES"
"UPPERCASE_SENTENCE_START"
":/path/to/externalFile.txt"
];
}
```
'';
enabledRules = helpers.defaultNullOpts.mkAttrsOf (with lib.types; 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
{
"<LANGUAGE1>" = [
"<WORD1>"
"<WORD2>"
...
];
"<LANGUAGE2>" = [
"<WORD1>"
"<WORD2>"
];
...
};
```
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 supports external files. See the documentation for details.
By default, no additional rules will be enabled.
Example:
```nix
{
"en-GB" = [
"PASSIVE_VOICE"
"OXFORD_SPELLING_NOUNS"
":/path/to/externalFile.txt"
];
}
```
'';
hiddenFalsePositives =
helpers.defaultNullOpts.mkAttrsOf (with lib.types; 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
```nix
{
"<LANGUAGE1>" = [
"<JSON1>"
"<JSON2>"
...
];
"<LANGUAGE2>" = [
"<JSON1>"
"<JSON2>"
];
};
description = ''
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
{
"<LANGUAGE1>" = [
"<WORD1>"
"<WORD2>"
...
};
```
where `<LANGUAGE>` denotes the language code in `settings.language` and `<JSON>` is a JSON
string containing information about the rule and sentence.
];
"<LANGUAGE2>" = [
"<WORD1>"
"<WORD2>"
];
...
};
```
where `<LANGUAGE>` denotes the language code in `settings.language` and `<RULE>` the ID of
the LanguageTool rule.
Although it is possible to manually edit this setting, the intended way is the
`Hide false positive` quick fix.
This setting is a multi-scope setting. See the documentation for details.
This setting supports external files. See the documentation for details.
By default, no additional rules will be disabled.
'';
};
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
expression.
All occurrences of the given rule are hidden in sentences (as determined by the LanguageTool
tokenizer) that match the regular expression.
See the documentation for details.
enabledRules = defaultNullOpts.mkAttrsOf' {
type = with types; listOf (maybeRaw str);
pluginDefault = { };
example = {
"en-GB" = [
"PASSIVE_VOICE"
"OXFORD_SPELLING_NOUNS"
":/path/to/externalFile.txt"
];
};
description = ''
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
{
"<LANGUAGE1>" = [
"<WORD1>"
"<WORD2>"
...
];
"<LANGUAGE2>" = [
"<WORD1>"
"<WORD2>"
];
...
};
```
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 supports external files. See the documentation for details.
If this list is very large, performance may suffer.
This setting is a multi-scope setting. See the documentation for details.
This setting supports external files. See the documentation for details.
By default, no additional rules will be enabled.
'';
};
Example:
```nix
{
"en-US" = [ ":/path/to/externalFile.txt" ];
}
```
'';
hiddenFalsePositives = defaultNullOpts.mkAttrsOf' {
type = with types; listOf (maybeRaw str);
pluginDefault = { };
example = {
"en-US" = [ ":/path/to/externalFile.txt" ];
};
description = ''
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
```nix
{
"<LANGUAGE1>" = [
"<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.
fields = helpers.defaultNullOpts.mkAttrsOf types.bool { } ''
List of BibTEX fields whose values are to be checked in BibTEX files.
Although it is possible to manually edit this setting, the intended way is the
`Hide false positive` quick fix.
This setting is an attrs with the field names as keys (not restricted to classical BibTEX
fields) and booleans as values, where `true` means that the field value should be checked and
`false` means that the field value should be ignored.
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
expression.
All occurrences of the given rule are hidden in sentences (as determined by the LanguageTool
tokenizer) that match the regular expression.
See the documentation for details.
Some common fields are already ignored, even if you set this setting to an empty attrs.
This setting is a multi-scope setting. See the documentation for details.
This setting supports external files. See the documentation for details.
If this list is very large, performance may suffer.
'';
};
Example:
```nix
{
maintitle = false;
seealso = true;
}
```
'';
fields = defaultNullOpts.mkAttrsOf' {
type = types.bool;
pluginDefault = { };
example = {
maintitle = false;
seealso = true;
};
description = ''
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
fields) and booleans as values, where `true` means that the field value should be checked and
`false` means that the field value should be ignored.
Some common fields are already ignored, even if you set this setting to an empty attrs.
'';
};
latex = {
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[]{}"`).
commands = defaultNullOpts.mkAttrsOf' {
type = types.str;
pluginDefault = { };
example = {
"\\label{}" = "ignore";
"\\documentclass[]{}" = "ignore";
"\\cite{}" = "dummy";
"\\cite[]{}" = "dummy";
};
description = ''
List of LATEX commands to be handled by the LATEX parser, listed together with empty arguments
(e.g., `"ref{}"`, `"\documentclass[]{}"`).
This setting is an attrs with the commands as keys and corresponding actions as values.
This setting is an attrs with the commands as keys and corresponding actions as values.
If you edit the `settings.json` file directly, dont forget to escape the initial backslash by
replacing it with two backslashes.
If you edit the `settings.json` file directly, dont forget to escape the initial backslash by
replacing it with two backslashes.
Many common commands are already handled by default, even if you set this setting to an empty
attrs.
Many common commands are already handled by default, even if you set this setting to an empty
attrs.
'';
};
Example:
```nix
{
"\\label{}" = "ignore";
"\\documentclass[]{}" = "ignore";
"\\cite{}" = "dummy";
"\\cite[]{}" = "dummy";
}
```
'';
environments = defaultNullOpts.mkAttrsOf' {
type = types.str;
pluginDefault = { };
example = {
lstlisting = "ignore";
verbatim = "ignore";
};
description = ''
List of names of LATEX environments to be handled by the LATEX parser.
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
values.
This setting is an attrs with the environment names as keys and corresponding actions as
values.
Some environments are already handled by default, even if you set this setting to an empty
attrs.
Example:
```nix
{
lstlisting = "ignore";
verbatim = "ignore";
}
```
'';
Some environments are already handled by default, even if you set this setting to an empty
attrs.
'';
};
};
markdown = {
nodes = helpers.defaultNullOpts.mkAttrsOf types.str { } ''
List of Markdown node types to be handled by the Markdown parser.
nodes = defaultNullOpts.mkAttrsOf' {
type = types.str;
pluginDefault = { };
example = {
CodeBlock = "ignore";
FencedCodeBlock = "ignore";
AutoLink = "dummy";
Code = "dummy";
};
description = ''
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.
The Markdown parser constructs an AST (abstract syntax tree) for the Markdown document, in
which all leaves have node type Text.
The possible node types are listed in the documentation of flexmark-java.
The Markdown parser constructs an AST (abstract syntax tree) for the Markdown document, in
which all leaves have node type Text.
The possible node types are listed in the documentation of flexmark-java.
Some common node types are already handled by default, even if you set this setting to an
empty attrs.
Example:
```nix
{
CodeBlock = "ignore";
FencedCodeBlock = "ignore";
AutoLink = "dummy";
Code = "dummy";
}
```
'';
Some common node types are already handled by default, even if you set this setting to an
empty attrs.
'';
};
};
configurationTarget =
helpers.defaultNullOpts.mkAttrsOf types.str
defaultNullOpts.mkAttrsOf types.str
{
dictionary = "workspaceFolderExternalFile";
disabledRules = "workspaceFolderExternalFile";
@ -356,12 +348,12 @@ with lib;
'';
additionalRules = {
enablePickyRules = helpers.defaultNullOpts.mkBool false ''
enablePickyRules = defaultNullOpts.mkBool false ''
Enable LanguageTool rules that are marked as picky and that are disabled by default, e.g.,
rules about passive voice, sentence length, etc., at the cost of more false positives.
'';
motherTongue = helpers.defaultNullOpts.mkStr "" ''
motherTongue = defaultNullOpts.mkStr "" ''
Optional mother tongue of the user (e.g., "de-DE").
If set, additional rules will be checked to detect false friends.
@ -421,47 +413,49 @@ with lib;
- "zh-CN": Chinese
'';
languageModel = helpers.defaultNullOpts.mkStr "" ''
languageModel = defaultNullOpts.mkStr "" ''
Optional path to a directory with rules of a language model with n-gram occurrence counts.
Set this setting to the parent directory that contains subdirectories for languages (e.g.,
en).
'';
neuralNetworkModel = helpers.defaultNullOpts.mkStr "" ''
neuralNetworkModel = defaultNullOpts.mkStr "" ''
Optional path to a directory with rules of a pretrained neural network model.
'';
word2VecModel = helpers.defaultNullOpts.mkStr "" ''
word2VecModel = defaultNullOpts.mkStr "" ''
Optional path to a directory with rules of a word2vec language model.
'';
};
languageToolHttpServerUri = helpers.defaultNullOpts.mkStr "" ''
If set to a non-empty string, LTEX will not use the bundled, built-in version of LanguageTool.
Instead, LTEX will connect to an external LanguageTool HTTP server.
Set this setting to the root URI of the server, and do not append v2/check or similar.
languageToolHttpServerUri = defaultNullOpts.mkStr' {
pluginDefault = "";
example = "http://localhost:8081/";
description = ''
If set to a non-empty string, LTEX will not use the bundled, built-in version of LanguageTool.
Instead, LTEX will connect to an external LanguageTool HTTP server.
Set this setting to the root URI of the server, and do not append v2/check or similar.
Note that in this mode, the settings `settings.additionalRules.languageModel`,
`settings.additionalRules.neuralNetworkModel`, and `settings.additionalRules.word2VecModel` will
not take any effect.
Example: `"http://localhost:8081/"`
'';
Note that in this mode, the settings `settings.additionalRules.languageModel`,
`settings.additionalRules.neuralNetworkModel`, and `settings.additionalRules.word2VecModel` will
not take any effect.
'';
};
languageToolOrg = {
username = helpers.defaultNullOpts.mkStr "" ''
username = defaultNullOpts.mkStr "" ''
Username/email as used to log in at `languagetool.org` for Premium API access.
Only relevant if `settings.languageToolHttpServerUri` is set.
'';
apiKey = helpers.defaultNullOpts.mkStr "" ''
apiKey = defaultNullOpts.mkStr "" ''
API key for Premium API access.
Only relevant if `settings.languageToolHttpServerUri` is set.
'';
};
ltex-ls = {
path = helpers.defaultNullOpts.mkStr "" ''
path = defaultNullOpts.mkStr "" ''
If set to an empty string, LTEX automatically downloads `ltex-ls` from GitHub, stores it in
the folder of the extension, and uses it for the checking process.
You can point this setting to an ltex-ls release you downloaded by yourself.
@ -472,7 +466,7 @@ with lib;
'';
logLevel =
helpers.defaultNullOpts.mkEnum
defaultNullOpts.mkEnum
[
"severe"
"warning"
@ -504,7 +498,7 @@ with lib;
};
java = {
path = helpers.defaultNullOpts.mkStr "" ''
path = defaultNullOpts.mkStr "" ''
If set to an empty string, LTEX uses a Java distribution that is bundled with `ltex-ls`.
You can point this setting to an existing Java installation on your computer to use that
installation instead.
@ -515,7 +509,7 @@ with lib;
Changes require restarting LTEX to take effect.
'';
initialHeapSize = helpers.defaultNullOpts.mkUnsignedInt 64 ''
initialHeapSize = defaultNullOpts.mkUnsignedInt 64 ''
Initial size of the Java heap memory in megabytes (corresponds to Javas -Xms option, must be
a positive integer).
@ -524,7 +518,7 @@ with lib;
Changes require restarting LTEX to take effect.
'';
maximumHeapSize = helpers.defaultNullOpts.mkUnsignedInt 512 ''
maximumHeapSize = defaultNullOpts.mkUnsignedInt 512 ''
Maximum size of the Java heap memory in megabytes (corresponds to Javas -Xmx option, must be
a positive integer).
@ -536,7 +530,7 @@ with lib;
'';
};
sentenceCacheSize = helpers.defaultNullOpts.mkUnsignedInt 2000 ''
sentenceCacheSize = 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),
@ -550,7 +544,7 @@ with lib;
Changes require restarting LTEX to take effect.
'';
completionEnabled = helpers.defaultNullOpts.mkBool false ''
completionEnabled = defaultNullOpts.mkBool false ''
Controls whether completion is enabled (also known as auto-completion, quick suggestions, and
IntelliSense).
@ -563,29 +557,34 @@ with lib;
It is recommended to enable this setting.
'';
diagnosticSeverity =
helpers.defaultNullOpts.mkNullableWithRaw (with lib.types; either str (attrsOf (maybeRaw str)))
"information"
''
Severity of the diagnostics corresponding to the grammar and spelling errors.
diagnosticSeverity = defaultNullOpts.mkNullableWithRaw' {
type = with types; either str (attrsOf (maybeRaw str));
pluginDefault = "information";
description = ''
Severity of the diagnostics corresponding to the grammar and spelling errors.
Controls how and where the diagnostics appear.
The possible severities are "error", "warning", "information", and "hint".
Controls how and where the diagnostics appear.
The possible severities are "error", "warning", "information", and "hint".
This setting can either be a string with the severity to use for all diagnostics, or an attrs
with rule-dependent severities.
If an attrs is used, each key is the ID of a LanguageTool rule and each value is one of the
possible severities.
In this case, the severity of other rules, which dont match any of the keys, has to be
specified with the special key "default".
This setting can either be a string with the severity to use for all diagnostics, or an attrs
with rule-dependent severities.
If an attrs is used, each key is the ID of a LanguageTool rule and each value is one of the
possible severities.
In this case, the severity of other rules, which dont match any of the keys, has to be
specified with the special key "default".
Examples:
- `"information"`
- `{PASSIVE_VOICE = "hint"; default = "information";}`
'';
Examples:
- `"information"`
- `{PASSIVE_VOICE = "hint"; default = "information";}`
'';
example = {
PASSIVE_VOICE = "hint";
default = "information";
};
};
checkFrequency =
helpers.defaultNullOpts.mkEnumFirstDefault
defaultNullOpts.mkEnumFirstDefault
[
"edit"
"save"
@ -602,17 +601,17 @@ with lib;
Use commands such as LTeX: Check Current Document to manually trigger checks.
'';
clearDiagnosticsWhenClosingFile = helpers.defaultNullOpts.mkBool true ''
clearDiagnosticsWhenClosingFile = defaultNullOpts.mkBool true ''
If set to true, diagnostics of a file are cleared when the file is closed.
'';
statusBarItem = helpers.defaultNullOpts.mkBool false ''
statusBarItem = defaultNullOpts.mkBool false ''
If set to true, an item about the status of LTEX is shown permanently in the status bar.
'';
trace = {
server =
helpers.defaultNullOpts.mkEnumFirstDefault
defaultNullOpts.mkEnumFirstDefault
[
"off"
"messages"

View file

@ -1,22 +1,25 @@
# All available settings are documented here:
# https://luals.github.io/wiki/settings/
{ lib, helpers }:
with lib;
{ lib, ... }:
let
inherit (lib.nixvim) defaultNullOpts;
inherit (lib) types;
in
{
addonManager = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Set the on/off state of the addon manager.
Disabling the addon manager prevents it from registering its command.
'';
};
completion = {
autoRequire = helpers.defaultNullOpts.mkBool true ''
autoRequire = defaultNullOpts.mkBool true ''
When the input looks like a file name, automatically require the file.
'';
callSnippet =
helpers.defaultNullOpts.mkEnumFirstDefault
defaultNullOpts.mkEnumFirstDefault
[
"Disable"
"Both"
@ -32,21 +35,21 @@ with lib;
When enabled, a "more complete" snippet will be offered.
'';
displayContext = helpers.defaultNullOpts.mkUnsignedInt 0 ''
displayContext = defaultNullOpts.mkUnsignedInt 0 ''
When a snippet is being suggested, this setting will set the amount of lines around the
snippet to preview to help you better understand its usage.
Setting to `0` will disable this feature.
'';
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable/disable completion.
Completion works like any autocompletion you already know of.
It helps you type less and get more done.
'';
keywordSnippet =
helpers.defaultNullOpts.mkEnum
defaultNullOpts.mkEnum
[
"Disable"
"Both"
@ -61,7 +64,7 @@ with lib;
Whether to show a snippet for key words like `if`, `while`, etc. When disabled, only the keyword will be completed. When enabled, a "more complete" snippet will be offered.
'';
postfix = helpers.defaultNullOpts.mkStr "@" ''
postfix = defaultNullOpts.mkStr "@" ''
The character to use for triggering a "postfix suggestion".
A postfix allows you to write some code and then trigger a snippet after (post) to "fix" the
code you have written.
@ -69,17 +72,17 @@ with lib;
`myTable@`.
'';
requireSeparator = helpers.defaultNullOpts.mkStr "." ''
requireSeparator = defaultNullOpts.mkStr "." ''
The separator to use when `require`-ing a file.
'';
showParams = helpers.defaultNullOpts.mkBool true ''
showParams = defaultNullOpts.mkBool true ''
Display a function's parameters in the list of completions.
When a function has multiple definitions, they will be displayed separately.
'';
showWord =
helpers.defaultNullOpts.mkEnum
defaultNullOpts.mkEnum
[
"Enable"
"Fallback"
@ -95,7 +98,7 @@ with lib;
usefulness in the current semantic context.
'';
workspaceWord = helpers.defaultNullOpts.mkBool true ''
workspaceWord = defaultNullOpts.mkBool true ''
Whether words from other files in the workspace should be suggested as "contextual words".
This can be useful for completing similar strings.
`completion.showWord` must not be disabled for this to have an effect.
@ -103,26 +106,26 @@ with lib;
};
diagnostics = {
disable = helpers.defaultNullOpts.mkListOf types.str [ ] ''
disable = defaultNullOpts.mkListOf types.str [ ] ''
Disable certain diagnostics globally.
For example, if you want all warnings for `lowercase-global` to be disabled, the value for
`diagnostics.disable` would be `["lowercase-global"]`.
'';
disableScheme = helpers.defaultNullOpts.mkListOf types.str [ "git" ] ''
disableScheme = defaultNullOpts.mkListOf types.str [ "git" ] ''
Disable diagnosis of Lua files that have the set schemes.
'';
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Whether all diagnostics should be enabled or not.
'';
globals = helpers.defaultNullOpts.mkListOf types.str [ ] ''
globals = defaultNullOpts.mkListOf types.str [ ] ''
An array of variable names that will be declared as global.
'';
groupFileStatus =
helpers.defaultNullOpts.mkAttrsOf
defaultNullOpts.mkAttrsOf
(types.enum [
"Any"
"Opened"
@ -157,7 +160,7 @@ with lib;
'';
groupSeverity =
helpers.defaultNullOpts.mkAttrsOf
defaultNullOpts.mkAttrsOf
(types.enum [
"Error"
"Warning"
@ -191,7 +194,7 @@ with lib;
'';
ignoredFiles =
helpers.defaultNullOpts.mkEnum
defaultNullOpts.mkEnum
[
"Enable"
"Opened"
@ -207,7 +210,7 @@ with lib;
'';
libraryFiles =
helpers.defaultNullOpts.mkEnum
defaultNullOpts.mkEnum
[
"Enable"
"Opened"
@ -223,7 +226,7 @@ with lib;
'';
neededFileStatus =
helpers.defaultNullOpts.mkAttrsOf
defaultNullOpts.mkAttrsOf
(types.enum [
"Any"
"Opened"
@ -301,7 +304,7 @@ with lib;
'';
severity =
helpers.defaultNullOpts.mkAttrsOf
defaultNullOpts.mkAttrsOf
(types.enum [
"Error"
"Warning"
@ -380,12 +383,12 @@ with lib;
- `"Hint!"` - Like `"Hint"` but overrides `diagnostics.groupSeverity`
'';
unusedLocalExclude = helpers.defaultNullOpts.mkListOf types.str [ ] ''
unusedLocalExclude = defaultNullOpts.mkListOf types.str [ ] ''
Define variable names that will not be reported as an unused local by
[`unused-local`](https://github.com/LuaLS/lua-language-server/wiki/Diagnostics#unused-local).
'';
workspaceDelay = helpers.defaultNullOpts.mkUnsignedInt 3000 ''
workspaceDelay = defaultNullOpts.mkUnsignedInt 3000 ''
Define the delay between diagnoses of the workspace in milliseconds.
Every time a file is edited, created, deleted, etc. the workspace will be re-diagnosed in the
background after this delay.
@ -393,7 +396,7 @@ with lib;
'';
workspaceEvent =
helpers.defaultNullOpts.mkEnum
defaultNullOpts.mkEnum
[
"OnChange"
"OnSave"
@ -410,7 +413,7 @@ with lib;
- `"None"`
'';
workspaceRate = helpers.defaultNullOpts.mkUnsignedInt 100 ''
workspaceRate = defaultNullOpts.mkUnsignedInt 100 ''
Define the rate at which the workspace will be diagnosed as a percentage.
`100` is 100% speed so the workspace will be diagnosed as fast as possible.
The rate can be lowered to reduce CPU usage, but the diagnosis speed will also become slower.
@ -419,37 +422,37 @@ with lib;
};
doc = {
packageName = helpers.defaultNullOpts.mkListOf types.str [ ] ''
packageName = defaultNullOpts.mkListOf types.str [ ] ''
The pattern used for matching field names as a package-private field.
Fields that match any of the patterns provided will be package-private.
'';
privateName = helpers.defaultNullOpts.mkListOf types.str [ ] ''
privateName = defaultNullOpts.mkListOf types.str [ ] ''
The pattern used for matching field names as a private field.
Fields that match any of the patterns provided will be private to that class.
'';
protectedName = helpers.defaultNullOpts.mkListOf types.str [ ] ''
protectedName = defaultNullOpts.mkListOf types.str [ ] ''
The pattern used for matching field names as a protected field.
Fields that match any of the patterns provided will be private to that class and its child classes.
'';
};
format = {
defaultConfig = helpers.defaultNullOpts.mkAttrsOf types.str { } ''
defaultConfig = defaultNullOpts.mkAttrsOf types.str { } ''
The default configuration for the formatter.
If there is a `.editorconfig` in the workspace, it will take priority.
Read more on the [formatter's GitHub page](https://github.com/CppCXY/EmmyLuaCodeStyle/tree/master/docs).
'';
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Whether the built-in formatted should be enabled or not.
'';
};
hint = {
arrayIndex =
helpers.defaultNullOpts.mkEnum
defaultNullOpts.mkEnum
[
"Enable"
"Auto"
@ -462,17 +465,17 @@ with lib;
- `"Disable"` - Disable array index hints
'';
await = helpers.defaultNullOpts.mkBool true ''
await = defaultNullOpts.mkBool true ''
If a function has been defined as [`@async`](https://github.com/LuaLS/lua-language-server/wiki/Annotations#async),
display an `await` hint when it is being called.
'';
enable = helpers.defaultNullOpts.mkBool false ''
enable = defaultNullOpts.mkBool false ''
Whether inline hints should be enabled or not.
'';
paramName =
helpers.defaultNullOpts.mkEnumFirstDefault
defaultNullOpts.mkEnumFirstDefault
[
"All"
"Literal"
@ -486,13 +489,13 @@ with lib;
- `"Disable"` - No parameter hints are shown
'';
paramType = helpers.defaultNullOpts.mkBool true ''
paramType = defaultNullOpts.mkBool true ''
Show a hint for parameter types at a function definition.
Requires the parameters to be defined with [`@param`](https://github.com/LuaLS/lua-language-server/wiki/Annotations#param).
'';
semicolon =
helpers.defaultNullOpts.mkEnum
defaultNullOpts.mkEnum
[
"All"
"SameLine"
@ -507,63 +510,63 @@ with lib;
- `"Disable"` - Never hint a semicolon
'';
setType = helpers.defaultNullOpts.mkBool false ''
setType = defaultNullOpts.mkBool false ''
Show a hint to display the type being applied at assignment operations.
'';
};
hover = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Whether to enable hover tooltips or not.
'';
enumsLimit = helpers.defaultNullOpts.mkUnsignedInt 5 ''
enumsLimit = defaultNullOpts.mkUnsignedInt 5 ''
When a value has multiple possible types, hovering it will display them.
This setting limits how many will be displayed in the tooltip before they are truncated.
'';
expandAlias = helpers.defaultNullOpts.mkBool true ''
expandAlias = defaultNullOpts.mkBool true ''
When hovering a value with an [`@alias`](https://github.com/LuaLS/lua-language-server/wiki/Annotations#alias)
for its type, should the alias be expanded into its values.
When enabled, `---@alias myType boolean|number` appears as `boolean|number`, otherwise it will
appear as `myType`.
'';
previewFields = helpers.defaultNullOpts.mkUnsignedInt 50 ''
previewFields = defaultNullOpts.mkUnsignedInt 50 ''
When a table is hovered, its fields will be displayed in the tooltip.
This setting limits how many fields can be seen in the tooltip.
Setting to `0` will disable this feature.
'';
viewNumber = helpers.defaultNullOpts.mkBool true ''
viewNumber = defaultNullOpts.mkBool true ''
Enable hovering a non-decimal value to see its numeric value.
'';
viewString = helpers.defaultNullOpts.mkBool true ''
viewString = defaultNullOpts.mkBool true ''
Enable hovering a string that contains an escape character to see its true string value.
For example, hovering `"\x48"` will display `"H"`.
'';
viewStringMax = helpers.defaultNullOpts.mkUnsignedInt 1000 ''
viewStringMax = defaultNullOpts.mkUnsignedInt 1000 ''
The maximum number of characters that can be previewed by hovering a string before it is
truncated.
'';
};
misc = {
parameters = helpers.defaultNullOpts.mkListOf types.str [ ] ''
parameters = defaultNullOpts.mkListOf types.str [ ] ''
[Command line parameters](https://github.com/LuaLS/lua-language-server/wiki/Getting-Started#run)
to be passed along to the server `exe` when starting through Visual Studio Code.
'';
executablePath = helpers.defaultNullOpts.mkStr "" ''
executablePath = defaultNullOpts.mkStr "" ''
Manually specify the path for the Lua Language Server executable file.
'';
};
runtime = {
builtin =
helpers.defaultNullOpts.mkAttrsOf
defaultNullOpts.mkAttrsOf
(types.enum [
"default"
"enable"
@ -617,7 +620,7 @@ with lib;
'';
fileEncoding =
helpers.defaultNullOpts.mkEnumFirstDefault
defaultNullOpts.mkEnumFirstDefault
[
"utf8"
"ansi"
@ -631,13 +634,13 @@ with lib;
- `"utf16be"`
'';
meta = helpers.defaultNullOpts.mkStr "$\{version} $\{language} $\{encoding}" ''
meta = defaultNullOpts.mkStr "$\{version} $\{language} $\{encoding}" ''
Specify the template that should be used for naming the folders that contain the generated
definitions for the various Lua versions, languages, and encodings.
'';
nonstandardSymbol =
helpers.defaultNullOpts.mkListOf
defaultNullOpts.mkListOf
(types.enum [
"//"
"/**/"
@ -667,7 +670,7 @@ with lib;
'';
path =
helpers.defaultNullOpts.mkListOf types.str
defaultNullOpts.mkListOf types.str
[
"?.lua"
"?/init.lua"
@ -682,71 +685,71 @@ with lib;
[`workspace.library`](https://github.com/LuaLS/lua-language-server/wiki/Settings#workspacelibrary).
'';
pathStrict = helpers.defaultNullOpts.mkBool false ''
pathStrict = defaultNullOpts.mkBool false ''
When enabled, [`runtime.path`](https://github.com/LuaLS/lua-language-server/wiki/Settings#runtimepath)
will only search the first level of directories.
See the description of `runtime.path` for more info.
'';
plugin = helpers.defaultNullOpts.mkStr "" ''
plugin = defaultNullOpts.mkStr "" ''
The path to the [plugin](https://github.com/LuaLS/lua-language-server/wiki/Plugins) to use.
Blank by default for security reasons.
'';
pluginArgs = helpers.defaultNullOpts.mkListOf types.str [ ] ''
pluginArgs = defaultNullOpts.mkListOf types.str [ ] ''
Additional arguments that will be passed to the active
[plugin](https://github.com/LuaLS/lua-language-server/wiki/Plugins).
'';
special = helpers.defaultNullOpts.mkAttrsOf types.str { } ''
special = defaultNullOpts.mkAttrsOf types.str { } ''
Special variables can be set to be treated as other variables. For example, specifying `"include" : "require"` will result in `include` being treated like `require`.
'';
unicodeName = helpers.defaultNullOpts.mkBool false ''
unicodeName = defaultNullOpts.mkBool false ''
Whether unicode characters should be allowed in variable names or not.
'';
version = helpers.defaultNullOpts.mkStr "Lua 5.4" ''
version = defaultNullOpts.mkStr "Lua 5.4" ''
The Lua runtime version to use in this environment.
'';
};
semantic = {
annotation = helpers.defaultNullOpts.mkBool true ''
annotation = defaultNullOpts.mkBool true ''
Whether semantic colouring should be enabled for type annotations.
'';
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Whether semantic colouring should be enabled.
You may need to set `editor.semanticHighlighting.enabled` to true in order for this setting to
take effect.
'';
keyword = helpers.defaultNullOpts.mkBool false ''
keyword = defaultNullOpts.mkBool false ''
Whether the server should provide semantic colouring of keywords, literals, and operators.
You should only need to enable this setting if your editor is unable to highlight Lua's syntax.
'';
variable = helpers.defaultNullOpts.mkBool true ''
variable = defaultNullOpts.mkBool true ''
Whether the server should provide semantic colouring of variables, fields, and parameters.
'';
};
signatureHelp = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
The signatureHelp group contains settings for helping understand signatures.
'';
};
spell = {
dict = helpers.defaultNullOpts.mkListOf types.str [ ] ''
dict = defaultNullOpts.mkListOf types.str [ ] ''
A custom dictionary of words that you know are spelt correctly but are being reported as incorrect.
Adding words to this dictionary will make them exempt from spell checking.
'';
};
telemetry = {
enable = helpers.defaultNullOpts.mkBool null ''
enable = defaultNullOpts.mkBool null ''
The language server comes with opt-in telemetry to help improve the language server.
It would be greatly appreciated if you enable this setting.
Read the [privacy policy](https://github.com/LuaLS/lua-language-server/wiki/Home#privacy)
@ -755,11 +758,11 @@ with lib;
};
type = {
castNumberToInteger = helpers.defaultNullOpts.mkBool false ''
castNumberToInteger = defaultNullOpts.mkBool false ''
Whether casting a `number` to an `integer` is allowed.
'';
weakNilCheck = helpers.defaultNullOpts.mkBool false ''
weakNilCheck = defaultNullOpts.mkBool false ''
Whether it is permitted to assign a union type that contains `nil` to a variable that does not
permit it.
When `false`, the following will throw an error because `number|nil` cannot be assigned to
@ -775,7 +778,7 @@ with lib;
```
'';
weakUnionCheck = helpers.defaultNullOpts.mkBool false ''
weakUnionCheck = defaultNullOpts.mkBool false ''
Whether it is permitted to assign a union type which only has one matching type to a variable.
When `false`, the following will throw an error because `string|boolean` cannot be assigned to
`string`.
@ -790,18 +793,18 @@ with lib;
};
window = {
progressBar = helpers.defaultNullOpts.mkBool true ''
progressBar = defaultNullOpts.mkBool true ''
Show a progress bar in the bottom status bar that shows how the workspace loading is progressing.
'';
statusBar = helpers.defaultNullOpts.mkBool true ''
statusBar = defaultNullOpts.mkBool true ''
Show a `Lua 😺` entry in the bottom status bar that can be clicked to manually perform a
workspace diagnosis.
'';
};
workspace = {
checkThirdParty = helpers.defaultNullOpts.mkBool true ''
checkThirdParty = defaultNullOpts.mkBool true ''
Whether [third party libraries](https://github.com/LuaLS/lua-language-server/wiki/Libraries)
can be automatically detected and applied.
Third party libraries can set up the environment to be as close as possible to your target
@ -810,17 +813,17 @@ with lib;
to view what third party libraries are currently supported.
'';
ignoreDir = helpers.defaultNullOpts.mkListOf types.str [ ".vscode" ] ''
ignoreDir = defaultNullOpts.mkListOf types.str [ ".vscode" ] ''
An array of paths that will be ignored and not included in the workspace diagnosis.
Uses `.gitignore` grammar. Can be a file or directory.
'';
ignoreSubmodules = helpers.defaultNullOpts.mkBool true ''
ignoreSubmodules = defaultNullOpts.mkBool true ''
Whether [git submodules](https://github.blog/2016-02-01-working-with-submodules/)
should be ignored and not included in the workspace diagnosis.
'';
library = helpers.defaultNullOpts.mkListOf types.str [ ] ''
library = defaultNullOpts.mkListOf types.str [ ] ''
An array of abosolute or workspace-relative paths that will be added to the workspace
diagnosis - meaning you will get completion and context from these library files.
Can be a file or directory.
@ -829,17 +832,17 @@ with lib;
Read more on the [Libraries page](https://github.com/LuaLS/lua-language-server/wiki/Libraries).
'';
maxPreload = helpers.defaultNullOpts.mkUnsignedInt 5000 ''
maxPreload = defaultNullOpts.mkUnsignedInt 5000 ''
The maximum amount of files that can be diagnosed.
More files will require more RAM.
'';
preloadFileSize = helpers.defaultNullOpts.mkUnsignedInt 500 ''
preloadFileSize = defaultNullOpts.mkUnsignedInt 500 ''
Files larger than this value (in KB) will be skipped when loading for workspace diagnosis.
'';
supportScheme =
helpers.defaultNullOpts.mkListOf types.str
defaultNullOpts.mkListOf types.str
[
"file"
"untitled"
@ -849,12 +852,12 @@ with lib;
Lua file schemes to enable the language server for.
'';
useGitIgnore = helpers.defaultNullOpts.mkBool true ''
useGitIgnore = defaultNullOpts.mkBool true ''
Whether files that are in `.gitignore` should be ignored by the language server when
performing workspace diagnosis.
'';
userThirdParty = helpers.defaultNullOpts.mkListOf types.str [ ] ''
userThirdParty = defaultNullOpts.mkListOf types.str [ ] ''
An array of paths to
[custom third party libraries](https://github.com/LuaLS/lua-language-server/wiki/Libraries#custom).
This path should point to a directory where **all** of your custom libraries are, not just to

View file

@ -1,10 +1,13 @@
{ lib, helpers }:
{ lib, ... }:
# All available settings are documented here:
# https://github.com/oxalica/nil/blob/main/docs/configuration.md
with lib;
let
inherit (lib.nixvim) defaultNullOpts;
inherit (lib) types;
in
{
formatting = {
command = helpers.defaultNullOpts.mkListOf' {
command = defaultNullOpts.mkListOf' {
type = types.str;
pluginDefault = null;
description = ''
@ -17,13 +20,13 @@ with lib;
};
diagnostics = {
ignored = helpers.defaultNullOpts.mkListOf types.str [ ] ''
ignored = defaultNullOpts.mkListOf types.str [ ] ''
Ignored diagnostic kinds.
The kind identifier is a snake_cased_string usually shown together
with the diagnostic message.
'';
excludedFiles = helpers.defaultNullOpts.mkListOf' {
excludedFiles = defaultNullOpts.mkListOf' {
type = types.str;
pluginDefault = [ ];
description = ''
@ -37,13 +40,13 @@ with lib;
};
nix = {
binary = helpers.defaultNullOpts.mkStr' {
binary = defaultNullOpts.mkStr' {
pluginDefault = "nix";
description = "The path to the `nix` binary.";
example = "/run/current-system/sw/bin/nix";
};
maxMemoryMB = helpers.defaultNullOpts.mkUnsignedInt' {
maxMemoryMB = defaultNullOpts.mkUnsignedInt' {
pluginDefault = 2560;
example = 1024;
description = ''
@ -59,19 +62,19 @@ with lib;
};
flake = {
autoArchive = helpers.defaultNullOpts.mkBool false ''
autoArchive = defaultNullOpts.mkBool false ''
Auto-archiving behavior which may use network.
- `null`: Ask every time.
- `true`: Automatically run `nix flake archive` when necessary.
- `false`: Do not archive. Only load inputs that are already on disk.
'';
autoEvalInputs = helpers.defaultNullOpts.mkBool false ''
autoEvalInputs = defaultNullOpts.mkBool false ''
Whether to auto-eval flake inputs.
The evaluation result is used to improve completion, but may cost lots of time and/or memory.
'';
nixpkgsInputName = helpers.defaultNullOpts.mkStr' {
nixpkgsInputName = defaultNullOpts.mkStr' {
pluginDefault = "nixpkgs";
example = "nixos";
description = ''

View file

@ -1,11 +1,14 @@
{ lib, helpers }:
{ lib, ... }:
# Options:
# - https://github.com/nix-community/nixd/blob/main/nixd/docs/configuration.md
# - https://github.com/nix-community/nixd/blob/main/nixd/include/nixd/Controller/Configuration.h
with lib;
let
inherit (lib.nixvim) defaultNullOpts mkNullOrOption;
inherit (lib) types;
in
{
diagnostic = {
suppress = helpers.defaultNullOpts.mkListOf' {
suppress = defaultNullOpts.mkListOf' {
type = types.str;
description = ''
Disable specific LSP warnings, etc.
@ -20,7 +23,7 @@ with lib;
};
formatting = {
command = helpers.defaultNullOpts.mkListOf types.str [ "nixpkgs-fmt" ] ''
command = defaultNullOpts.mkListOf types.str [ "nixpkgs-fmt" ] ''
Which command you would like to do formatting.
Explicitly setting to `["nixpkgs-fmt"]` will automatically add `pkgs.nixpkgs-fmt` to the nixvim
environment.
@ -31,14 +34,14 @@ with lib;
let
provider = types.submodule {
options = {
expr = mkOption {
expr = lib.mkOption {
type = types.str;
description = "Expression to eval. Select this attrset as eval .options";
};
};
};
in
helpers.mkNullOrOption (with lib.types; attrsOf (maybeRaw provider)) ''
mkNullOrOption (with types; attrsOf (maybeRaw provider)) ''
Tell the language server your desired option set, for completion.
This is lazily evaluated.
'';
@ -47,14 +50,14 @@ with lib;
let
provider = types.submodule {
options = {
expr = mkOption {
expr = lib.mkOption {
type = types.str;
description = "Expression to eval. Treat it as `import <nixpkgs> { }`";
};
};
};
in
helpers.mkNullOrOption (lib.types.maybeRaw provider) ''
mkNullOrOption (types.maybeRaw provider) ''
This expression will be interpreted as "nixpkgs" toplevel
Nixd provides package, lib completion/information from it.
'';

View file

@ -1,17 +1,17 @@
{
lib,
helpers,
config,
pkgs,
config,
...
}:
with lib;
let
cfg = config.plugins.lsp.servers.pylsp;
inherit (lib.nixvim) defaultNullOpts mkNullOrOption;
inherit (lib) mkOption types;
in
{
options.plugins.lsp.servers.pylsp = {
pythonPackage = mkPackageOption pkgs "python" {
pythonPackage = lib.mkPackageOption pkgs "python" {
default = "python3";
};
@ -19,7 +19,7 @@ in
# https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md
settings = {
configurationSources = mkOption {
type = lib.types.nullOr (
type = types.nullOr (
types.enum [
"pycodestyle"
"flake8"
@ -32,108 +32,108 @@ in
plugins = {
autopep8 = {
enabled = helpers.defaultNullOpts.mkBool true ''
enabled = defaultNullOpts.mkBool true ''
Enable or disable the plugin.
Setting this explicitly to `true` will install the dependency for this plugin (autopep8).
'';
};
flake8 = {
config = helpers.mkNullOrOption types.str ''
config = mkNullOrOption types.str ''
Path to the config file that will be the authoritative config source.
'';
enabled = helpers.defaultNullOpts.mkBool false ''
enabled = defaultNullOpts.mkBool false ''
Enable or disable the plugin.
Setting this explicitly to `true` will install the dependency for this plugin (flake8).
'';
exclude = helpers.defaultNullOpts.mkListOf types.str [ ] ''
exclude = defaultNullOpts.mkListOf types.str [ ] ''
List of files or directories to exclude.
'';
executable = helpers.mkNullOrOption types.str ''
executable = mkNullOrOption types.str ''
Path to the flake8 executable.
'';
filename = helpers.mkNullOrOption types.str ''
filename = mkNullOrOption types.str ''
Only check for filenames matching the patterns in this list.
'';
hangClosing = helpers.mkNullOrOption types.bool ''
hangClosing = mkNullOrOption types.bool ''
Hang closing bracket instead of matching indentation of opening bracket's line.
'';
ignore = helpers.defaultNullOpts.mkListOf types.str [ ] ''
ignore = defaultNullOpts.mkListOf types.str [ ] ''
List of errors and warnings to ignore (or skip).
'';
maxComplexity = helpers.mkNullOrOption types.int ''
maxComplexity = mkNullOrOption types.int ''
Maximum allowed complexity threshold.
'';
maxLineLength = helpers.mkNullOrOption types.int ''
maxLineLength = mkNullOrOption types.int ''
Maximum allowed line length for the entirety of this run.
'';
indentSize = helpers.mkNullOrOption types.int ''
indentSize = mkNullOrOption types.int ''
Set indentation spaces.
'';
perFileIgnores = helpers.defaultNullOpts.mkListOf types.str [ ] ''
perFileIgnores = defaultNullOpts.mkListOf types.str [ ] ''
A pairing of filenames and violation codes that defines which violations to ignore in a
particular file.
For example: `["file_path.py:W305,W304"]`.
'';
select = helpers.mkNullOrOption (types.listOf types.str) ''
select = mkNullOrOption (types.listOf types.str) ''
List of errors and warnings to enable.
'';
};
jedi = {
auto_import_modules = helpers.defaultNullOpts.mkListOf types.str [
auto_import_modules = defaultNullOpts.mkListOf types.str [
"numpy"
] "List of module names for `jedi.settings.auto_import_modules`.";
extra_paths = helpers.defaultNullOpts.mkListOf types.str [ ] ''
extra_paths = defaultNullOpts.mkListOf types.str [ ] ''
Define extra paths for jedi.Script.
'';
environment = helpers.mkNullOrOption types.str ''
environment = mkNullOrOption types.str ''
Define environment for jedi.Script and Jedi.names.
'';
};
jedi_completion = {
enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin.";
enabled = defaultNullOpts.mkBool true "Enable or disable the plugin.";
include_params = helpers.defaultNullOpts.mkBool true ''
include_params = defaultNullOpts.mkBool true ''
Auto-completes methods and classes with tabstops for each parameter.
'';
include_class_objects = helpers.defaultNullOpts.mkBool false ''
include_class_objects = defaultNullOpts.mkBool false ''
Adds class objects as a separate completion item.
'';
include_function_objects = helpers.defaultNullOpts.mkBool false ''
include_function_objects = defaultNullOpts.mkBool false ''
Adds function objects as a separate completion item.
'';
fuzzy = helpers.defaultNullOpts.mkBool false ''
fuzzy = defaultNullOpts.mkBool false ''
Enable fuzzy when requesting autocomplete.
'';
eager = helpers.defaultNullOpts.mkBool false ''
eager = defaultNullOpts.mkBool false ''
Resolve documentation and detail eagerly.
'';
resolve_at_most = helpers.defaultNullOpts.mkInt 25 ''
resolve_at_most = defaultNullOpts.mkInt 25 ''
How many labels and snippets (at most) should be resolved.
'';
cache_for = helpers.defaultNullOpts.mkListOf types.str [
cache_for = defaultNullOpts.mkListOf types.str [
"pandas"
"numpy"
"tensorflow"
@ -142,159 +142,159 @@ in
};
jedi_definition = {
enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin.";
enabled = defaultNullOpts.mkBool true "Enable or disable the plugin.";
follow_imports = helpers.defaultNullOpts.mkBool true ''
follow_imports = defaultNullOpts.mkBool true ''
The goto call will follow imports.
'';
follow_builtin_imports = helpers.defaultNullOpts.mkBool true ''
follow_builtin_imports = defaultNullOpts.mkBool true ''
If follow_imports is true will decide if it follow builtin imports.
'';
follow_builtin_definitions = helpers.defaultNullOpts.mkBool true ''
follow_builtin_definitions = defaultNullOpts.mkBool true ''
Follow builtin and extension definitions to stubs.
'';
};
jedi_hover = {
enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin.";
enabled = defaultNullOpts.mkBool true "Enable or disable the plugin.";
};
jedi_references = {
enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin.";
enabled = defaultNullOpts.mkBool true "Enable or disable the plugin.";
};
jedi_signature_help = {
enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin.";
enabled = defaultNullOpts.mkBool true "Enable or disable the plugin.";
};
jedi_symbols = {
enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin.";
enabled = defaultNullOpts.mkBool true "Enable or disable the plugin.";
all_scopes = helpers.defaultNullOpts.mkBool true ''
all_scopes = defaultNullOpts.mkBool true ''
If true lists the names of all scopes instead of only the module namespace.
'';
include_import_symbols = helpers.defaultNullOpts.mkBool true ''
include_import_symbols = defaultNullOpts.mkBool true ''
If true includes symbols imported from other libraries.
'';
};
mccabe = {
enabled = helpers.defaultNullOpts.mkBool true ''
enabled = defaultNullOpts.mkBool true ''
Enable or disable the plugin.
Setting this explicitly to `true` will install the dependency for this plugin (mccabe).
'';
threshold = helpers.defaultNullOpts.mkInt 15 ''
threshold = defaultNullOpts.mkInt 15 ''
The minimum threshold that triggers warnings about cyclomatic complexity.
'';
};
preload = {
enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin.";
enabled = defaultNullOpts.mkBool true "Enable or disable the plugin.";
modules = helpers.defaultNullOpts.mkListOf types.str [ ] ''
modules = defaultNullOpts.mkListOf types.str [ ] ''
List of modules to import on startup.
'';
};
pycodestyle = {
enabled = helpers.defaultNullOpts.mkBool true ''
enabled = defaultNullOpts.mkBool true ''
Enable or disable the plugin.
Setting this explicitly to `true` will install the dependency for this plugin
(pycodestyle).
'';
exclude = helpers.defaultNullOpts.mkListOf types.str [ ] ''
exclude = defaultNullOpts.mkListOf types.str [ ] ''
Exclude files or directories which match these patterns.
'';
filename = helpers.defaultNullOpts.mkListOf types.str [ ] ''
filename = defaultNullOpts.mkListOf types.str [ ] ''
When parsing directories, only check filenames matching these patterns.
'';
ropeFolder = helpers.mkNullOrOption (types.listOf types.str) ''
ropeFolder = mkNullOrOption (types.listOf types.str) ''
Select errors and warnings.
'';
ignore = helpers.defaultNullOpts.mkListOf types.str [ ] ''
ignore = defaultNullOpts.mkListOf types.str [ ] ''
Ignore errors and warnings.
'';
hangClosing = helpers.mkNullOrOption types.bool ''
hangClosing = mkNullOrOption types.bool ''
Hang closing bracket instead of matching indentation of opening bracket's line.
'';
maxLineLength = helpers.mkNullOrOption types.int ''
maxLineLength = mkNullOrOption types.int ''
Set maximum allowed line length.
'';
indentSize = helpers.mkNullOrOption types.int ''
indentSize = mkNullOrOption types.int ''
Set indentation spaces.
'';
};
pydocstyle = {
enabled = helpers.defaultNullOpts.mkBool false ''
enabled = defaultNullOpts.mkBool false ''
Enable or disable the plugin.
Setting this explicitly to `true` will install the dependency for this plugin
(pydocstyle).
'';
convention = helpers.mkNullOrOption (types.enum [
convention = mkNullOrOption (types.enum [
"pep257"
"numpy"
"google"
"None"
]) "Choose the basic list of checked errors by specifying an existing convention.";
addIgnore = helpers.defaultNullOpts.mkListOf types.str [ ] ''
addIgnore = defaultNullOpts.mkListOf types.str [ ] ''
Ignore errors and warnings in addition to the specified convention.
'';
addSelect = helpers.defaultNullOpts.mkListOf types.str [ ] ''
addSelect = defaultNullOpts.mkListOf types.str [ ] ''
Select errors and warnings in addition to the specified convention.
'';
ignore = helpers.defaultNullOpts.mkListOf types.str [ ] ''
ignore = defaultNullOpts.mkListOf types.str [ ] ''
Ignore errors and warnings.
'';
select = helpers.mkNullOrOption (types.listOf types.str) ''
select = mkNullOrOption (types.listOf types.str) ''
Select errors and warnings.
'';
match = helpers.defaultNullOpts.mkStr "(?!test_).*\\.py" ''
match = defaultNullOpts.mkStr "(?!test_).*\\.py" ''
Check only files that exactly match the given regular expression;
default is to match files that don't start with 'test_' but end with '.py'.
'';
matchDir = helpers.defaultNullOpts.mkStr "[^\\.].*" ''
matchDir = defaultNullOpts.mkStr "[^\\.].*" ''
Search only dirs that exactly match the given regular expression;
default is to match dirs which do not begin with a dot.
'';
};
pyflakes = {
enabled = helpers.defaultNullOpts.mkBool true ''
enabled = defaultNullOpts.mkBool true ''
Enable or disable the plugin.
Setting this explicitly to `true` will install the dependency for this plugin (pyflakes).
'';
};
pylint = {
enabled = helpers.defaultNullOpts.mkBool false ''
enabled = defaultNullOpts.mkBool false ''
Enable or disable the plugin.
Setting this explicitly to `true` will install the dependency for this plugin (pylint).
'';
args = helpers.defaultNullOpts.mkListOf types.str [ ] ''
args = defaultNullOpts.mkListOf types.str [ ] ''
Arguments to pass to pylint.
'';
executable = helpers.mkNullOrOption types.str ''
executable = mkNullOrOption types.str ''
Executable to run pylint with.
Enabling this will run pylint on unsaved files via stdin.
Can slow down workflow. Only works with python3.
@ -302,30 +302,30 @@ in
};
rope_autoimport = {
enabled = helpers.defaultNullOpts.mkBool false ''
enabled = defaultNullOpts.mkBool false ''
Enable or disable the plugin.
Setting this explicitly to `true` will install the dependency for this plugin (rope).
'';
memory = helpers.defaultNullOpts.mkBool false ''
memory = defaultNullOpts.mkBool false ''
Make the autoimport database memory only.
Drastically increases startup time.
'';
};
rope_completion = {
enabled = helpers.defaultNullOpts.mkBool false ''
enabled = defaultNullOpts.mkBool false ''
Enable or disable the plugin.
Setting this explicitly to `true` will install the dependency for this plugin (rope).
'';
eager = helpers.defaultNullOpts.mkBool false ''
eager = defaultNullOpts.mkBool false ''
Resolve documentation and detail eagerly.
'';
};
yapf = {
enabled = helpers.defaultNullOpts.mkBool true ''
enabled = defaultNullOpts.mkBool true ''
Enable or disable the plugin.
Setting this explicitly to `true` will install the dependency for this plugin (yapf).
'';
@ -333,32 +333,32 @@ in
### THIRD-PARTY PLUGINS
pylsp_mypy = {
enabled = helpers.defaultNullOpts.mkBool false ''
enabled = defaultNullOpts.mkBool false ''
Enable or disable the plugin.
Setting this explicitly to `true` will install the dependency for this plugin
(pylsp-mypy).
'';
live_mode = helpers.defaultNullOpts.mkBool true ''
live_mode = defaultNullOpts.mkBool true ''
Provides type checking as you type.
This writes to a tempfile every time a check is done.
Turning off live_mode means you must save your changes for mypy diagnostics to update
correctly.
'';
dmypy = helpers.defaultNullOpts.mkBool false ''
dmypy = defaultNullOpts.mkBool false ''
Executes via dmypy run rather than mypy.
This uses the dmypy daemon and may dramatically improve the responsiveness of the pylsp
server, however this currently does not work in live_mode.
Enabling this disables live_mode, even for conflicting configs.
'';
strict = helpers.defaultNullOpts.mkBool false ''
strict = defaultNullOpts.mkBool false ''
Refers to the strict option of mypy.
This option often is too strict to be useful.
'';
overrides = helpers.defaultNullOpts.mkListOf (with types; either bool str) [ true ] ''
overrides = defaultNullOpts.mkListOf (with types; either bool str) [ true ] ''
Specifies a list of alternate or supplemental command-line options.
This modifies the options passed to mypy or the mypy-specific ones passed to dmypy run.
When present, the special boolean member true is replaced with the command-line options that
@ -367,18 +367,18 @@ in
options (see `mypy.main:process_options` and `mypy --help | grep inverse`).
'';
dmypy_status_file = helpers.defaultNullOpts.mkStr ".dmypy.json" ''
dmypy_status_file = defaultNullOpts.mkStr ".dmypy.json" ''
Specifies which status file dmypy should use.
This modifies the --status-file option passed to dmypy given dmypy is active.
'';
config_sub_paths = helpers.defaultNullOpts.mkListOf types.str [ ] ''
config_sub_paths = defaultNullOpts.mkListOf types.str [ ] ''
Specifies sub paths under which the mypy configuration file may be found.
For each directory searched for the mypy config file, this also searches the sub paths
specified here.
'';
report_progress = helpers.defaultNullOpts.mkBool false ''
report_progress = defaultNullOpts.mkBool false ''
Report basic progress to the LSP client.
With this option, pylsp-mypy will report when mypy is running, given your editor supports
LSP progress reporting.
@ -390,7 +390,7 @@ in
};
isort = {
enabled = helpers.defaultNullOpts.mkBool false ''
enabled = defaultNullOpts.mkBool false ''
Enable or disable the plugin.
Setting this explicitly to `true` will install the dependency for this plugin
(pyls-isort).
@ -398,30 +398,30 @@ in
};
black = {
enabled = helpers.defaultNullOpts.mkBool false ''
enabled = defaultNullOpts.mkBool false ''
Enable or disable the plugin.
Setting this explicitly to `true` will install the dependency for this plugin
(python-lsp-black).
'';
cache_config = helpers.defaultNullOpts.mkBool false ''
cache_config = defaultNullOpts.mkBool false ''
Whether to enable black configuration caching.
'';
line_length = helpers.defaultNullOpts.mkInt 88 ''
line_length = defaultNullOpts.mkInt 88 ''
An integer that maps to black's max-line-length setting.
Defaults to 88 (same as black's default).
This can also be set through black's configuration files, which should be preferred for
multi-user projects.
'';
preview = helpers.defaultNullOpts.mkBool false ''
preview = defaultNullOpts.mkBool false ''
Enable or disable black's --preview setting.
'';
};
memestra = {
enabled = helpers.defaultNullOpts.mkBool false ''
enabled = defaultNullOpts.mkBool false ''
Enable or disable the plugin.
Setting this explicitly to `true` will install the dependency for this plugin
(pyls-memestra).
@ -429,7 +429,7 @@ in
};
rope = {
enabled = helpers.defaultNullOpts.mkBool false ''
enabled = defaultNullOpts.mkBool false ''
Enable or disable the plugin.
Setting this explicitly to `true` will install the dependency for this plugin
(pylsp-rope).
@ -437,45 +437,45 @@ in
};
ruff = {
enabled = helpers.defaultNullOpts.mkBool false ''
enabled = defaultNullOpts.mkBool false ''
Enable or disable the plugin.
Setting this explicitly to `true` will install the dependency for this plugin
(python-lsp-ruff).
'';
config = helpers.mkNullOrOption types.str "Path to optional pyproject.toml file.";
config = mkNullOrOption types.str "Path to optional pyproject.toml file.";
exclude = helpers.defaultNullOpts.mkListOf types.str [ ] ''
exclude = defaultNullOpts.mkListOf types.str [ ] ''
Exclude files from being checked by ruff.
'';
executable = helpers.mkNullOrOption types.str ''
executable = mkNullOrOption types.str ''
Path to the ruff executable. Assumed to be in PATH by default.
'';
ignore = helpers.defaultNullOpts.mkListOf types.str [ ] ''
ignore = defaultNullOpts.mkListOf types.str [ ] ''
Error codes to ignore.
'';
extendIgnore = helpers.defaultNullOpts.mkListOf types.str [ ] ''
extendIgnore = defaultNullOpts.mkListOf types.str [ ] ''
Same as ignore, but append to existing ignores.
'';
lineLength = helpers.mkNullOrOption types.int "Set the line-length for length checks.";
lineLength = mkNullOrOption types.int "Set the line-length for length checks.";
perFileIgnores = helpers.mkNullOrOption (with types; attrsOf (listOf str)) ''
perFileIgnores = mkNullOrOption (with types; attrsOf (listOf str)) ''
File-specific error codes to be ignored.
'';
select = helpers.defaultNullOpts.mkListOf types.str [ ] ''
select = defaultNullOpts.mkListOf types.str [ ] ''
List of error codes to enable.
'';
extendSelect = helpers.defaultNullOpts.mkListOf types.str [ ] ''
extendSelect = defaultNullOpts.mkListOf types.str [ ] ''
Same as select, but append to existing error codes.
'';
format = helpers.defaultNullOpts.mkListOf types.str [ ] ''
format = defaultNullOpts.mkListOf types.str [ ] ''
List of error codes to fix during formatting.
The default is ["I"], any additional codes are appended to this list.
'';
@ -485,11 +485,11 @@ in
};
rope = {
extensionModules = helpers.mkNullOrOption types.str ''
extensionModules = mkNullOrOption types.str ''
Builtin and c-extension modules that are allowed to be imported and inspected by rope.
'';
ropeFolder = helpers.mkNullOrOption (types.listOf types.str) ''
ropeFolder = mkNullOrOption (types.listOf types.str) ''
The name of the folder in which rope stores project configurations and data.
Pass null for not using such a folder at all.
'';
@ -497,7 +497,7 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
# WARNING: tricky stuff below:
# We need to fix the `python-lsp-server` derivation by adding all of the (user enabled)
# plugins to its `propagatedBuildInputs`.
@ -511,7 +511,7 @@ in
(map
(
pluginName:
(optionals (isEnabled plugins.${pluginName}) cfg.package.optional-dependencies.${pluginName})
(lib.optionals (isEnabled plugins.${pluginName}) cfg.package.optional-dependencies.${pluginName})
)
[
"autopep8"
@ -524,20 +524,20 @@ in
"yapf"
]
)
++ (optionals (
++ (lib.optionals (
(isEnabled plugins.rope_autoimport) || (isEnabled plugins.rope_completion)
) cfg.package.optional-dependencies.rope);
# All of those plugins have `python-lsp-server` as a dependency.
# We need to get rid of it to add them to the `python-lsp-server` derivation itself.
thirdPartyPlugins = lists.flatten (
mapAttrsToList
thirdPartyPlugins = lib.lists.flatten (
lib.mapAttrsToList
(
pluginName: nixPackage:
(optional (isEnabled plugins.${pluginName}) (
(lib.optional (isEnabled plugins.${pluginName}) (
nixPackage.overridePythonAttrs (old: {
# Get rid of the python-lsp-server dependency
dependencies = filter (dep: dep.pname != "python-lsp-server") old.dependencies;
dependencies = lib.filter (dep: dep.pname != "python-lsp-server") old.dependencies;
# Skip testing because those naked dependencies will complain about missing pylsp
doCheck = false;
@ -601,7 +601,7 @@ in
# Final list of pylsp plugins to install
pylspPlugins = nativePlugins ++ thirdPartyPlugins;
in
mkDefault (
lib.mkDefault (
# This is the final default package for pylsp
cfg.pythonPackage.pkgs.python-lsp-server.overridePythonAttrs (old: {
propagatedBuildInputs = pylspPlugins ++ old.dependencies;

View file

@ -1,44 +1,47 @@
# TODO: make all the types support raw lua
lib:
let
inherit (lib.nixvim) defaultNullOpts;
inherit (lib) types;
rustAnalyzerOptions = import ../../../generated/rust-analyzer.nix;
mkRustAnalyzerType =
{ kind, ... }@typeInfo:
if kind == "enum" then
lib.types.enum typeInfo.values
types.enum typeInfo.values
else if kind == "oneOf" then
lib.types.oneOf (lib.map mkRustAnalyzerType typeInfo.subTypes)
types.oneOf (lib.map mkRustAnalyzerType typeInfo.subTypes)
else if kind == "list" then
lib.types.listOf (mkRustAnalyzerType typeInfo.item)
types.listOf (mkRustAnalyzerType typeInfo.item)
else if kind == "number" then
let
inherit (typeInfo) minimum maximum;
in
if minimum != null && maximum != null then
lib.types.numbers.between minimum maximum
types.numbers.between minimum maximum
else if minimum != null then
lib.types.addCheck lib.types.number (x: x >= minimum)
types.addCheck types.number (x: x >= minimum)
else if maximum != null then
lib.types.addCheck lib.types.number (x: x <= maximum)
types.addCheck types.number (x: x <= maximum)
else
lib.types.number
types.number
else if kind == "integer" then
let
inherit (typeInfo) minimum maximum;
in
if minimum != null && maximum != null then
lib.types.ints.between minimum maximum
types.ints.between minimum maximum
else if minimum != null then
lib.types.addCheck lib.types.int (x: x >= minimum)
types.addCheck types.int (x: x >= minimum)
else if maximum != null then
lib.types.addCheck lib.types.int (x: x <= maximum)
types.addCheck types.int (x: x <= maximum)
else
lib.types.int
types.int
else if kind == "object" then
lib.types.attrsOf lib.types.anything
types.attrsOf types.anything
else if kind == "submodule" then
lib.types.submodule {
types.submodule {
options = lib.mapAttrs (
_: ty:
lib.mkOption {
@ -48,9 +51,9 @@ let
) typeInfo.options;
}
else if kind == "string" then
lib.types.str
types.str
else if kind == "boolean" then
lib.types.bool
types.bool
else
throw "Unknown type: ${kind}";
@ -60,7 +63,7 @@ let
pluginDefault,
type,
}:
lib.nixvim.defaultNullOpts.mkNullable' {
defaultNullOpts.mkNullable' {
inherit description pluginDefault;
type = mkRustAnalyzerType type;
};
@ -72,8 +75,8 @@ let
in
lib.setAttrByPath parts value;
nestedNixOptions = lib.attrsets.mapAttrsToList (
nestedNixOptions = lib.mapAttrsToList (
name: value: nestOpt name (mkNixOption value)
) rustAnalyzerOptions;
in
(builtins.foldl' lib.attrsets.recursiveUpdate { } nestedNixOptions).rust-analyzer
(builtins.foldl' lib.recursiveUpdate { } nestedNixOptions).rust-analyzer

View file

@ -4,26 +4,26 @@
pkgs,
...
}:
with lib;
let
cfg = config.plugins.lsp.servers.rust_analyzer;
inherit (lib) mkPackageOption types;
inherit (lib.nixvim) mkNullOrOption';
in
{
options.plugins.lsp.servers.rust_analyzer = {
# https://github.com/nix-community/nixvim/issues/674
installCargo = mkOption {
type = with types; nullOr bool;
default = null;
installCargo = mkNullOrOption' {
type = types.bool;
example = true;
description = "Whether to install `cargo`.";
};
# TODO: make nullable?
cargoPackage = mkPackageOption pkgs "cargo" { };
cargoPackage = lib.mkPackageOption pkgs "cargo" { };
installRustc = mkOption {
type = with types; nullOr bool;
default = null;
installRustc = mkNullOrOption' {
type = types.bool;
example = true;
description = "Whether to install `rustc`.";
};
@ -31,9 +31,8 @@ in
# TODO: make nullable
rustcPackage = mkPackageOption pkgs "rustc" { };
installRustfmt = mkOption {
type = with types; nullOr bool;
default = null;
installRustfmt = mkNullOrOption' {
type = types.bool;
example = true;
description = "Whether to install `rustfmt`.";
};
@ -41,9 +40,9 @@ in
# TODO: make nullable
rustfmtPackage = mkPackageOption pkgs "rustfmt" { };
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
warnings =
(optional (cfg.installCargo == null) ''
(lib.optional (cfg.installCargo == null) ''
`rust_analyzer` relies on `cargo`.
- Set `plugins.lsp.servers.rust_analyzer.installCargo = true` to install it automatically
with Nixvim.
@ -53,7 +52,7 @@ in
through Nixvim.
By doing so, you will dismiss this warning.
'')
++ (optional (cfg.installRustc == null) ''
++ (lib.optional (cfg.installRustc == null) ''
`rust_analyzer` relies on `rustc`.
- Set `plugins.lsp.servers.rust_analyzer.installRustc = true` to install it automatically
with Nixvim.
@ -65,9 +64,11 @@ in
'');
extraPackages =
with pkgs;
optional (isBool cfg.installCargo && cfg.installCargo) cfg.cargoPackage
++ optional (isBool cfg.installRustc && cfg.installRustc) cfg.rustcPackage
++ optional (isBool cfg.installRustfmt && cfg.installRustfmt) cfg.rustfmtPackage;
let
isEnabled = x: lib.isBool x && x;
in
lib.optional (isEnabled cfg.installCargo) cfg.cargoPackage
++ lib.optional (isEnabled cfg.installRustc) cfg.rustcPackage
++ lib.optional (isEnabled cfg.installRustfmt) cfg.rustfmtPackage;
};
}

View file

@ -1,12 +1,12 @@
{
lib,
helpers,
config,
...
}:
with lib;
let
cfg = config.plugins.lsp.servers.svelte;
inherit (lib.nixvim) defaultNullOpts mkNullOrOption;
inherit (lib) types;
in
{
# Options: https://github.com/sveltejs/language-tools/tree/master/packages/language-server#settings
@ -14,161 +14,161 @@ in
svelte = {
plugin = {
typescript = {
enable = helpers.defaultNullOpts.mkBool true "Enable the TypeScript plugin.";
enable = defaultNullOpts.mkBool true "Enable the TypeScript plugin.";
diagnostics = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable diagnostic messages for TypeScript.
'';
};
hover = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable hover info for TypeScript.
'';
};
documentSymbols = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable document symbols for TypeScript.
'';
};
completions = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable completions for TypeScript.
'';
};
codeActions = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable code actions for TypeScript.
'';
};
selectionRange = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable selection range for TypeScript.
'';
};
signatureHelp = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable signature help (parameter hints) for JS/TS.
'';
};
semanticTokens = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable semantic tokens (semantic highlight) for TypeScript.
'';
};
};
css = {
enable = helpers.defaultNullOpts.mkBool true "Enable the CSS plugin.";
enable = defaultNullOpts.mkBool true "Enable the CSS plugin.";
globals = helpers.mkNullOrOption types.str ''
globals = mkNullOrOption types.str ''
Which css files should be checked for global variables (`--global-var: value;`).
These variables are added to the css completions.
String of comma-separated file paths or globs relative to workspace root.
'';
diagnostics = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable diagnostic messages for CSS.
'';
};
hover = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable hover info for CSS.
'';
};
completions = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable completions for CSS.
'';
emmet = helpers.defaultNullOpts.mkBool true ''
emmet = defaultNullOpts.mkBool true ''
Enable emmet auto completions for CSS.
'';
};
documentColors = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable document colors for CSS.
'';
};
colorPresentations = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable color picker for CSS.
'';
};
documentSymbols = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable document symbols for CSS.
'';
};
selectionRange = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable selection range for CSS.
'';
};
};
html = {
enable = helpers.defaultNullOpts.mkBool true "Enable the HTML plugin.";
enable = defaultNullOpts.mkBool true "Enable the HTML plugin.";
hover = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable hover info for HTML.
'';
};
completions = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable completions for HTML.
'';
emmet = helpers.defaultNullOpts.mkBool true ''
emmet = defaultNullOpts.mkBool true ''
Enable emmet auto completions for HTML.
'';
};
tagComplete = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable tag auto closing.
'';
};
documentSymbols = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable document symbols for HTML.
'';
};
linkedEditing = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable Linked Editing for HTML.
'';
};
};
svelte = {
enable = helpers.defaultNullOpts.mkBool true "Enable the Svelte plugin.";
enable = defaultNullOpts.mkBool true "Enable the Svelte plugin.";
diagnostics = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable diagnostic messages for Svelte.
'';
};
compilerWarnings = helpers.mkNullOrOption (with types; attrsOf str) ''
compilerWarnings = mkNullOrOption (with types; attrsOf str) ''
Svelte compiler warning codes to ignore or to treat as errors.
Example:
```
@ -179,7 +179,7 @@ in
'';
format = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable formatting for Svelte (includes css & js) using `prettier-plugin-svelte`.
You can set some formatting options through this extension.
@ -188,21 +188,21 @@ in
'';
config = {
svelteSortOrder = helpers.defaultNullOpts.mkStr "options-scripts-markup-styles" ''
svelteSortOrder = defaultNullOpts.mkStr "options-scripts-markup-styles" ''
Format: join the keys `options`, `scripts`, `markup`, `styles` with a `-` in the
order you want.
This option is ignored if there's any kind of configuration file, for example a
`.prettierrc` file.
'';
svelteStrictMode = helpers.defaultNullOpts.mkBool false ''
svelteStrictMode = defaultNullOpts.mkBool false ''
More strict HTML syntax.
This option is ignored if there's any kind of configuration file, for example a
`.prettierrc` file.
'';
svelteAllowShorthand = helpers.defaultNullOpts.mkBool true ''
svelteAllowShorthand = defaultNullOpts.mkBool true ''
Option to enable/disable component attribute shorthand if attribute name and
expression are the same.
@ -210,21 +210,21 @@ in
`.prettierrc` file.
'';
svelteBracketNewLine = helpers.defaultNullOpts.mkBool true ''
svelteBracketNewLine = defaultNullOpts.mkBool true ''
Put the `>` of a multiline element on a new line.
This option is ignored if there's any kind of configuration file, for example a
`.prettierrc` file.
'';
svelteIndentScriptAndStyle = helpers.defaultNullOpts.mkBool true ''
svelteIndentScriptAndStyle = defaultNullOpts.mkBool true ''
Whether or not to indent code inside `<script>` and `<style>` tags.
This option is ignored if there's any kind of configuration file, for example a
`.prettierrc` file.
'';
printWidth = helpers.defaultNullOpts.mkInt 80 ''
printWidth = defaultNullOpts.mkInt 80 ''
Maximum line width after which code is tried to be broken up.
This is a Prettier core option.
@ -234,7 +234,7 @@ in
`.prettierrc` file.
'';
singleQuote = helpers.defaultNullOpts.mkBool false ''
singleQuote = defaultNullOpts.mkBool false ''
Use single quotes instead of double quotes, where possible.
This is a Prettier core option.
@ -247,37 +247,37 @@ in
};
hover = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable hover info for Svelte (for tags like `#if`/`#each`).
'';
};
completions = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable completions for TypeScript.
Enable autocompletion for Svelte (for tags like `#if`/`#each`).
'';
};
rename = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable rename/move Svelte files functionality.
'';
};
codeActions = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable code actions for Svelte.
'';
};
selectionRange = {
enable = helpers.defaultNullOpts.mkBool true ''
enable = defaultNullOpts.mkBool true ''
Enable selection range for Svelte.
'';
};
defaultScriptLanguage = helpers.mkNullOrOption types.str ''
defaultScriptLanguage = mkNullOrOption types.str ''
The default language to use when generating new script tags in Svelte.
'';
};
@ -285,7 +285,7 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
plugins.lsp.servers.svelte.extraOptions.init_options = {
configuration = cfg.initOptions;
};