mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-28 03:20:08 +02:00
plugigns/efmls-configs: Use the generated source files
This commit is contained in:
parent
01d9178788
commit
99f272d8c7
1 changed files with 51 additions and 189 deletions
|
@ -5,146 +5,34 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
|
||||||
let
|
let
|
||||||
tools = trivial.importJSON "${pkgs.vimPlugins.efmls-configs-nvim.src}/doc/supported-list.json";
|
tools = import ../../../generated/efmls-configs.nix;
|
||||||
|
packagingStatus = import ./efmls-configs-pkgs.nix pkgs;
|
||||||
|
|
||||||
languages = builtins.attrNames tools;
|
|
||||||
|
|
||||||
# Mapping of tool name to the nixpkgs package (if any)
|
|
||||||
allToolPkgs = with pkgs; {
|
|
||||||
inherit
|
|
||||||
actionlint
|
|
||||||
alejandra
|
|
||||||
ameba
|
|
||||||
astyle
|
|
||||||
bashate
|
|
||||||
beautysh
|
|
||||||
biome
|
|
||||||
black
|
|
||||||
buf
|
|
||||||
cbfmt
|
|
||||||
checkmake
|
|
||||||
clazy
|
|
||||||
codespell
|
|
||||||
cppcheck
|
|
||||||
cpplint
|
|
||||||
dfmt
|
|
||||||
djlint
|
|
||||||
dmd
|
|
||||||
dprint
|
|
||||||
fish
|
|
||||||
flawfinder
|
|
||||||
fnlfmt
|
|
||||||
gcc
|
|
||||||
gitlint
|
|
||||||
gofumpt
|
|
||||||
golines
|
|
||||||
golint
|
|
||||||
hadolint
|
|
||||||
isort
|
|
||||||
joker
|
|
||||||
jq
|
|
||||||
languagetool
|
|
||||||
mypy
|
|
||||||
php
|
|
||||||
prettierd
|
|
||||||
prettypst
|
|
||||||
proselint
|
|
||||||
protolint
|
|
||||||
pylint
|
|
||||||
rubocop
|
|
||||||
ruff
|
|
||||||
rustfmt
|
|
||||||
scalafmt
|
|
||||||
selene
|
|
||||||
shellcheck
|
|
||||||
shellharden
|
|
||||||
shfmt
|
|
||||||
smlfmt
|
|
||||||
sqlfluff
|
|
||||||
statix
|
|
||||||
stylua
|
|
||||||
taplo
|
|
||||||
typstfmt
|
|
||||||
typstyle
|
|
||||||
uncrustify
|
|
||||||
vale
|
|
||||||
yamllint
|
|
||||||
yapf
|
|
||||||
;
|
|
||||||
inherit (python3.pkgs)
|
|
||||||
autopep8
|
|
||||||
flake8
|
|
||||||
mdformat
|
|
||||||
vulture
|
|
||||||
;
|
|
||||||
inherit (nodePackages)
|
|
||||||
eslint
|
|
||||||
eslint_d
|
|
||||||
prettier
|
|
||||||
alex
|
|
||||||
sql-formatter
|
|
||||||
stylelint
|
|
||||||
textlint
|
|
||||||
write-good
|
|
||||||
;
|
|
||||||
inherit (phpPackages) phan phpstan psalm;
|
|
||||||
inherit (luaPackages) luacheck;
|
|
||||||
inherit (haskellPackages) fourmolu;
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
# Filter packages that are not compatible with the current platform
|
# Filter packages that are not compatible with the current platform
|
||||||
toolPkgs = filterAttrs (a: pkg: meta.availableOn pkgs.stdenv.hostPlatform pkg) allToolPkgs;
|
toolPkgs = lib.filterAttrs (
|
||||||
|
a: pkg: lib.meta.availableOn pkgs.stdenv.hostPlatform pkg
|
||||||
|
) packagingStatus.packaged;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.plugins.efmls-configs = {
|
options.plugins.efmls-configs = {
|
||||||
enable = mkEnableOption "efmls-configs, premade configurations for efm-langserver";
|
enable = lib.mkEnableOption "efmls-configs, premade configurations for efm-langserver";
|
||||||
|
|
||||||
package = helpers.mkPluginPackageOption "efmls-configs-nvim" pkgs.vimPlugins.efmls-configs-nvim;
|
package = helpers.mkPluginPackageOption "efmls-configs-nvim" pkgs.vimPlugins.efmls-configs-nvim;
|
||||||
|
|
||||||
externallyManagedPackages = mkOption {
|
externallyManagedPackages = lib.mkOption {
|
||||||
type = types.either (types.enum [ "all" ]) (types.listOf types.str);
|
type = with lib.types; either (enum [ "all" ]) (listOf str);
|
||||||
description = ''
|
description = ''
|
||||||
Linters/Formatters to skip installing with nixvim. Set to `all` to install no packages
|
Linters/Formatters to skip installing with nixvim. Set to `all` to install no packages
|
||||||
'';
|
'';
|
||||||
default = [ ];
|
default = [ ];
|
||||||
};
|
};
|
||||||
|
|
||||||
toolPackages = attrsets.mapAttrs (
|
toolPackages = lib.attrsets.mapAttrs (
|
||||||
tool: pkg:
|
tool: pkg:
|
||||||
mkOption {
|
helpers.mkPackageOption {
|
||||||
type = types.package;
|
name = tool;
|
||||||
default = pkg;
|
default = pkg;
|
||||||
description = "Package for ${tool}";
|
|
||||||
}
|
}
|
||||||
) toolPkgs;
|
) toolPkgs;
|
||||||
|
|
||||||
|
@ -161,51 +49,25 @@ in
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
setup =
|
setup = lib.mkOption {
|
||||||
let
|
type = lib.types.submodule {
|
||||||
languageTools =
|
freeformType = lib.types.attrsOf lib.types.anything;
|
||||||
lang: kind: map (v: v.name) (if hasAttr kind tools.${lang} then tools.${lang}.${kind} else [ ]);
|
|
||||||
|
|
||||||
miscLinters = languageTools "misc" "linters";
|
options = lib.mapAttrs (
|
||||||
miscFormatters = languageTools "misc" "formatters";
|
_: value:
|
||||||
|
lib.mapAttrs (
|
||||||
mkChooseOption =
|
kind:
|
||||||
lang: kind: possible:
|
{ lang, possible }:
|
||||||
let
|
let
|
||||||
toolType = with types; either (enum possible) helpers.nixvimTypes.rawLua;
|
toolType = helpers.nixvimTypes.maybeRaw (lib.types.enum possible);
|
||||||
in
|
in
|
||||||
mkOption {
|
lib.mkOption {
|
||||||
type = with types; either toolType (listOf toolType);
|
type = lib.types.either toolType (lib.types.listOf toolType);
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "${kind} tools for ${lang}";
|
description = "${kind} tools for ${lang}";
|
||||||
};
|
|
||||||
in
|
|
||||||
mkOption {
|
|
||||||
type = types.submodule {
|
|
||||||
freeformType = types.attrs;
|
|
||||||
|
|
||||||
options =
|
|
||||||
(listToAttrs (
|
|
||||||
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
|
) value
|
||||||
))
|
) tools;
|
||||||
// {
|
|
||||||
all = {
|
|
||||||
linter = mkChooseOption "all languages" "linter" miscLinters;
|
|
||||||
formatter = mkChooseOption "all languages" "formatter" miscFormatters;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
description = "Configuration for each filetype. Use `all` to match any filetype.";
|
description = "Configuration for each filetype. Use `all` to match any filetype.";
|
||||||
default = { };
|
default = { };
|
||||||
|
@ -216,16 +78,16 @@ in
|
||||||
cfg = config.plugins.efmls-configs;
|
cfg = config.plugins.efmls-configs;
|
||||||
|
|
||||||
# Tools that have been selected by the user
|
# Tools that have been selected by the user
|
||||||
tools = lists.unique (
|
tools = lib.lists.unique (
|
||||||
filter isString (
|
lib.filter lib.isString (
|
||||||
concatLists (
|
lib.concatLists (
|
||||||
map (
|
map (
|
||||||
{
|
{
|
||||||
linter ? [ ],
|
linter ? [ ],
|
||||||
formatter ? [ ],
|
formatter ? [ ],
|
||||||
}:
|
}:
|
||||||
(toList linter) ++ (toList formatter)
|
(lib.toList linter) ++ (lib.toList formatter)
|
||||||
) (attrValues cfg.setup)
|
) (lib.attrValues cfg.setup)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -236,43 +98,43 @@ in
|
||||||
if cfg.externallyManagedPackages == "all" then
|
if cfg.externallyManagedPackages == "all" then
|
||||||
_: false
|
_: false
|
||||||
else
|
else
|
||||||
toolName: !(elem toolName cfg.externallyManagedPackages);
|
toolName: !(lib.elem toolName cfg.externallyManagedPackages);
|
||||||
partition = lists.partition partitionFn tools;
|
partition = lib.lists.partition partitionFn tools;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
nixvim = partition.right;
|
nixvim = partition.right;
|
||||||
external = partition.wrong;
|
external = partition.wrong;
|
||||||
};
|
};
|
||||||
|
|
||||||
nixvimPkgs = lists.partition (v: hasAttr v cfg.toolPackages) pkgsForTools.nixvim;
|
nixvimPkgs = lib.lists.partition (v: lib.hasAttr v cfg.toolPackages) pkgsForTools.nixvim;
|
||||||
|
|
||||||
mkToolOption =
|
mkToolValue =
|
||||||
kind: opt:
|
kind: opt:
|
||||||
map (
|
map (
|
||||||
tool: if isString tool then helpers.mkRaw "require 'efmls-configs.${kind}.${tool}'" else tool
|
tool: if lib.isString tool then helpers.mkRaw "require 'efmls-configs.${kind}.${tool}'" else tool
|
||||||
) (toList opt);
|
) (lib.toList opt);
|
||||||
|
|
||||||
setupOptions =
|
setupOptions =
|
||||||
(mapAttrs (
|
(lib.mapAttrs (
|
||||||
_:
|
_:
|
||||||
{
|
{
|
||||||
linter ? [ ],
|
linter ? [ ],
|
||||||
formatter ? [ ],
|
formatter ? [ ],
|
||||||
}:
|
}:
|
||||||
(mkToolOption "linters" linter) ++ (mkToolOption "formatters" formatter)
|
(mkToolValue "linters" linter) ++ (mkToolValue "formatters" formatter)
|
||||||
) (attrsets.filterAttrs (v: _: v != "all") cfg.setup))
|
) (lib.attrsets.filterAttrs (v: _: v != "all") cfg.setup))
|
||||||
// {
|
// {
|
||||||
"=" =
|
"=" =
|
||||||
(mkToolOption "linters" cfg.setup.all.linter)
|
(mkToolValue "linters" cfg.setup.all.linter) ++ (mkToolValue "formatters" cfg.setup.all.formatter);
|
||||||
++ (mkToolOption "formatters" cfg.setup.all.formatter);
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
mkIf cfg.enable {
|
lib.mkIf cfg.enable {
|
||||||
extraPlugins = [ cfg.package ];
|
extraPlugins = [ cfg.package ];
|
||||||
|
|
||||||
warnings = optional ((length nixvimPkgs.wrong) > 0) ''
|
# TODO: print the location of the offending options
|
||||||
|
warnings = lib.optional ((lib.length nixvimPkgs.wrong) > 0) ''
|
||||||
Nixvim (plugins.efmls-configs): Following tools are not handled by nixvim, please add them to externallyManagedPackages to silence this:
|
Nixvim (plugins.efmls-configs): Following tools are not handled by nixvim, please add them to externallyManagedPackages to silence this:
|
||||||
${concatStringsSep " " nixvimPkgs.wrong}
|
${lib.concatStringsSep " " nixvimPkgs.wrong}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
plugins.lsp.servers.efm = {
|
plugins.lsp.servers.efm = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue