mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
plugins/efmls-configs: move from lsp to by-name
This commit is contained in:
parent
f13bdfec8f
commit
09daa2cb83
5 changed files with 3 additions and 4 deletions
|
@ -217,7 +217,6 @@ in
|
|||
++ renameModules
|
||||
++ [
|
||||
./ccls.nix
|
||||
./efmls-configs.nix
|
||||
./hls.nix
|
||||
./pylsp.nix
|
||||
./rust-analyzer.nix
|
||||
|
|
|
@ -1,170 +0,0 @@
|
|||
lib:
|
||||
let
|
||||
inherit (import ../../../lib/pkg-lists.nix lib) topLevel scoped;
|
||||
in
|
||||
{
|
||||
# efmls-configs tools that have no corresponding nixpkgs package
|
||||
unpackaged = [
|
||||
"blade_formatter"
|
||||
"cljstyle"
|
||||
"cspell"
|
||||
"dartanalyzer"
|
||||
"debride"
|
||||
"deno_fmt"
|
||||
"fecs"
|
||||
"fixjson"
|
||||
"forge_fmt"
|
||||
"gersemi"
|
||||
"js_standard"
|
||||
"kdlfmt"
|
||||
"markuplint"
|
||||
"mix"
|
||||
"pint"
|
||||
"prettier_eslint"
|
||||
"prettier_standard"
|
||||
"redpen"
|
||||
"reek"
|
||||
"rome"
|
||||
"ruff_sort"
|
||||
"slim_lint"
|
||||
"solhint"
|
||||
"sorbet"
|
||||
"swiftformat"
|
||||
"swiftlint"
|
||||
"xo"
|
||||
];
|
||||
|
||||
# Mapping from a efmls-configs tool name to the corresponding nixpkgs package
|
||||
packaged =
|
||||
# Top-level packages
|
||||
topLevel [
|
||||
"actionlint"
|
||||
"alejandra"
|
||||
"ameba"
|
||||
"astyle"
|
||||
"bashate"
|
||||
"beautysh"
|
||||
"biome"
|
||||
"black"
|
||||
"buf"
|
||||
"cbfmt"
|
||||
"checkmake"
|
||||
"clazy"
|
||||
"codespell"
|
||||
"cppcheck"
|
||||
"cpplint"
|
||||
"dfmt"
|
||||
"djlint"
|
||||
"dmd"
|
||||
"dprint"
|
||||
"eslint"
|
||||
"fish"
|
||||
"flawfinder"
|
||||
"fnlfmt"
|
||||
"gcc"
|
||||
"gitlint"
|
||||
"gofumpt"
|
||||
"golines"
|
||||
"golint"
|
||||
"hadolint"
|
||||
"isort"
|
||||
"joker"
|
||||
"jq"
|
||||
"languagetool"
|
||||
"mypy"
|
||||
"php"
|
||||
"prettypst"
|
||||
"proselint"
|
||||
"protolint"
|
||||
"pylint"
|
||||
"rubocop"
|
||||
"ruff"
|
||||
"rustfmt"
|
||||
"scalafmt"
|
||||
"selene"
|
||||
"shellcheck"
|
||||
"shellharden"
|
||||
"shfmt"
|
||||
"smlfmt"
|
||||
"sqlfluff"
|
||||
"sql-formatter"
|
||||
"statix"
|
||||
"stylua"
|
||||
"taplo"
|
||||
"typstfmt"
|
||||
"typstyle"
|
||||
"uncrustify"
|
||||
"vale"
|
||||
"yamllint"
|
||||
"yapf"
|
||||
]
|
||||
# Scoped packages
|
||||
// scoped {
|
||||
python3.pkgs = [
|
||||
"autopep8"
|
||||
"flake8"
|
||||
"mdformat"
|
||||
"vulture"
|
||||
];
|
||||
nodePackages = [
|
||||
"alex"
|
||||
"eslint_d"
|
||||
"jsonlint"
|
||||
"prettier"
|
||||
"stylelint"
|
||||
"textlint"
|
||||
];
|
||||
phpPackages = [
|
||||
"phan"
|
||||
"phpstan"
|
||||
"psalm"
|
||||
];
|
||||
luaPackages = [
|
||||
"luacheck"
|
||||
];
|
||||
haskellPackages = [
|
||||
"fourmolu"
|
||||
];
|
||||
}
|
||||
# Packages where the name is different
|
||||
// {
|
||||
ansible_lint = "ansible-lint";
|
||||
chktex = "texliveMedium";
|
||||
clang_format = "clang-tools";
|
||||
clang_tidy = "clang-tools";
|
||||
clj_kondo = "clj-kondo";
|
||||
cmake_lint = "cmake-format";
|
||||
dartfmt = "dart";
|
||||
dotnet_format = "dotnet-runtime";
|
||||
fish_indent = "fish";
|
||||
gofmt = "go";
|
||||
goimports = "go-tools";
|
||||
golangci_lint = "golangci-lint";
|
||||
google_java_format = "google-java-format";
|
||||
go_revive = "revive";
|
||||
latexindent = "texliveMedium";
|
||||
lua_format = "luaformatter";
|
||||
markdownlint = "markdownlint-cli";
|
||||
mcs = "mono";
|
||||
nixfmt = "nixfmt-classic";
|
||||
phpcbf = [
|
||||
"phpPackages"
|
||||
"php-codesniffer"
|
||||
];
|
||||
php_cs_fixer = [
|
||||
"phpPackages"
|
||||
"php-cs-fixer"
|
||||
];
|
||||
phpcs = [
|
||||
"phpPackages"
|
||||
"php-codesniffer"
|
||||
];
|
||||
prettier_d = "prettierd";
|
||||
slither = "slither-analyzer";
|
||||
staticcheck = "go-tools";
|
||||
terraform_fmt = "terraform";
|
||||
vint = "vim-vint";
|
||||
write_good = "write-good";
|
||||
yq = "yq-go";
|
||||
};
|
||||
}
|
|
@ -1,160 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
tools = import ../../../generated/efmls-configs.nix;
|
||||
inherit (import ./efmls-configs-pkgs.nix lib) packaged;
|
||||
in
|
||||
{
|
||||
options.plugins.efmls-configs = {
|
||||
enable = lib.mkEnableOption "efmls-configs, premade configurations for efm-langserver";
|
||||
|
||||
package = lib.mkPackageOption pkgs "efmls-configs-nvim" {
|
||||
default = [
|
||||
"vimPlugins"
|
||||
"efmls-configs-nvim"
|
||||
];
|
||||
};
|
||||
|
||||
efmLangServerPackage = lib.mkPackageOption pkgs "efm-langserver" {
|
||||
nullable = true;
|
||||
};
|
||||
|
||||
externallyManagedPackages = lib.mkOption {
|
||||
type = with lib.types; either (enum [ "all" ]) (listOf str);
|
||||
description = ''
|
||||
Linters/Formatters to skip installing with nixvim. Set to `all` to install no packages
|
||||
'';
|
||||
default = [ ];
|
||||
};
|
||||
|
||||
toolPackages = lib.pipe packaged [
|
||||
# Produce package a option for each tool
|
||||
(lib.attrsets.mapAttrs (
|
||||
name: loc:
|
||||
lib.mkPackageOption pkgs name {
|
||||
nullable = true;
|
||||
default = loc;
|
||||
}
|
||||
))
|
||||
# Filter package defaults that are not compatible with the current platform
|
||||
(lib.attrsets.mapAttrs (
|
||||
_: opt:
|
||||
if lib.meta.availableOn pkgs.stdenv.hostPlatform opt.default then
|
||||
opt
|
||||
else
|
||||
builtins.removeAttrs opt [ "defaultText" ] // { default = null; }
|
||||
))
|
||||
];
|
||||
|
||||
/*
|
||||
Users can set the options as follows:
|
||||
|
||||
{
|
||||
c = {
|
||||
linter = "cppcheck";
|
||||
formatter = ["clang-format" "uncrustify"];
|
||||
};
|
||||
go = {
|
||||
linter = ["djlint" "golangci_lint"];
|
||||
};
|
||||
}
|
||||
*/
|
||||
setup = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
freeformType = lib.types.attrsOf lib.types.anything;
|
||||
|
||||
options = lib.mapAttrs (
|
||||
_:
|
||||
lib.mapAttrs (
|
||||
kind:
|
||||
{ lang, possible }:
|
||||
let
|
||||
toolType = lib.types.maybeRaw (lib.types.enum possible);
|
||||
in
|
||||
lib.mkOption {
|
||||
type = lib.types.either toolType (lib.types.listOf toolType);
|
||||
default = [ ];
|
||||
description = "${kind} tools for ${lang}";
|
||||
}
|
||||
)
|
||||
) tools;
|
||||
};
|
||||
description = "Configuration for each filetype. Use `all` to match any filetype.";
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
config =
|
||||
let
|
||||
cfg = config.plugins.efmls-configs;
|
||||
|
||||
# Tools that have been selected by the user
|
||||
tools = lib.lists.unique (
|
||||
lib.filter lib.isString (
|
||||
lib.concatMap (
|
||||
{
|
||||
linter ? [ ],
|
||||
formatter ? [ ],
|
||||
}:
|
||||
(lib.toList linter) ++ (lib.toList formatter)
|
||||
) (lib.attrValues cfg.setup)
|
||||
)
|
||||
);
|
||||
|
||||
pkgsForTools =
|
||||
let
|
||||
partitionFn =
|
||||
if cfg.externallyManagedPackages == "all" then
|
||||
_: false
|
||||
else
|
||||
toolName: !(lib.elem toolName cfg.externallyManagedPackages);
|
||||
partition = lib.lists.partition partitionFn tools;
|
||||
in
|
||||
{
|
||||
nixvim = partition.right;
|
||||
external = partition.wrong;
|
||||
};
|
||||
|
||||
nixvimPkgs = lib.lists.partition (v: lib.hasAttr v cfg.toolPackages) pkgsForTools.nixvim;
|
||||
|
||||
mkToolValue =
|
||||
kind: opt:
|
||||
map (
|
||||
tool: if lib.isString tool then helpers.mkRaw "require 'efmls-configs.${kind}.${tool}'" else tool
|
||||
) (lib.toList opt);
|
||||
|
||||
setupOptions =
|
||||
(lib.mapAttrs (
|
||||
_:
|
||||
{
|
||||
linter ? [ ],
|
||||
formatter ? [ ],
|
||||
}:
|
||||
(mkToolValue "linters" linter) ++ (mkToolValue "formatters" formatter)
|
||||
) (lib.attrsets.filterAttrs (v: _: v != "all") cfg.setup))
|
||||
// {
|
||||
"=" =
|
||||
(mkToolValue "linters" cfg.setup.all.linter) ++ (mkToolValue "formatters" cfg.setup.all.formatter);
|
||||
};
|
||||
in
|
||||
lib.mkIf cfg.enable {
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
# TODO: print the location of the offending options
|
||||
warnings = lib.optional (nixvimPkgs.wrong != [ ]) ''
|
||||
Nixvim (plugins.efmls-configs): Following tools are not handled by nixvim, please add them to `externallyManagedPackages` to silence this:
|
||||
${lib.concatMapStringsSep "\n" (tool: " - ${tool}") nixvimPkgs.wrong}
|
||||
'';
|
||||
|
||||
plugins.lsp.servers.efm = {
|
||||
enable = true;
|
||||
extraOptions.settings.languages = setupOptions;
|
||||
};
|
||||
|
||||
extraPackages = [ cfg.efmLangServerPackage ] ++ (map (v: cfg.toolPackages.${v}) nixvimPkgs.right);
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue