Skip to content

Commit

Permalink
plugins/lsp/efmls-configs: respect tool packages availability
Browse files Browse the repository at this point in the history
  • Loading branch information
GaetanLepage committed Nov 21, 2023
1 parent a05b2a9 commit 3cb12cd
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 24 deletions.
22 changes: 20 additions & 2 deletions plugins/lsp/language-servers/efmls-configs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ with lib; let
languages = builtins.attrNames tools;

# Mapping of tool name to the nixpkgs package (if any)
toolPkgs = with pkgs; {
allToolPkgs = with pkgs; {
inherit
actionlint
alejandra
Expand Down Expand Up @@ -99,6 +99,16 @@ with lib; let
write_good = write-good;
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 {
options.plugins.efmls-configs = {
enable = mkEnableOption "efmls-configs, premade configurations for efm-langserver";
Expand Down Expand Up @@ -249,6 +259,14 @@ in {
extraOptions.settings.languages = setupOptions;
};

extraPackages = [pkgs.efm-langserver] ++ (builtins.map (v: toolPkgs.${v}) nixvimPkgs.right);
extraPackages =
[
pkgs.efm-langserver
]
++ (
builtins.map
(v: toolPkgs.${v})
nixvimPkgs.right
);
};
}
62 changes: 40 additions & 22 deletions tests/test-sources/plugins/lsp/efmls-configs.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{efmls-options, ...}: {
{
efmls-options,
pkgs,
...
}: {
empty = {
plugins.efmls-configs.enable = true;
};
Expand All @@ -16,27 +20,41 @@
"phpstan"
];

unpackaged = [
"blade_formatter"
"cspell"
"dartanalyzer"
"debride"
"fecs"
"fixjson"
"forge_fmt"
"gersemi"
"js_standard"
"pint"
"prettier_eslint"
"prettier_standard"
"redpen"
"reek"
"rome"
"slim_lint"
"solhint"
"sorbet"
"xo"
];
unpackaged =
[
"blade_formatter"
"cspell"
"dartanalyzer"
"debride"
"fecs"
"fixjson"
"forge_fmt"
"gersemi"
"js_standard"
"pint"
"prettier_eslint"
"prettier_standard"
"redpen"
"reek"
"rome"
"slim_lint"
"solhint"
"sorbet"
"xo"
]
++ (
pkgs.lib.optionals
pkgs.stdenv.isDarwin
["clazy"]
)
++ (
pkgs.lib.optionals
pkgs.stdenv.isAarch64
[
"dmd"
"smlfmt"
]
);

# Fetch the valid enum members from the tool options
toolsFromOptions = opt: let
Expand Down

0 comments on commit 3cb12cd

Please sign in to comment.