mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-01 04:44:31 +02:00
treewide: Reformat with nixfmt
This commit is contained in:
parent
c6281260dc
commit
62f32bfc71
459 changed files with 28139 additions and 26377 deletions
|
@ -4,9 +4,11 @@
|
|||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp.servers.ccls;
|
||||
in {
|
||||
in
|
||||
{
|
||||
# Options: https://github.com/MaskRay/ccls/wiki/Customization#initialization-options
|
||||
options.plugins.lsp.servers.ccls.initOptions = {
|
||||
cache = {
|
||||
|
@ -42,20 +44,28 @@ in {
|
|||
use a JSON formatter such as `jq . < /tmp/ccls/@tmp@c/a.cc.json` to display it.
|
||||
'';
|
||||
|
||||
retainInMemory = helpers.defaultNullOpts.mkEnum [0 1 2] "1" ''
|
||||
Change to 0 if you want to save memory, but having multiple ccls processes operating in the
|
||||
same directory may corrupt ccls's in-memory representation of the index.
|
||||
retainInMemory =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
[
|
||||
0
|
||||
1
|
||||
2
|
||||
]
|
||||
"1"
|
||||
''
|
||||
Change to 0 if you want to save memory, but having multiple ccls processes operating in the
|
||||
same directory may corrupt ccls's in-memory representation of the index.
|
||||
|
||||
After this number of loads, keep a copy of file index in memory (which increases memory
|
||||
usage).
|
||||
During incremental updates, the removed file index will be taken from the in-memory copy,
|
||||
instead of the on-disk file.
|
||||
After this number of loads, keep a copy of file index in memory (which increases memory
|
||||
usage).
|
||||
During incremental updates, the removed file index will be taken from the in-memory copy,
|
||||
instead of the on-disk file.
|
||||
|
||||
Every index action is counted: the initial load, a save action.
|
||||
- 0: never retain
|
||||
- 1: retain after initial load
|
||||
- 2: retain after 2 loads (initial load+first save)
|
||||
'';
|
||||
Every index action is counted: the initial load, a save action.
|
||||
- 0: never retain
|
||||
- 1: retain after initial load
|
||||
- 2: retain after 2 loads (initial load+first save)
|
||||
'';
|
||||
};
|
||||
|
||||
clang = {
|
||||
|
@ -189,30 +199,45 @@ in {
|
|||
If you want to reduce peak CPU and memory usage, set it to a small integer.
|
||||
'';
|
||||
|
||||
comments = helpers.defaultNullOpts.mkEnum [0 1 2] "2" ''
|
||||
`ccls` can index the contents of comments associated with functions/types/variables (macros
|
||||
are not handled).
|
||||
This value controls how comments are indexed:
|
||||
- `0`: don't index comments
|
||||
- `1`: index Doxygen comment markers
|
||||
- `2`: use `-fparse-all-comments` and recognize plain `//` `/* */` in addition to Doxygen
|
||||
comment markers
|
||||
'';
|
||||
comments =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
[
|
||||
0
|
||||
1
|
||||
2
|
||||
]
|
||||
"2"
|
||||
''
|
||||
`ccls` can index the contents of comments associated with functions/types/variables (macros
|
||||
are not handled).
|
||||
This value controls how comments are indexed:
|
||||
- `0`: don't index comments
|
||||
- `1`: index Doxygen comment markers
|
||||
- `2`: use `-fparse-all-comments` and recognize plain `//` `/* */` in addition to Doxygen
|
||||
comment markers
|
||||
'';
|
||||
|
||||
multiVersion = helpers.defaultNullOpts.mkEnum [0 1] "0" ''
|
||||
Index a file only once (`0`), or in each translation unit that includes it (`1`).
|
||||
multiVersion =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
[
|
||||
0
|
||||
1
|
||||
]
|
||||
"0"
|
||||
''
|
||||
Index a file only once (`0`), or in each translation unit that includes it (`1`).
|
||||
|
||||
The default is sensible for common usage: it reduces memory footprint.
|
||||
If both `a.cc` and `b.cc` include `a.h`, there is only one indexed version of `a.h`.
|
||||
The default is sensible for common usage: it reduces memory footprint.
|
||||
If both `a.cc` and `b.cc` include `a.h`, there is only one indexed version of `a.h`.
|
||||
|
||||
But for dependent name lookup, or references in headers that may change depending on other
|
||||
macros, etc, you may want to index a file multiple times to get every possible cross
|
||||
reference.
|
||||
In that case set the option to `1` but be aware that it may increase index file sizes
|
||||
significantly.
|
||||
But for dependent name lookup, or references in headers that may change depending on other
|
||||
macros, etc, you may want to index a file multiple times to get every possible cross
|
||||
reference.
|
||||
In that case set the option to `1` but be aware that it may increase index file sizes
|
||||
significantly.
|
||||
|
||||
Also consider using `index.multiVersionBlacklist` to exclude system headers.
|
||||
'';
|
||||
Also consider using `index.multiVersionBlacklist` to exclude system headers.
|
||||
'';
|
||||
|
||||
multiVersionBlacklist = helpers.defaultNullOpts.mkNullable (with types; listOf str) "[]" ''
|
||||
A list of regular expressions matching files that should not be indexed via multi-version
|
||||
|
@ -250,24 +275,28 @@ in {
|
|||
cache files to disk.
|
||||
'';
|
||||
|
||||
trackDependency = helpers.defaultNullOpts.mkEnum [0 1 2] "2" ''
|
||||
Determine whether a file should be re-indexed when any of its dependencies changes
|
||||
timestamp.
|
||||
trackDependency =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
[
|
||||
0
|
||||
1
|
||||
2
|
||||
]
|
||||
"2"
|
||||
''
|
||||
Determine whether a file should be re-indexed when any of its dependencies changes
|
||||
timestamp.
|
||||
|
||||
If `a.h` has been changed, when you open `a.cc` which includes `a.h` then if
|
||||
`trackDependency` is:
|
||||
If `a.h` has been changed, when you open `a.cc` which includes `a.h` then if
|
||||
`trackDependency` is:
|
||||
|
||||
- 0: no re-indexing unless `a.cc` itself changes timestamp.
|
||||
- 2: the index of `a.cc` is considered stale and it should be re-indexed.
|
||||
- 1: before the initial load, the behavior of `2` is used, otherwise the behavior of `0` is
|
||||
used.
|
||||
'';
|
||||
- 0: no re-indexing unless `a.cc` itself changes timestamp.
|
||||
- 2: the index of `a.cc` is considered stale and it should be re-indexed.
|
||||
- 1: before the initial load, the behavior of `2` is used, otherwise the behavior of `0` is
|
||||
used.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
mkIf cfg.enable
|
||||
{
|
||||
plugins.lsp.servers.ccls.extraOptions.init_options = cfg.initOptions;
|
||||
};
|
||||
config = mkIf cfg.enable { plugins.lsp.servers.ccls.extraOptions.init_options = cfg.initOptions; };
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
{ lib, helpers }:
|
||||
with lib;
|
||||
{
|
||||
lib,
|
||||
helpers,
|
||||
}:
|
||||
with lib; {
|
||||
analysisExcludedFolders = helpers.mkNullOrOption (with types; listOf str) ''
|
||||
An array of paths (absolute or relative to each workspace folder) that should be excluded from
|
||||
analysis.
|
||||
|
@ -27,15 +25,21 @@ with lib; {
|
|||
If unspecified, diagnostics will not be generated.
|
||||
'';
|
||||
|
||||
renameFilesWithClasses = helpers.mkNullOrOption (types.enum ["always" "prompt"]) ''
|
||||
When set to "always", will include edits to rename files when classes are renamed if the
|
||||
filename matches the class name (but in snake_form).
|
||||
When set to "prompt", a prompt will be shown on each class rename asking to confirm the file
|
||||
rename.
|
||||
Otherwise, files will not be renamed.
|
||||
Renames are performed using LSP's `ResourceOperation` edits - that means the rename is simply
|
||||
included in the resulting `WorkspaceEdit` and must be handled by the client.
|
||||
'';
|
||||
renameFilesWithClasses =
|
||||
helpers.mkNullOrOption
|
||||
(types.enum [
|
||||
"always"
|
||||
"prompt"
|
||||
])
|
||||
''
|
||||
When set to "always", will include edits to rename files when classes are renamed if the
|
||||
filename matches the class name (but in snake_form).
|
||||
When set to "prompt", a prompt will be shown on each class rename asking to confirm the file
|
||||
rename.
|
||||
Otherwise, files will not be renamed.
|
||||
Renames are performed using LSP's `ResourceOperation` edits - that means the rename is simply
|
||||
included in the resulting `WorkspaceEdit` and must be handled by the client.
|
||||
'';
|
||||
|
||||
enableSnippets = helpers.mkNullOrOption types.bool ''
|
||||
Whether to include code snippets (such as class, stful, switch) in code completion.
|
||||
|
@ -47,11 +51,18 @@ with lib; {
|
|||
When unspecified, imports will be updated if the client supports `willRenameFiles` requests.
|
||||
'';
|
||||
|
||||
documentation = helpers.mkNullOrOption (types.enum ["none" "summary" "full"]) ''
|
||||
The typekind of dartdocs to include in Hovers, Code Completion, Signature Help and other similar
|
||||
requests.
|
||||
If not set, defaults to `"full"`.
|
||||
'';
|
||||
documentation =
|
||||
helpers.mkNullOrOption
|
||||
(types.enum [
|
||||
"none"
|
||||
"summary"
|
||||
"full"
|
||||
])
|
||||
''
|
||||
The typekind of dartdocs to include in Hovers, Code Completion, Signature Help and other similar
|
||||
requests.
|
||||
If not set, defaults to `"full"`.
|
||||
'';
|
||||
|
||||
includeDependenciesInWorkspaceSymbols = helpers.mkNullOrOption types.bool ''
|
||||
Whether to include symbols from dependencies and Dart/Flutter SDKs in Workspace Symbol results.
|
||||
|
|
|
@ -5,15 +5,19 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
lspHelpers = import ../helpers.nix {inherit lib config pkgs;};
|
||||
with lib;
|
||||
let
|
||||
lspHelpers = import ../helpers.nix { inherit lib config pkgs; };
|
||||
|
||||
servers = [
|
||||
{
|
||||
name = "ansiblels";
|
||||
description = "ansiblels for Ansible";
|
||||
package = pkgs.ansible-language-server;
|
||||
cmd = cfg: ["${cfg.package}/bin/ansible-language-server" "--stdio"];
|
||||
cmd = cfg: [
|
||||
"${cfg.package}/bin/ansible-language-server"
|
||||
"--stdio"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "ast-grep";
|
||||
|
@ -27,7 +31,10 @@ with lib; let
|
|||
name = "astro";
|
||||
description = "astrols for Astro";
|
||||
package = pkgs.nodePackages."@astrojs/language-server";
|
||||
cmd = cfg: ["${cfg.package}/bin/astro-ls" "--stdio"];
|
||||
cmd = cfg: [
|
||||
"${cfg.package}/bin/astro-ls"
|
||||
"--stdio"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "bashls";
|
||||
|
@ -73,7 +80,10 @@ with lib; let
|
|||
name = "cssls";
|
||||
description = "cssls for CSS";
|
||||
package = pkgs.vscode-langservers-extracted;
|
||||
cmd = cfg: ["${cfg.package}/bin/vscode-css-language-server" "--stdio"];
|
||||
cmd = cfg: [
|
||||
"${cfg.package}/bin/vscode-css-language-server"
|
||||
"--stdio"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "dagger";
|
||||
|
@ -84,8 +94,8 @@ with lib; let
|
|||
name = "dartls";
|
||||
description = "dart language-server";
|
||||
package = pkgs.dart;
|
||||
settingsOptions = import ./dartls-settings.nix {inherit lib helpers;};
|
||||
settings = cfg: {dart = cfg;};
|
||||
settingsOptions = import ./dartls-settings.nix { inherit lib helpers; };
|
||||
settings = cfg: { dart = cfg; };
|
||||
}
|
||||
{
|
||||
name = "denols";
|
||||
|
@ -112,7 +122,10 @@ with lib; let
|
|||
name = "dockerls";
|
||||
description = "dockerls for Dockerfile";
|
||||
package = pkgs.dockerfile-language-server-nodejs;
|
||||
cmd = cfg: ["${cfg.package}/bin/docker-langserver" "--stdio"];
|
||||
cmd = cfg: [
|
||||
"${cfg.package}/bin/docker-langserver"
|
||||
"--stdio"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "efm";
|
||||
|
@ -132,12 +145,15 @@ with lib; let
|
|||
{
|
||||
name = "eslint";
|
||||
package = pkgs.vscode-langservers-extracted;
|
||||
cmd = cfg: ["${cfg.package}/bin/vscode-eslint-language-server" "--stdio"];
|
||||
cmd = cfg: [
|
||||
"${cfg.package}/bin/vscode-eslint-language-server"
|
||||
"--stdio"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "elixirls";
|
||||
package = pkgs.elixir-ls;
|
||||
cmd = cfg: ["${cfg.package}/bin/elixir-ls"];
|
||||
cmd = cfg: [ "${cfg.package}/bin/elixir-ls" ];
|
||||
}
|
||||
{
|
||||
name = "fortls";
|
||||
|
@ -193,13 +209,19 @@ with lib; let
|
|||
name = "hls";
|
||||
description = "haskell language server";
|
||||
package = pkgs.haskell-language-server;
|
||||
cmd = cfg: ["haskell-language-server-wrapper" "--lsp"];
|
||||
cmd = cfg: [
|
||||
"haskell-language-server-wrapper"
|
||||
"--lsp"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "html";
|
||||
description = "HTML language server from `vscode-langservers-extracted`";
|
||||
package = pkgs.vscode-langservers-extracted;
|
||||
cmd = cfg: ["${cfg.package}/bin/vscode-html-language-server" "--stdio"];
|
||||
cmd = cfg: [
|
||||
"${cfg.package}/bin/vscode-html-language-server"
|
||||
"--stdio"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "htmx";
|
||||
|
@ -215,13 +237,16 @@ with lib; let
|
|||
name = "java-language-server";
|
||||
description = "Java language server";
|
||||
serverName = "java_language_server";
|
||||
cmd = cfg: ["${cfg.package}/bin/java-language-server"];
|
||||
cmd = cfg: [ "${cfg.package}/bin/java-language-server" ];
|
||||
}
|
||||
{
|
||||
name = "jsonls";
|
||||
description = "jsonls for JSON";
|
||||
package = pkgs.vscode-langservers-extracted;
|
||||
cmd = cfg: ["${cfg.package}/bin/vscode-json-language-server" "--stdio"];
|
||||
cmd = cfg: [
|
||||
"${cfg.package}/bin/vscode-json-language-server"
|
||||
"--stdio"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "julials";
|
||||
|
@ -252,8 +277,8 @@ with lib; let
|
|||
name = "ltex";
|
||||
description = "ltex-ls for LanguageTool";
|
||||
package = pkgs.ltex-ls;
|
||||
settingsOptions = import ./ltex-settings.nix {inherit lib helpers;};
|
||||
settings = cfg: {ltex = cfg;};
|
||||
settingsOptions = import ./ltex-settings.nix { inherit lib helpers; };
|
||||
settings = cfg: { ltex = cfg; };
|
||||
}
|
||||
{
|
||||
name = "lua-ls";
|
||||
|
@ -261,9 +286,10 @@ with lib; let
|
|||
# Use the old name of the lua LS if the user is on a stable branch of nixpkgs
|
||||
# Rename occurred here: https://github.com/NixOS/nixpkgs/pull/215057
|
||||
package =
|
||||
if (hasAttr "lua-language-server" pkgs)
|
||||
then pkgs.lua-language-server
|
||||
else pkgs.sumneko-lua-language-server;
|
||||
if (hasAttr "lua-language-server" pkgs) then
|
||||
pkgs.lua-language-server
|
||||
else
|
||||
pkgs.sumneko-lua-language-server;
|
||||
serverName = "lua_ls";
|
||||
|
||||
# All available settings are documented here:
|
||||
|
@ -285,17 +311,12 @@ with lib; let
|
|||
description = ''
|
||||
An array of variable names that will be declared as global.
|
||||
'';
|
||||
default = ["vim"];
|
||||
default = [ "vim" ];
|
||||
};
|
||||
};
|
||||
workspace = {
|
||||
library = mkOption {
|
||||
type = with types;
|
||||
nullOr
|
||||
(
|
||||
listOf
|
||||
(either str helpers.nixvimTypes.rawLua)
|
||||
);
|
||||
type = with types; nullOr (listOf (either str helpers.nixvimTypes.rawLua));
|
||||
description = ''
|
||||
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.
|
||||
|
@ -303,7 +324,7 @@ with lib; let
|
|||
Files included here will have some features disabled such as renaming fields to
|
||||
prevent accidentally renaming your library files.
|
||||
'';
|
||||
default = [(helpers.mkRaw "vim.api.nvim_get_runtime_file('', true)")];
|
||||
default = [ (helpers.mkRaw "vim.api.nvim_get_runtime_file('', true)") ];
|
||||
};
|
||||
checkThirdParty = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
|
@ -321,7 +342,7 @@ with lib; let
|
|||
enable = mkEnableOption "telemetry";
|
||||
};
|
||||
};
|
||||
settings = cfg: {Lua = cfg;};
|
||||
settings = cfg: { Lua = cfg; };
|
||||
}
|
||||
{
|
||||
name = "marksman";
|
||||
|
@ -353,7 +374,7 @@ with lib; let
|
|||
diagnostics = {
|
||||
ignored = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
default = [ ];
|
||||
description = ''
|
||||
Ignored diagnostic kinds.
|
||||
The kind identifier is a snake_cased_string usually shown together
|
||||
|
@ -362,7 +383,7 @@ with lib; let
|
|||
};
|
||||
excludedFiles = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
default = [ ];
|
||||
description = ''
|
||||
Files to exclude from showing diagnostics. Useful for generated files.
|
||||
It accepts an array of paths. Relative paths are joint to the workspace root.
|
||||
|
@ -371,7 +392,11 @@ with lib; let
|
|||
};
|
||||
};
|
||||
};
|
||||
settings = cfg: {nil = {inherit (cfg) formatting diagnostics;};};
|
||||
settings = cfg: {
|
||||
nil = {
|
||||
inherit (cfg) formatting diagnostics;
|
||||
};
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "nimls";
|
||||
|
@ -382,12 +407,15 @@ with lib; let
|
|||
name = "nixd";
|
||||
description = "nixd for Nix";
|
||||
package = pkgs.nixd;
|
||||
settings = cfg: {nixd = cfg;};
|
||||
settings = cfg: { nixd = cfg; };
|
||||
}
|
||||
{
|
||||
name = "nushell";
|
||||
description = "Nushell language server";
|
||||
cmd = cfg: ["${cfg.package}/bin/nu" "--lsp"];
|
||||
cmd = cfg: [
|
||||
"${cfg.package}/bin/nu"
|
||||
"--lsp"
|
||||
];
|
||||
}
|
||||
{
|
||||
name = "ocamllsp";
|
||||
|
@ -403,8 +431,8 @@ with lib; let
|
|||
name = "omnisharp";
|
||||
description = "OmniSharp language server for C#";
|
||||
package = pkgs.omnisharp-roslyn;
|
||||
cmd = cfg: ["${cfg.package}/bin/OmniSharp"];
|
||||
settings = cfg: {omnisharp = cfg;};
|
||||
cmd = cfg: [ "${cfg.package}/bin/OmniSharp" ];
|
||||
settings = cfg: { omnisharp = cfg; };
|
||||
settingsOptions = {
|
||||
enableEditorConfigSupport = helpers.defaultNullOpts.mkBool true ''
|
||||
Enables support for reading code style, naming convention and analyzer settings from
|
||||
|
@ -488,7 +516,7 @@ with lib; let
|
|||
name = "pylsp";
|
||||
description = "pylsp for Python";
|
||||
package = pkgs.python3Packages.python-lsp-server;
|
||||
settings = cfg: {pylsp = cfg;};
|
||||
settings = cfg: { pylsp = cfg; };
|
||||
}
|
||||
{
|
||||
name = "pylyzer";
|
||||
|
@ -520,7 +548,7 @@ with lib; let
|
|||
serverName = "rust_analyzer";
|
||||
|
||||
settingsOptions = import ./rust-analyzer-config.nix lib pkgs;
|
||||
settings = cfg: {rust-analyzer = cfg;};
|
||||
settings = cfg: { rust-analyzer = cfg; };
|
||||
}
|
||||
{
|
||||
name = "slint-lsp";
|
||||
|
@ -627,16 +655,15 @@ with lib; let
|
|||
description = "zls for Zig";
|
||||
}
|
||||
];
|
||||
in {
|
||||
imports =
|
||||
lib.lists.map lspHelpers.mkLsp servers
|
||||
++ [
|
||||
./ccls.nix
|
||||
./efmls-configs.nix
|
||||
./nixd.nix
|
||||
./pylsp.nix
|
||||
./rust-analyzer.nix
|
||||
./svelte.nix
|
||||
./vls.nix
|
||||
];
|
||||
in
|
||||
{
|
||||
imports = lib.lists.map lspHelpers.mkLsp servers ++ [
|
||||
./ccls.nix
|
||||
./efmls-configs.nix
|
||||
./nixd.nix
|
||||
./pylsp.nix
|
||||
./rust-analyzer.nix
|
||||
./svelte.nix
|
||||
./vls.nix
|
||||
];
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
tools = trivial.importJSON "${pkgs.vimPlugins.efmls-configs-nvim.src}/doc/supported-list.json";
|
||||
|
||||
languages = builtins.attrNames tools;
|
||||
|
@ -71,15 +72,13 @@ with lib; let
|
|||
yamllint
|
||||
yapf
|
||||
;
|
||||
inherit
|
||||
(python3.pkgs)
|
||||
inherit (python3.pkgs)
|
||||
autopep8
|
||||
flake8
|
||||
mdformat
|
||||
vulture
|
||||
;
|
||||
inherit
|
||||
(nodePackages)
|
||||
inherit (nodePackages)
|
||||
eslint
|
||||
eslint_d
|
||||
prettier
|
||||
|
@ -89,20 +88,9 @@ with lib; let
|
|||
textlint
|
||||
write-good
|
||||
;
|
||||
inherit
|
||||
(phpPackages)
|
||||
phan
|
||||
phpstan
|
||||
psalm
|
||||
;
|
||||
inherit
|
||||
(luaPackages)
|
||||
luacheck
|
||||
;
|
||||
inherit
|
||||
(haskellPackages)
|
||||
fourmolu
|
||||
;
|
||||
inherit (phpPackages) phan phpstan psalm;
|
||||
inherit (luaPackages) luacheck;
|
||||
inherit (haskellPackages) fourmolu;
|
||||
ansible_lint = ansible-lint;
|
||||
chktex = texliveMedium;
|
||||
clang_format = clang-tools;
|
||||
|
@ -134,85 +122,86 @@ with lib; let
|
|||
yq = yq-go;
|
||||
};
|
||||
# Filter packages that are not compatible with the current platform
|
||||
toolPkgs =
|
||||
filterAttrs
|
||||
(
|
||||
a: pkg:
|
||||
meta.availableOn
|
||||
pkgs.stdenv.hostPlatform
|
||||
pkg
|
||||
)
|
||||
allToolPkgs;
|
||||
in {
|
||||
toolPkgs = filterAttrs (a: pkg: meta.availableOn pkgs.stdenv.hostPlatform pkg) allToolPkgs;
|
||||
in
|
||||
{
|
||||
options.plugins.efmls-configs = {
|
||||
enable = mkEnableOption "efmls-configs, premade configurations for efm-langserver";
|
||||
|
||||
package = helpers.mkPackageOption "efmls-configs-nvim" pkgs.vimPlugins.efmls-configs-nvim;
|
||||
|
||||
externallyManagedPackages = mkOption {
|
||||
type = types.either (types.enum ["all"]) (types.listOf types.str);
|
||||
type = types.either (types.enum [ "all" ]) (types.listOf types.str);
|
||||
description = ''
|
||||
Linters/Formatters to skip installing with nixvim. Set to `all` to install no packages
|
||||
'';
|
||||
default = [];
|
||||
default = [ ];
|
||||
};
|
||||
|
||||
toolPackages = attrsets.mapAttrs (tool: pkg:
|
||||
toolPackages = attrsets.mapAttrs (
|
||||
tool: pkg:
|
||||
mkOption {
|
||||
type = types.package;
|
||||
default = pkg;
|
||||
description = "Package for ${tool}";
|
||||
})
|
||||
toolPkgs;
|
||||
}
|
||||
) toolPkgs;
|
||||
|
||||
/*
|
||||
Users can set the options as follows:
|
||||
Users can set the options as follows:
|
||||
|
||||
{
|
||||
c = {
|
||||
linter = "cppcheck";
|
||||
formatter = ["clang-format" "uncrustify"];
|
||||
};
|
||||
go = {
|
||||
linter = ["djlint" "golangci_lint"];
|
||||
};
|
||||
}
|
||||
*/
|
||||
setup = let
|
||||
languageTools = lang: kind:
|
||||
builtins.map (v: v.name) (
|
||||
if builtins.hasAttr kind tools.${lang}
|
||||
then tools.${lang}.${kind}
|
||||
else []
|
||||
);
|
||||
|
||||
miscLinters = languageTools "misc" "linters";
|
||||
miscFormatters = languageTools "misc" "formatters";
|
||||
|
||||
mkChooseOption = lang: kind: possible: let
|
||||
toolType = with types; either (enum possible) helpers.nixvimTypes.rawLua;
|
||||
in
|
||||
mkOption {
|
||||
type = with types; either toolType (listOf toolType);
|
||||
default = [];
|
||||
description = "${kind} tools for ${lang}";
|
||||
{
|
||||
c = {
|
||||
linter = "cppcheck";
|
||||
formatter = ["clang-format" "uncrustify"];
|
||||
};
|
||||
in
|
||||
go = {
|
||||
linter = ["djlint" "golangci_lint"];
|
||||
};
|
||||
}
|
||||
*/
|
||||
setup =
|
||||
let
|
||||
languageTools =
|
||||
lang: kind:
|
||||
builtins.map (v: v.name) (
|
||||
if builtins.hasAttr kind tools.${lang} then tools.${lang}.${kind} else [ ]
|
||||
);
|
||||
|
||||
miscLinters = languageTools "misc" "linters";
|
||||
miscFormatters = languageTools "misc" "formatters";
|
||||
|
||||
mkChooseOption =
|
||||
lang: kind: possible:
|
||||
let
|
||||
toolType = with types; either (enum possible) helpers.nixvimTypes.rawLua;
|
||||
in
|
||||
mkOption {
|
||||
type = with types; either toolType (listOf toolType);
|
||||
default = [ ];
|
||||
description = "${kind} tools for ${lang}";
|
||||
};
|
||||
in
|
||||
mkOption {
|
||||
type = types.submodule {
|
||||
freeformType = types.attrs;
|
||||
|
||||
options =
|
||||
(builtins.listToAttrs (builtins.map (lang: let
|
||||
langTools = languageTools lang;
|
||||
in {
|
||||
name = lang;
|
||||
value = {
|
||||
linter = mkChooseOption lang "linter" ((langTools "linters") ++ miscLinters);
|
||||
formatter = mkChooseOption lang "formatter" ((langTools "formatters") ++ miscFormatters);
|
||||
};
|
||||
})
|
||||
languages))
|
||||
(builtins.listToAttrs (
|
||||
builtins.map (
|
||||
lang:
|
||||
let
|
||||
langTools = languageTools lang;
|
||||
in
|
||||
{
|
||||
name = lang;
|
||||
value = {
|
||||
linter = mkChooseOption lang "linter" ((langTools "linters") ++ miscLinters);
|
||||
formatter = mkChooseOption lang "formatter" ((langTools "formatters") ++ miscFormatters);
|
||||
};
|
||||
}
|
||||
) languages
|
||||
))
|
||||
// {
|
||||
all = {
|
||||
linter = mkChooseOption "all languages" "linter" miscLinters;
|
||||
|
@ -221,67 +210,69 @@ in {
|
|||
};
|
||||
};
|
||||
description = "Configuration for each filetype. Use `all` to match any filetype.";
|
||||
default = {};
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
config = let
|
||||
cfg = config.plugins.efmls-configs;
|
||||
toolAsList = tools:
|
||||
if builtins.isList tools
|
||||
then tools
|
||||
else [tools];
|
||||
config =
|
||||
let
|
||||
cfg = config.plugins.efmls-configs;
|
||||
toolAsList = tools: if builtins.isList tools then tools else [ tools ];
|
||||
|
||||
# Tools that have been selected by the user
|
||||
tools = lists.unique (builtins.filter builtins.isString (
|
||||
builtins.concatLists (
|
||||
builtins.map ({
|
||||
linter ? [],
|
||||
formatter ? [],
|
||||
}:
|
||||
(toolAsList linter) ++ (toolAsList formatter))
|
||||
(builtins.attrValues cfg.setup)
|
||||
)
|
||||
));
|
||||
|
||||
pkgsForTools = let
|
||||
partitionFn =
|
||||
if cfg.externallyManagedPackages == "all"
|
||||
then _: false
|
||||
else t: !(builtins.elem t cfg.externallyManagedPackages);
|
||||
partition = lists.partition partitionFn tools;
|
||||
in {
|
||||
nixvim = partition.right;
|
||||
external = partition.wrong;
|
||||
};
|
||||
|
||||
nixvimPkgs = lists.partition (v: builtins.hasAttr v cfg.toolPackages) pkgsForTools.nixvim;
|
||||
|
||||
mkToolOption = kind: opt:
|
||||
builtins.map
|
||||
(tool:
|
||||
if builtins.isString tool
|
||||
then helpers.mkRaw "require 'efmls-configs.${kind}.${tool}'"
|
||||
else tool)
|
||||
(toolAsList opt);
|
||||
|
||||
setupOptions =
|
||||
(builtins.mapAttrs (
|
||||
_: {
|
||||
linter ? [],
|
||||
formatter ? [],
|
||||
}:
|
||||
(mkToolOption "linters" linter)
|
||||
++ (mkToolOption "formatters" formatter)
|
||||
# Tools that have been selected by the user
|
||||
tools = lists.unique (
|
||||
builtins.filter builtins.isString (
|
||||
builtins.concatLists (
|
||||
builtins.map (
|
||||
{
|
||||
linter ? [ ],
|
||||
formatter ? [ ],
|
||||
}:
|
||||
(toolAsList linter) ++ (toolAsList formatter)
|
||||
) (builtins.attrValues cfg.setup)
|
||||
)
|
||||
)
|
||||
(attrsets.filterAttrs (v: _: v != "all") cfg.setup))
|
||||
// {
|
||||
"=" =
|
||||
(mkToolOption "linters" cfg.setup.all.linter)
|
||||
++ (mkToolOption "formatters" cfg.setup.all.formatter);
|
||||
};
|
||||
in
|
||||
);
|
||||
|
||||
pkgsForTools =
|
||||
let
|
||||
partitionFn =
|
||||
if cfg.externallyManagedPackages == "all" then
|
||||
_: false
|
||||
else
|
||||
t: !(builtins.elem t cfg.externallyManagedPackages);
|
||||
partition = lists.partition partitionFn tools;
|
||||
in
|
||||
{
|
||||
nixvim = partition.right;
|
||||
external = partition.wrong;
|
||||
};
|
||||
|
||||
nixvimPkgs = lists.partition (v: builtins.hasAttr v cfg.toolPackages) pkgsForTools.nixvim;
|
||||
|
||||
mkToolOption =
|
||||
kind: opt:
|
||||
builtins.map (
|
||||
tool:
|
||||
if builtins.isString tool then helpers.mkRaw "require 'efmls-configs.${kind}.${tool}'" else tool
|
||||
) (toolAsList opt);
|
||||
|
||||
setupOptions =
|
||||
(builtins.mapAttrs (
|
||||
_:
|
||||
{
|
||||
linter ? [ ],
|
||||
formatter ? [ ],
|
||||
}:
|
||||
(mkToolOption "linters" linter) ++ (mkToolOption "formatters" formatter)
|
||||
) (attrsets.filterAttrs (v: _: v != "all") cfg.setup))
|
||||
// {
|
||||
"=" =
|
||||
(mkToolOption "linters" cfg.setup.all.linter)
|
||||
++ (mkToolOption "formatters" cfg.setup.all.formatter);
|
||||
};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [cfg.package];
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
warnings = optional ((builtins.length nixvimPkgs.wrong) > 0) ''
|
||||
Nixvim (plugins.efmls-configs): Following tools are not handled by nixvim, please add them to externallyManagedPackages to silence this:
|
||||
|
@ -293,14 +284,8 @@ in {
|
|||
extraOptions.settings.languages = setupOptions;
|
||||
};
|
||||
|
||||
extraPackages =
|
||||
[
|
||||
pkgs.efm-langserver
|
||||
]
|
||||
++ (
|
||||
builtins.map
|
||||
(v: cfg.toolPackages.${v})
|
||||
nixvimPkgs.right
|
||||
);
|
||||
extraPackages = [
|
||||
pkgs.efm-langserver
|
||||
] ++ (builtins.map (v: cfg.toolPackages.${v}) nixvimPkgs.right);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,38 +1,35 @@
|
|||
{ lib, helpers }:
|
||||
with lib;
|
||||
{
|
||||
lib,
|
||||
helpers,
|
||||
}:
|
||||
with lib; {
|
||||
enabled =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; either bool (listOf str))
|
||||
''["bibtex" "context" "context.tex" "html" "latex" "markdown" "org" "restructuredtext" "rsweave"]''
|
||||
''
|
||||
Controls whether the extension is enabled.
|
||||
Allows disabling LanguageTool on specific workspaces or for specific code language modes
|
||||
(i.e., file types).
|
||||
helpers.defaultNullOpts.mkNullable (with types; either bool (listOf str))
|
||||
''["bibtex" "context" "context.tex" "html" "latex" "markdown" "org" "restructuredtext" "rsweave"]''
|
||||
''
|
||||
Controls whether the extension is enabled.
|
||||
Allows disabling LanguageTool on specific workspaces or for specific code language modes
|
||||
(i.e., file types).
|
||||
|
||||
Either supply a boolean value stating whether LTEX is enabled for all supported markup languages
|
||||
or disabled for all of them, or supply a list of code language identifiers for which LTEX should
|
||||
be enabled (note that extensions can define additional code language identifiers).
|
||||
Either supply a boolean value stating whether LTEX is enabled for all supported markup languages
|
||||
or disabled for all of them, or supply a list of code language identifiers for which LTEX should
|
||||
be enabled (note that extensions can define additional code language identifiers).
|
||||
|
||||
All supported markup languages are listed in the default value of this setting.
|
||||
In addition, LTEX can check comments in many popular programming languages like C++ or Java, if
|
||||
you add the corresponding code language identifiers to this setting.
|
||||
If you add an unsupported code language mode, LTEX will check corresponding files as plain text
|
||||
without any parsing.
|
||||
All supported markup languages are listed in the default value of this setting.
|
||||
In addition, LTEX can check comments in many popular programming languages like C++ or Java, if
|
||||
you add the corresponding code language identifiers to this setting.
|
||||
If you add an unsupported code language mode, LTEX will check corresponding files as plain text
|
||||
without any parsing.
|
||||
|
||||
The activation events are unaffected by this setting.
|
||||
This means that the extension will be activated whenever a file with a supported code language
|
||||
mode is opened.
|
||||
For unsupported code language modes, you may need to activate the extension explicitly by
|
||||
executing the LTeX: Activate Extension command.
|
||||
The activation events are unaffected by this setting.
|
||||
This means that the extension will be activated whenever a file with a supported code language
|
||||
mode is opened.
|
||||
For unsupported code language modes, you may need to activate the extension explicitly by
|
||||
executing the LTeX: Activate Extension command.
|
||||
|
||||
Examples:
|
||||
- true
|
||||
- false
|
||||
- ["latex" "markdown"]
|
||||
'';
|
||||
Examples:
|
||||
- true
|
||||
- false
|
||||
- ["latex" "markdown"]
|
||||
'';
|
||||
|
||||
language = helpers.defaultNullOpts.mkStr "en-US" ''
|
||||
The language (e.g., "en-US") LanguageTool should check against.
|
||||
|
@ -94,175 +91,159 @@ with lib; {
|
|||
- "zh-CN": Chinese
|
||||
'';
|
||||
|
||||
dictionary =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; attrsOf (listOf 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`.
|
||||
|
||||
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
|
||||
dictionary = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf 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
|
||||
{
|
||||
"en-US" = [
|
||||
"adaptivity"
|
||||
"precomputed"
|
||||
"subproblem"
|
||||
"<LANGUAGE1>" = [
|
||||
"<WORD1>"
|
||||
"<WORD2>"
|
||||
...
|
||||
];
|
||||
"de-DE" = [
|
||||
"B-Splines"
|
||||
"<LANGUAGE2>" = [
|
||||
"<WORD1>"
|
||||
"<WORD2>"
|
||||
];
|
||||
...
|
||||
};
|
||||
```
|
||||
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 spelling errors will be ignored.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
{
|
||||
"en-US" = [
|
||||
"adaptivity"
|
||||
"precomputed"
|
||||
"subproblem"
|
||||
];
|
||||
"de-DE" = [
|
||||
"B-Splines"
|
||||
":/path/to/externalFile.txt"
|
||||
];
|
||||
}
|
||||
```
|
||||
'';
|
||||
|
||||
disabledRules = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf 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>"
|
||||
...
|
||||
];
|
||||
"<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 disabled.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
{
|
||||
"en-US" = [
|
||||
"EN_QUOTES"
|
||||
"UPPERCASE_SENTENCE_START"
|
||||
":/path/to/externalFile.txt"
|
||||
];
|
||||
}
|
||||
```
|
||||
'';
|
||||
|
||||
enabledRules = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf 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"
|
||||
];
|
||||
}
|
||||
```
|
||||
'';
|
||||
```
|
||||
'';
|
||||
|
||||
disabledRules =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; attrsOf (listOf 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>"
|
||||
...
|
||||
];
|
||||
"<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 disabled.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
hiddenFalsePositives = helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf 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
|
||||
{
|
||||
"en-US" = [
|
||||
"EN_QUOTES"
|
||||
"UPPERCASE_SENTENCE_START"
|
||||
":/path/to/externalFile.txt"
|
||||
"<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.
|
||||
|
||||
Although it is possible to manually edit this setting, the intended way is the
|
||||
`Hide false positive` quick fix.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
{
|
||||
"en-US" = [ ":/path/to/externalFile.txt" ];
|
||||
}
|
||||
```
|
||||
'';
|
||||
|
||||
enabledRules =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; attrsOf (listOf 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.mkNullable
|
||||
(with types; attrsOf (listOf 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>"
|
||||
];
|
||||
...
|
||||
};
|
||||
```
|
||||
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
|
||||
`Hide false positive` quick fix.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
{
|
||||
"en-US" = [ ":/path/to/externalFile.txt" ];
|
||||
}
|
||||
```
|
||||
'';
|
||||
```
|
||||
'';
|
||||
|
||||
fields = helpers.defaultNullOpts.mkNullable (with types; attrsOf bool) "{}" ''
|
||||
List of BibTEX fields whose values are to be checked in BibTEX files.
|
||||
|
@ -351,19 +332,18 @@ with lib; {
|
|||
};
|
||||
|
||||
configurationTarget =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; attrsOf str)
|
||||
''
|
||||
{
|
||||
dictionary = "workspaceFolderExternalFile";
|
||||
disabledRules = "workspaceFolderExternalFile";
|
||||
hiddenFalsePositives = "workspaceFolderExternalFile";
|
||||
}
|
||||
''
|
||||
''
|
||||
Controls which `settings.json` or external setting file (see documentation) to update when
|
||||
using one of the quick fixes.
|
||||
'';
|
||||
helpers.defaultNullOpts.mkNullable (with types; attrsOf str)
|
||||
''
|
||||
{
|
||||
dictionary = "workspaceFolderExternalFile";
|
||||
disabledRules = "workspaceFolderExternalFile";
|
||||
hiddenFalsePositives = "workspaceFolderExternalFile";
|
||||
}
|
||||
''
|
||||
''
|
||||
Controls which `settings.json` or external setting file (see documentation) to update when
|
||||
using one of the quick fixes.
|
||||
'';
|
||||
|
||||
additionalRules = {
|
||||
enablePickyRules = helpers.defaultNullOpts.mkBool false ''
|
||||
|
@ -483,34 +463,34 @@ with lib; {
|
|||
|
||||
logLevel =
|
||||
helpers.defaultNullOpts.mkEnum
|
||||
[
|
||||
"severe"
|
||||
"warning"
|
||||
"info"
|
||||
"config"
|
||||
[
|
||||
"severe"
|
||||
"warning"
|
||||
"info"
|
||||
"config"
|
||||
"fine"
|
||||
"finer"
|
||||
"finest"
|
||||
]
|
||||
"fine"
|
||||
"finer"
|
||||
"finest"
|
||||
]
|
||||
"fine"
|
||||
''
|
||||
Logging level (verbosity) of the `ltex-ls` server log.
|
||||
''
|
||||
Logging level (verbosity) of the `ltex-ls` server log.
|
||||
|
||||
The levels in descending order are "severe", "warning", "info", "config", "fine", "finer", and
|
||||
"finest".
|
||||
All messages that have the specified log level or a higher level are logged.
|
||||
The levels in descending order are "severe", "warning", "info", "config", "fine", "finer", and
|
||||
"finest".
|
||||
All messages that have the specified log level or a higher level are logged.
|
||||
|
||||
`ltex-ls` does not use all log levels.
|
||||
`ltex-ls` does not use all log levels.
|
||||
|
||||
Possible values:
|
||||
- "severe": Minimum verbosity. Only log severe errors.
|
||||
- "warning": Very low verbosity. Only log severe errors and warnings.
|
||||
- "info": Low verbosity. Additionally, log startup and shutdown messages.
|
||||
- "config": Medium verbosity. Additionally, log configuration messages.
|
||||
- "fine": Medium to high verbosity (default). Additionally, log when LanguageTool is called or LanguageTool has to be reinitialized due to changed settings.
|
||||
- "finer": High verbosity. Log additional debugging information such as full texts to be checked.
|
||||
- "finest": Maximum verbosity. Log all available debugging information.
|
||||
'';
|
||||
Possible values:
|
||||
- "severe": Minimum verbosity. Only log severe errors.
|
||||
- "warning": Very low verbosity. Only log severe errors and warnings.
|
||||
- "info": Low verbosity. Additionally, log startup and shutdown messages.
|
||||
- "config": Medium verbosity. Additionally, log configuration messages.
|
||||
- "fine": Medium to high verbosity (default). Additionally, log when LanguageTool is called or LanguageTool has to be reinitialized due to changed settings.
|
||||
- "finer": High verbosity. Log additional debugging information such as full texts to be checked.
|
||||
- "finest": Maximum verbosity. Log all available debugging information.
|
||||
'';
|
||||
};
|
||||
|
||||
java = {
|
||||
|
@ -574,40 +554,42 @@ with lib; {
|
|||
'';
|
||||
|
||||
diagnosticSeverity =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; either str (attrsOf str))
|
||||
"information"
|
||||
''
|
||||
Severity of the diagnostics corresponding to the grammar and spelling errors.
|
||||
helpers.defaultNullOpts.mkNullable (with types; either str (attrsOf str)) "information"
|
||||
''
|
||||
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 don’t 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 don’t 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";}`
|
||||
'';
|
||||
|
||||
checkFrequency =
|
||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
||||
["edit" "save" "manual"]
|
||||
''
|
||||
Controls when documents should be checked.
|
||||
[
|
||||
"edit"
|
||||
"save"
|
||||
"manual"
|
||||
]
|
||||
''
|
||||
Controls when documents should be checked.
|
||||
|
||||
Possible values:
|
||||
- "edit": Documents are checked when they are opened or edited (on every keystroke), or when
|
||||
the settings change.
|
||||
- "save": Documents are checked when they are opened or saved, or when the settings change.
|
||||
- "manual": Documents are not checked automatically, except when the settings change.
|
||||
Use commands such as LTeX: Check Current Document to manually trigger checks.
|
||||
'';
|
||||
Possible values:
|
||||
- "edit": Documents are checked when they are opened or edited (on every keystroke), or when
|
||||
the settings change.
|
||||
- "save": Documents are checked when they are opened or saved, or when the settings change.
|
||||
- "manual": Documents are not checked automatically, except when the settings change.
|
||||
Use commands such as LTeX: Check Current Document to manually trigger checks.
|
||||
'';
|
||||
|
||||
clearDiagnosticsWhenClosingFile = helpers.defaultNullOpts.mkBool true ''
|
||||
If set to true, diagnostics of a file are cleared when the file is closed.
|
||||
|
@ -620,20 +602,24 @@ with lib; {
|
|||
trace = {
|
||||
server =
|
||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
||||
["off" "messages" "verbose"]
|
||||
''
|
||||
Debug setting to log the communication between language client and server.
|
||||
[
|
||||
"off"
|
||||
"messages"
|
||||
"verbose"
|
||||
]
|
||||
''
|
||||
Debug setting to log the communication between language client and server.
|
||||
|
||||
When reporting issues, set this to "verbose".
|
||||
Append the relevant part to the GitHub issue.
|
||||
When reporting issues, set this to "verbose".
|
||||
Append the relevant part to the GitHub issue.
|
||||
|
||||
Changes require restarting LTEX to take effect.
|
||||
Changes require restarting LTEX to take effect.
|
||||
|
||||
Possible values:
|
||||
- "off": Don’t log any of the communication between language client and server.
|
||||
- "messages": Log the type of requests and responses between language client and server.
|
||||
- "verbose": Log the type and contents of requests and responses between language client and
|
||||
server.
|
||||
'';
|
||||
Possible values:
|
||||
- "off": Don’t log any of the communication between language client and server.
|
||||
- "messages": Log the type of requests and responses between language client and server.
|
||||
- "verbose": Log the type and contents of requests and responses between language client and
|
||||
server.
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp.servers.nixd;
|
||||
in {
|
||||
in
|
||||
{
|
||||
# Options: https://github.com/nix-community/nixd/blob/main/docs/user-guide.md#configuration
|
||||
options.plugins.lsp.servers.nixd.settings = {
|
||||
# The evaluation section, provide auto completion for dynamic bindings.
|
||||
|
@ -53,12 +55,7 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config =
|
||||
mkIf cfg.enable
|
||||
{
|
||||
extraPackages =
|
||||
optional
|
||||
(cfg.settings.formatting.command == "nixpkgs-fmt")
|
||||
pkgs.nixpkgs-fmt;
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
extraPackages = optional (cfg.settings.formatting.command == "nixpkgs-fmt") pkgs.nixpkgs-fmt;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,21 +5,25 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp.servers.pylsp;
|
||||
in {
|
||||
in
|
||||
{
|
||||
# All settings are documented here:
|
||||
# https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md
|
||||
|
||||
options.plugins.lsp.servers.pylsp.settings = {
|
||||
configurationSources = mkOption {
|
||||
type = lib.types.nullOr (types.enum ["pycodestyle" "flake8"]);
|
||||
type = lib.types.nullOr (
|
||||
types.enum [
|
||||
"pycodestyle"
|
||||
"flake8"
|
||||
]
|
||||
);
|
||||
description = "List of configuration sources to use.";
|
||||
default = null;
|
||||
apply = value:
|
||||
if (value != null)
|
||||
then [value]
|
||||
else null;
|
||||
apply = value: if (value != null) then [ value ] else null;
|
||||
};
|
||||
|
||||
plugins = {
|
||||
|
@ -86,10 +90,8 @@ in {
|
|||
|
||||
jedi = {
|
||||
auto_import_modules =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(types.listOf types.str)
|
||||
"[ \"numpy\" ]"
|
||||
"List of module names for `jedi.settings.auto_import_modules`.";
|
||||
helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[ \"numpy\" ]"
|
||||
"List of module names for `jedi.settings.auto_import_modules`.";
|
||||
|
||||
extra_paths = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
|
||||
Define extra paths for jedi.Script.
|
||||
|
@ -128,10 +130,9 @@ in {
|
|||
'';
|
||||
|
||||
cache_for =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(types.listOf types.str)
|
||||
"[ \"pandas\" \"numpy\" \"tensorflow\" \"matplotlib\" ]"
|
||||
"Modules for which labels and snippets should be cached.";
|
||||
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
|
||||
"[ \"pandas\" \"numpy\" \"tensorflow\" \"matplotlib\" ]"
|
||||
"Modules for which labels and snippets should be cached.";
|
||||
};
|
||||
|
||||
jedi_definition = {
|
||||
|
@ -236,15 +237,12 @@ in {
|
|||
(pydocstyle).
|
||||
'';
|
||||
|
||||
convention =
|
||||
helpers.mkNullOrOption
|
||||
(types.enum [
|
||||
"pep257"
|
||||
"numpy"
|
||||
"google"
|
||||
"None"
|
||||
])
|
||||
"Choose the basic list of checked errors by specifying an existing convention.";
|
||||
convention = helpers.mkNullOrOption (types.enum [
|
||||
"pep257"
|
||||
"numpy"
|
||||
"google"
|
||||
"None"
|
||||
]) "Choose the basic list of checked errors by specifying an existing convention.";
|
||||
|
||||
addIgnore = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
|
||||
Ignore errors and warnings in addition to the specified convention.
|
||||
|
@ -356,17 +354,22 @@ in {
|
|||
|
||||
overrides =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(types.listOf
|
||||
(types.oneOf [types.bool types.str helpers.nixvimTypes.rawLua]))
|
||||
"[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
|
||||
would've been passed had overrides not been specified.
|
||||
Later options take precedence, which allows for replacing or negating individual default
|
||||
options (see mypy.main:process_options and mypy --help | grep inverse).
|
||||
'';
|
||||
(types.listOf (
|
||||
types.oneOf [
|
||||
types.bool
|
||||
types.str
|
||||
helpers.nixvimTypes.rawLua
|
||||
]
|
||||
))
|
||||
"[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
|
||||
would've been passed had overrides not been specified.
|
||||
Later options take precedence, which allows for replacing or negating individual default
|
||||
options (see mypy.main:process_options and mypy --help | grep inverse).
|
||||
'';
|
||||
|
||||
dmypy_status_file = helpers.defaultNullOpts.mkStr ".dmypy.json" ''
|
||||
Specifies which status file dmypy should use.
|
||||
|
@ -497,24 +500,21 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config =
|
||||
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`.
|
||||
# See https://github.com/NixOS/nixpkgs/issues/229337
|
||||
plugins.lsp.servers.pylsp.package = let
|
||||
config = 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`.
|
||||
# See https://github.com/NixOS/nixpkgs/issues/229337
|
||||
plugins.lsp.servers.pylsp.package =
|
||||
let
|
||||
isEnabled = x: (x.enabled != null && x.enabled);
|
||||
inherit (cfg.settings) plugins;
|
||||
|
||||
nativePlugins =
|
||||
(map
|
||||
(
|
||||
pluginName: (
|
||||
optionals (isEnabled plugins.${pluginName})
|
||||
cfg.package.optional-dependencies.${pluginName}
|
||||
)
|
||||
pluginName:
|
||||
(optionals (isEnabled plugins.${pluginName}) cfg.package.optional-dependencies.${pluginName})
|
||||
)
|
||||
[
|
||||
"autopep8"
|
||||
|
@ -525,114 +525,95 @@ in {
|
|||
"pyflakes"
|
||||
"pylint"
|
||||
"yapf"
|
||||
])
|
||||
++ (
|
||||
optionals
|
||||
(
|
||||
(isEnabled plugins.rope_autoimport)
|
||||
|| (isEnabled plugins.rope_completion)
|
||||
)
|
||||
cfg.package.optional-dependencies.rope
|
||||
);
|
||||
]
|
||||
)
|
||||
++ (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
|
||||
(
|
||||
pluginName: nixPackage: (
|
||||
optional
|
||||
(isEnabled plugins.${pluginName})
|
||||
(
|
||||
nixPackage.overridePythonAttrs (
|
||||
old: {
|
||||
# Get rid of the python-lsp-server dependency
|
||||
propagatedBuildInputs =
|
||||
filter
|
||||
(dep: dep.pname != "python-lsp-server")
|
||||
old.propagatedBuildInputs;
|
||||
(
|
||||
pluginName: nixPackage:
|
||||
(optional (isEnabled plugins.${pluginName}) (
|
||||
nixPackage.overridePythonAttrs (old: {
|
||||
# Get rid of the python-lsp-server dependency
|
||||
propagatedBuildInputs = filter (dep: dep.pname != "python-lsp-server") old.propagatedBuildInputs;
|
||||
|
||||
# Skip testing because those naked dependencies will complain about missing pylsp
|
||||
doCheck = false;
|
||||
}
|
||||
)
|
||||
)
|
||||
# Skip testing because those naked dependencies will complain about missing pylsp
|
||||
doCheck = false;
|
||||
})
|
||||
))
|
||||
)
|
||||
)
|
||||
(with pkgs.python3Packages; {
|
||||
pylsp_mypy = pylsp-mypy.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.cfg \
|
||||
--replace-fail "python-lsp-server >=1.7.0" ""
|
||||
'';
|
||||
});
|
||||
isort = pyls-isort.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.py \
|
||||
--replace-fail 'install_requires=["python-lsp-server", "isort"],' 'install_requires=["isort"],'
|
||||
'';
|
||||
});
|
||||
black = python-lsp-black.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.cfg \
|
||||
--replace-fail "python-lsp-server>=1.4.0" ""
|
||||
'';
|
||||
});
|
||||
memestra = pyls-memestra.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' requirements.txt
|
||||
'';
|
||||
});
|
||||
rope = pylsp-rope.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' setup.cfg
|
||||
'';
|
||||
});
|
||||
ruff = python-lsp-ruff.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch
|
||||
or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' pyproject.toml
|
||||
'';
|
||||
(
|
||||
with pkgs.python3Packages;
|
||||
{
|
||||
pylsp_mypy = pylsp-mypy.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.cfg \
|
||||
--replace-fail "python-lsp-server >=1.7.0" ""
|
||||
'';
|
||||
});
|
||||
isort = pyls-isort.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.py \
|
||||
--replace-fail 'install_requires=["python-lsp-server", "isort"],' 'install_requires=["isort"],'
|
||||
'';
|
||||
});
|
||||
black = python-lsp-black.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
substituteInPlace setup.cfg \
|
||||
--replace-fail "python-lsp-server>=1.4.0" ""
|
||||
'';
|
||||
});
|
||||
memestra = pyls-memestra.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' requirements.txt
|
||||
'';
|
||||
});
|
||||
rope = pylsp-rope.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' setup.cfg
|
||||
'';
|
||||
});
|
||||
ruff = python-lsp-ruff.overridePythonAttrs (old: {
|
||||
postPatch =
|
||||
old.postPatch or ''''
|
||||
+ ''
|
||||
sed -i '/python-lsp-server/d' pyproject.toml
|
||||
'';
|
||||
|
||||
build-system = [setuptools] ++ (old.build-system or []);
|
||||
});
|
||||
})
|
||||
build-system = [ setuptools ] ++ (old.build-system or [ ]);
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
# Final list of pylsp plugins to install
|
||||
pylspPlugins = nativePlugins ++ thirdPartyPlugins;
|
||||
in
|
||||
mkDefault (
|
||||
# This is the final default package for pylsp
|
||||
pkgs.python3Packages.python-lsp-server.overridePythonAttrs (
|
||||
old: {
|
||||
propagatedBuildInputs = pylspPlugins ++ old.dependencies;
|
||||
disabledTests =
|
||||
(old.disabledTests or [])
|
||||
++ [
|
||||
# Those tests fail when third-party plugins are loaded
|
||||
"test_notebook_document__did_open"
|
||||
"test_notebook_document__did_change"
|
||||
];
|
||||
}
|
||||
)
|
||||
);
|
||||
};
|
||||
mkDefault (
|
||||
# This is the final default package for pylsp
|
||||
pkgs.python3Packages.python-lsp-server.overridePythonAttrs (old: {
|
||||
propagatedBuildInputs = pylspPlugins ++ old.dependencies;
|
||||
disabledTests = (old.disabledTests or [ ]) ++ [
|
||||
# Those tests fail when third-party plugins are loaded
|
||||
"test_notebook_document__did_open"
|
||||
"test_notebook_document__did_change"
|
||||
];
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,34 +1,32 @@
|
|||
lib: pkgs:
|
||||
# Future improvements:
|
||||
# - extra documentation from anyOf types, they can have `enumDescriptions` that are valuable
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
packageJson = "${pkgs.rust-analyzer.src}/editors/code/package.json";
|
||||
|
||||
options =
|
||||
(trivial.importJSON packageJson)
|
||||
.contributes
|
||||
.configuration
|
||||
.properties;
|
||||
options = (trivial.importJSON packageJson).contributes.configuration.properties;
|
||||
|
||||
packageJsonTxt = strings.splitString "\n" (builtins.readFile packageJson);
|
||||
vscodeStart =
|
||||
lists.findFirstIndex (x: x == " \"configuration\": {")
|
||||
(throw "no configuration")
|
||||
packageJsonTxt;
|
||||
vscodeStart = lists.findFirstIndex (
|
||||
x: x == " \"configuration\": {"
|
||||
) (throw "no configuration") packageJsonTxt;
|
||||
vscodeEnd =
|
||||
lists.findFirstIndex (strings.hasInfix "generated-start") (throw "no generated start")
|
||||
packageJsonTxt;
|
||||
packageJsonTxt;
|
||||
vscodeOptions = lists.sublist vscodeStart (vscodeEnd - vscodeStart) packageJsonTxt;
|
||||
|
||||
vscodeOptionNames =
|
||||
builtins.map
|
||||
(x: strings.removeSuffix "\": {" (strings.removePrefix " \"" x))
|
||||
(lists.filter (strings.hasPrefix " \"rust-analyzer.")
|
||||
vscodeOptions);
|
||||
vscodeOptionNames = builtins.map (
|
||||
x: strings.removeSuffix "\": {" (strings.removePrefix " \"" x)
|
||||
) (lists.filter (strings.hasPrefix " \"rust-analyzer.") vscodeOptions);
|
||||
|
||||
rustAnalyzerOptions =
|
||||
builtins.removeAttrs options
|
||||
(vscodeOptionNames ++ ["\$generated-start" "\$generated-end"]);
|
||||
rustAnalyzerOptions = builtins.removeAttrs options (
|
||||
vscodeOptionNames
|
||||
++ [
|
||||
"\$generated-start"
|
||||
"\$generated-end"
|
||||
]
|
||||
);
|
||||
|
||||
nullType = mkOptionType {
|
||||
name = "nullType";
|
||||
|
@ -38,126 +36,132 @@ with lib; let
|
|||
check = e: e == null;
|
||||
};
|
||||
|
||||
mkRustAnalyzerType = opt: {
|
||||
type,
|
||||
enum ? null,
|
||||
minimum ? null,
|
||||
maximum ? null,
|
||||
items ? null,
|
||||
anyOf ? null,
|
||||
uniqueItems ? null,
|
||||
# unused, but for exhaustivness
|
||||
enumDescriptions ? null,
|
||||
} @ def:
|
||||
if enum != null
|
||||
then types.enum enum
|
||||
else if anyOf != null
|
||||
then types.oneOf (builtins.map (mkRustAnalyzerType opt) anyOf)
|
||||
else if builtins.isList type
|
||||
then
|
||||
if builtins.length type == 2 && builtins.head type == "null"
|
||||
then types.nullOr (mkRustAnalyzerType opt (def // {type = builtins.elemAt type 1;}))
|
||||
else types.oneOf (builtins.map (t: mkRustAnalyzerType opt (def // {type = t;})) type)
|
||||
else if type == "boolean"
|
||||
then types.bool
|
||||
else if type == "object"
|
||||
then types.attrsOf types.anything
|
||||
else if type == "string"
|
||||
then types.str
|
||||
else if type == "null"
|
||||
then nullType
|
||||
else if type == "array"
|
||||
then
|
||||
mkRustAnalyzerType =
|
||||
opt:
|
||||
{
|
||||
type,
|
||||
enum ? null,
|
||||
minimum ? null,
|
||||
maximum ? null,
|
||||
items ? null,
|
||||
anyOf ? null,
|
||||
uniqueItems ? null,
|
||||
# unused, but for exhaustivness
|
||||
enumDescriptions ? null,
|
||||
}@def:
|
||||
if enum != null then
|
||||
types.enum enum
|
||||
else if anyOf != null then
|
||||
types.oneOf (builtins.map (mkRustAnalyzerType opt) anyOf)
|
||||
else if builtins.isList type then
|
||||
if builtins.length type == 2 && builtins.head type == "null" then
|
||||
types.nullOr (mkRustAnalyzerType opt (def // { type = builtins.elemAt type 1; }))
|
||||
else
|
||||
types.oneOf (builtins.map (t: mkRustAnalyzerType opt (def // { type = t; })) type)
|
||||
else if type == "boolean" then
|
||||
types.bool
|
||||
else if type == "object" then
|
||||
types.attrsOf types.anything
|
||||
else if type == "string" then
|
||||
types.str
|
||||
else if type == "null" then
|
||||
nullType
|
||||
else if type == "array" then
|
||||
types.listOf (
|
||||
mkRustAnalyzerType "${opt}-items"
|
||||
(
|
||||
if items == null
|
||||
then throw "null items with array type (in ${opt})"
|
||||
else items
|
||||
mkRustAnalyzerType "${opt}-items" (
|
||||
if items == null then throw "null items with array type (in ${opt})" else items
|
||||
)
|
||||
)
|
||||
else if type == "number"
|
||||
then
|
||||
if minimum != null && maximum != null
|
||||
then types.numbers.between minimum maximum
|
||||
else if minimum != null
|
||||
then types.addCheck types.number (x: x >= minimum)
|
||||
else if maximum != null
|
||||
then types.addCheck types.number (x: x <= maximum)
|
||||
else types.number
|
||||
else if type == "integer"
|
||||
then
|
||||
if minimum != null && maximum != null
|
||||
then types.ints.between minimum maximum
|
||||
else if minimum != null
|
||||
then types.addCheck types.int (x: x >= minimum)
|
||||
else if maximum != null
|
||||
then types.addCheck types.int (x: x <= maximum)
|
||||
else types.int
|
||||
else throw "unhandled type `${builtins.toJSON type}` (in ${opt})";
|
||||
else if type == "number" then
|
||||
if minimum != null && maximum != null then
|
||||
types.numbers.between minimum maximum
|
||||
else if minimum != null then
|
||||
types.addCheck types.number (x: x >= minimum)
|
||||
else if maximum != null then
|
||||
types.addCheck types.number (x: x <= maximum)
|
||||
else
|
||||
types.number
|
||||
else if type == "integer" then
|
||||
if minimum != null && maximum != null then
|
||||
types.ints.between minimum maximum
|
||||
else if minimum != null then
|
||||
types.addCheck types.int (x: x >= minimum)
|
||||
else if maximum != null then
|
||||
types.addCheck types.int (x: x <= maximum)
|
||||
else
|
||||
types.int
|
||||
else
|
||||
throw "unhandled type `${builtins.toJSON type}` (in ${opt})";
|
||||
|
||||
mkRustAnalyzerOption = opt: {
|
||||
default,
|
||||
markdownDescription,
|
||||
type ? null,
|
||||
anyOf ? null,
|
||||
# Enum types
|
||||
enum ? null,
|
||||
enumDescriptions ? null,
|
||||
# Int types
|
||||
minimum ? null,
|
||||
maximum ? null,
|
||||
# List types
|
||||
items ? null,
|
||||
uniqueItems ? false,
|
||||
}:
|
||||
mkRustAnalyzerOption =
|
||||
opt:
|
||||
{
|
||||
default,
|
||||
markdownDescription,
|
||||
type ? null,
|
||||
anyOf ? null,
|
||||
# Enum types
|
||||
enum ? null,
|
||||
enumDescriptions ? null,
|
||||
# Int types
|
||||
minimum ? null,
|
||||
maximum ? null,
|
||||
# List types
|
||||
items ? null,
|
||||
uniqueItems ? false,
|
||||
}:
|
||||
mkOption {
|
||||
type = types.nullOr (mkRustAnalyzerType opt {
|
||||
inherit
|
||||
type
|
||||
enum
|
||||
minimum
|
||||
maximum
|
||||
items
|
||||
anyOf
|
||||
uniqueItems
|
||||
;
|
||||
});
|
||||
type = types.nullOr (
|
||||
mkRustAnalyzerType opt {
|
||||
inherit
|
||||
type
|
||||
enum
|
||||
minimum
|
||||
maximum
|
||||
items
|
||||
anyOf
|
||||
uniqueItems
|
||||
;
|
||||
}
|
||||
);
|
||||
default = null;
|
||||
description =
|
||||
if enum != null
|
||||
then let
|
||||
valueDesc = builtins.map ({
|
||||
fst,
|
||||
snd,
|
||||
}: ''- ${fst}: ${snd}'') (lists.zipLists enum enumDescriptions);
|
||||
in ''
|
||||
${markdownDescription}
|
||||
if enum != null then
|
||||
let
|
||||
valueDesc = builtins.map ({ fst, snd }: ''- ${fst}: ${snd}'') (
|
||||
lists.zipLists enum enumDescriptions
|
||||
);
|
||||
in
|
||||
''
|
||||
${markdownDescription}
|
||||
|
||||
Values:
|
||||
${builtins.concatStringsSep "\n" valueDesc}
|
||||
Values:
|
||||
${builtins.concatStringsSep "\n" valueDesc}
|
||||
|
||||
```nix
|
||||
${generators.toPretty {} default}
|
||||
```
|
||||
''
|
||||
else ''
|
||||
${markdownDescription}
|
||||
```nix
|
||||
${generators.toPretty { } default}
|
||||
```
|
||||
''
|
||||
else
|
||||
''
|
||||
${markdownDescription}
|
||||
|
||||
default:
|
||||
```nix
|
||||
${generators.toPretty {} default}
|
||||
```
|
||||
'';
|
||||
default:
|
||||
```nix
|
||||
${generators.toPretty { } default}
|
||||
```
|
||||
'';
|
||||
};
|
||||
|
||||
nixOptions = builtins.mapAttrs mkRustAnalyzerOption rustAnalyzerOptions;
|
||||
|
||||
nestOpt = opt: value: let
|
||||
parts = strings.splitString "." opt;
|
||||
in
|
||||
builtins.foldl' (current: segment: {${segment} = current;}) value (lists.reverseList parts);
|
||||
nestOpt =
|
||||
opt: value:
|
||||
let
|
||||
parts = strings.splitString "." opt;
|
||||
in
|
||||
builtins.foldl' (current: segment: { ${segment} = current; }) value (lists.reverseList parts);
|
||||
|
||||
nestedNixOptions = attrsets.mapAttrsToList nestOpt nixOptions;
|
||||
in
|
||||
(builtins.foldl' attrsets.recursiveUpdate {} nestedNixOptions).rust-analyzer
|
||||
(builtins.foldl' attrsets.recursiveUpdate { } nestedNixOptions).rust-analyzer
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp.servers.rust-analyzer;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.plugins.lsp.servers.rust-analyzer = {
|
||||
# https://github.com/nix-community/nixvim/issues/674
|
||||
installCargo = mkOption {
|
||||
|
@ -37,45 +39,30 @@ in {
|
|||
};
|
||||
config = mkIf cfg.enable {
|
||||
warnings =
|
||||
(
|
||||
optional
|
||||
(cfg.installCargo == null)
|
||||
''
|
||||
`rust_analyzer` relies on `cargo`.
|
||||
- Set `plugins.lsp.servers.rust-analyzer.installCargo = true` to install it automatically
|
||||
with Nixvim.
|
||||
You can customize which package to install by changing
|
||||
`plugins.lsp.servers.rust-analyzer.cargoPackage`.
|
||||
- Set `plugins.lsp.servers.rust-analyzer.installCargo = false` to not have it install
|
||||
through Nixvim.
|
||||
By doing so, you will dismiss this warning.
|
||||
''
|
||||
)
|
||||
++ (
|
||||
optional
|
||||
(cfg.installRustc == null)
|
||||
''
|
||||
`rust_analyzer` relies on `rustc`.
|
||||
- Set `plugins.lsp.servers.rust-analyzer.installRustc = true` to install it automatically
|
||||
with Nixvim.
|
||||
You can customize which package to install by changing
|
||||
`plugins.lsp.servers.rust-analyzer.rustcPackage`.
|
||||
- Set `plugins.lsp.servers.rust-analyzer.installRustc = false` to not have it install
|
||||
through Nixvim.
|
||||
By doing so, you will dismiss this warning.
|
||||
''
|
||||
);
|
||||
(optional (cfg.installCargo == null) ''
|
||||
`rust_analyzer` relies on `cargo`.
|
||||
- Set `plugins.lsp.servers.rust-analyzer.installCargo = true` to install it automatically
|
||||
with Nixvim.
|
||||
You can customize which package to install by changing
|
||||
`plugins.lsp.servers.rust-analyzer.cargoPackage`.
|
||||
- Set `plugins.lsp.servers.rust-analyzer.installCargo = false` to not have it install
|
||||
through Nixvim.
|
||||
By doing so, you will dismiss this warning.
|
||||
'')
|
||||
++ (optional (cfg.installRustc == null) ''
|
||||
`rust_analyzer` relies on `rustc`.
|
||||
- Set `plugins.lsp.servers.rust-analyzer.installRustc = true` to install it automatically
|
||||
with Nixvim.
|
||||
You can customize which package to install by changing
|
||||
`plugins.lsp.servers.rust-analyzer.rustcPackage`.
|
||||
- Set `plugins.lsp.servers.rust-analyzer.installRustc = false` to not have it install
|
||||
through Nixvim.
|
||||
By doing so, you will dismiss this warning.
|
||||
'');
|
||||
|
||||
extraPackages = with pkgs;
|
||||
(
|
||||
optional
|
||||
((isBool cfg.installCargo) && cfg.installCargo)
|
||||
cfg.cargoPackage
|
||||
)
|
||||
++ (
|
||||
optional
|
||||
((isBool cfg.installRustc) && cfg.installRustc)
|
||||
cfg.rustcPackage
|
||||
);
|
||||
extraPackages =
|
||||
with pkgs;
|
||||
(optional ((isBool cfg.installCargo) && cfg.installCargo) cfg.cargoPackage)
|
||||
++ (optional ((isBool cfg.installRustc) && cfg.installRustc) cfg.rustcPackage);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp.servers.svelte;
|
||||
in {
|
||||
in
|
||||
{
|
||||
# Options: https://github.com/sveltejs/language-tools/tree/master/packages/language-server#settings
|
||||
options.plugins.lsp.servers.svelte.initOptions = {
|
||||
svelte = {
|
||||
|
@ -283,11 +285,9 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config =
|
||||
mkIf cfg.enable
|
||||
{
|
||||
plugins.lsp.servers.svelte.extraOptions.init_options = {
|
||||
configuration = cfg.initOptions;
|
||||
};
|
||||
config = mkIf cfg.enable {
|
||||
plugins.lsp.servers.svelte.extraOptions.init_options = {
|
||||
configuration = cfg.initOptions;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
{ lib, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp.servers.vls;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.plugins.lsp.servers.vls = {
|
||||
autoSetFiletype = mkOption {
|
||||
type = types.bool;
|
||||
|
@ -18,11 +16,5 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config =
|
||||
mkIf cfg.enable
|
||||
{
|
||||
filetype.extension =
|
||||
mkIf cfg.autoSetFiletype
|
||||
{v = "vlang";};
|
||||
};
|
||||
config = mkIf cfg.enable { filetype.extension = mkIf cfg.autoSetFiletype { v = "vlang"; }; };
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue