mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-16 04:04:34 +02:00
plugins/none-ls: Adapt to autogenerated builtin list
This commit is contained in:
parent
776835b066
commit
930f5fdd21
1 changed files with 38 additions and 291 deletions
|
@ -5,273 +5,48 @@
|
|||
helpers,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
noneLsBuiltins = builtins.fromJSON (
|
||||
builtins.readFile "${pkgs.vimPlugins.none-ls-nvim.src}/doc/builtins.json"
|
||||
);
|
||||
noneLsBuiltins = import ../../generated/none-ls.nix;
|
||||
|
||||
# Can contain either:
|
||||
# - a package
|
||||
# - null if the source is not present in nixpkgs
|
||||
# - false if this source does not need a package
|
||||
builtinPackages = {
|
||||
inherit (pkgs)
|
||||
actionlint
|
||||
alejandra
|
||||
asmfmt
|
||||
astyle
|
||||
bibclean
|
||||
biome
|
||||
buf
|
||||
cbfmt
|
||||
checkmake
|
||||
checkstyle
|
||||
clazy
|
||||
codespell
|
||||
commitlint
|
||||
cppcheck
|
||||
csharpier
|
||||
deadnix
|
||||
dfmt
|
||||
djhtml
|
||||
djlint
|
||||
erlfmt
|
||||
fantomas
|
||||
fish
|
||||
fnlfmt
|
||||
fprettify
|
||||
gitlint
|
||||
gofumpt
|
||||
golines
|
||||
hadolint
|
||||
hclfmt
|
||||
isort
|
||||
joker
|
||||
just
|
||||
ktlint
|
||||
leptosfmt
|
||||
mdformat
|
||||
mdl
|
||||
mypy
|
||||
pmd
|
||||
prettierd
|
||||
proselint
|
||||
protolint
|
||||
pylint
|
||||
revive
|
||||
rstcheck
|
||||
rubocop
|
||||
rubyfmt
|
||||
rufo
|
||||
rustywind
|
||||
scalafmt
|
||||
selene
|
||||
semgrep
|
||||
shellharden
|
||||
shfmt
|
||||
smlfmt
|
||||
sqlfluff
|
||||
statix
|
||||
stylelint
|
||||
stylua
|
||||
tfsec
|
||||
topiary
|
||||
treefmt
|
||||
trivy
|
||||
typstfmt
|
||||
typstyle
|
||||
uncrustify
|
||||
usort
|
||||
vale
|
||||
verilator
|
||||
yamlfix
|
||||
yamlfmt
|
||||
yamllint
|
||||
yapf
|
||||
zprint
|
||||
zsh
|
||||
;
|
||||
inherit (pkgs.nodePackages) alex prettier;
|
||||
inherit (pkgs.python3.pkgs) black;
|
||||
inherit (pkgs.phpPackages) phpmd phpstan;
|
||||
inherit (pkgs.rubyPackages) htmlbeautifier;
|
||||
inherit (pkgs.ocamlPackages) ocamlformat;
|
||||
ansiblelint = pkgs.ansible-lint;
|
||||
bean_check = pkgs.beancount;
|
||||
bean_format = pkgs.beancount;
|
||||
blackd = pkgs.black;
|
||||
buildifier = pkgs.bazel-buildtools;
|
||||
cfn_lint = pkgs.python3.pkgs.cfn-lint;
|
||||
clang_format = pkgs.clang-tools;
|
||||
clj_kondo = pkgs.clj-kondo;
|
||||
cmake_format = pkgs.cmake-format;
|
||||
cmake_lint = pkgs.cmake-format;
|
||||
credo = pkgs.elixir;
|
||||
crystal_format = pkgs.crystal;
|
||||
cue_fmt = pkgs.cue;
|
||||
d2_fmt = pkgs.d2;
|
||||
dart_format = pkgs.dart;
|
||||
dictionary = pkgs.curl;
|
||||
dotenv_linter = pkgs.dotenv-linter;
|
||||
dxfmt = pkgs.dioxus-cli;
|
||||
editorconfig_checker = pkgs.editorconfig-checker;
|
||||
elm_format = pkgs.elmPackages.elm-format;
|
||||
emacs_scheme_mode = pkgs.emacs;
|
||||
emacs_vhdl_mode = pkgs.emacs;
|
||||
erb_format = pkgs.rubyPackages.erb-formatter;
|
||||
fish_indent = pkgs.fish;
|
||||
format_r = pkgs.R;
|
||||
# TODO: Added 2024-06-13; remove 2024-09-13
|
||||
# Nixpkgs renamed to _3 & _4 without maintaining an alias
|
||||
# Out of sync lock files could be using either attr name...
|
||||
gdformat = pkgs.gdtoolkit_4 or pkgs.gdtoolkit;
|
||||
gdlint = pkgs.gdtoolkit_4 or pkgs.gdtoolkit;
|
||||
gitsigns = pkgs.git;
|
||||
gleam_format = pkgs.gleam;
|
||||
glslc = pkgs.shaderc;
|
||||
gn_format = pkgs.gn;
|
||||
gofmt = pkgs.go;
|
||||
goimports = pkgs.gotools;
|
||||
goimports_reviser = pkgs.goimports-reviser;
|
||||
golangci_lint = pkgs.golangci-lint;
|
||||
google_java_format = pkgs.google-java-format;
|
||||
haml_lint = pkgs.mastodon;
|
||||
haxe_formatter = pkgs.haxe;
|
||||
isortd = pkgs.isort;
|
||||
ltrs = pkgs.languagetool-rust;
|
||||
markdownlint_cli2 = pkgs.markdownlint-cli2;
|
||||
markdownlint = pkgs.nodePackages.markdownlint-cli;
|
||||
mix = pkgs.elixir;
|
||||
nimpretty = pkgs.nim;
|
||||
nixfmt = pkgs.nixfmt-classic;
|
||||
nixpkgs_fmt = pkgs.nixpkgs-fmt;
|
||||
opacheck = pkgs.open-policy-agent;
|
||||
opentofu_fmt = pkgs.opentofu;
|
||||
pg_format = pkgs.pgformatter;
|
||||
phpcbf = pkgs.phpPackages.php-codesniffer;
|
||||
phpcsfixer = pkgs.phpPackages.php-cs-fixer;
|
||||
phpcs = pkgs.phpPackages.php-codesniffer;
|
||||
prisma_format = pkgs.nodePackages.prisma;
|
||||
ptop = pkgs.fpc;
|
||||
puppet_lint = pkgs.puppet-lint;
|
||||
qmlformat = pkgs.qt6.qtdeclarative;
|
||||
qmllint = pkgs.qt6.qtdeclarative;
|
||||
racket_fixw = pkgs.racket;
|
||||
raco_fmt = pkgs.racket;
|
||||
rego = pkgs.open-policy-agent;
|
||||
rpmspec = pkgs.rpm;
|
||||
sqlformat = pkgs.python3.pkgs.sqlparse;
|
||||
staticcheck = pkgs.go-tools;
|
||||
surface = pkgs.elixir;
|
||||
swift_format = pkgs.swift-format;
|
||||
teal = pkgs.luaPackages.tl;
|
||||
terraform_fmt = pkgs.terraform;
|
||||
terraform_validate = pkgs.terraform;
|
||||
tidy = pkgs.html-tidy;
|
||||
verible_verilog_format = pkgs.verible;
|
||||
vint = pkgs.vim-vint;
|
||||
write_good = pkgs.write-good;
|
||||
xmllint = pkgs.libxml2;
|
||||
inherit (import ./packages.nix pkgs) packaged unpackaged;
|
||||
|
||||
# Sources not present in nixpkgs
|
||||
blade_formatter = null;
|
||||
bsfmt = null;
|
||||
bslint = null;
|
||||
cljstyle = null;
|
||||
cueimports = null;
|
||||
erb_lint = null;
|
||||
findent = null;
|
||||
forge_fmt = null;
|
||||
gccdiag = null;
|
||||
gersemi = null;
|
||||
markuplint = null;
|
||||
mlint = null;
|
||||
nginx_beautifier = null;
|
||||
npm_groovy_lint = null;
|
||||
ocdc = null;
|
||||
packer = null;
|
||||
perlimports = null;
|
||||
pint = null;
|
||||
pretty_php = null;
|
||||
purs_tidy = null;
|
||||
pyink = null;
|
||||
reek = null;
|
||||
regal = null;
|
||||
remark = null;
|
||||
rescript = null;
|
||||
saltlint = null;
|
||||
solhint = null;
|
||||
spectral = null;
|
||||
sqlfmt = null;
|
||||
sql_formatter = null;
|
||||
styler = null;
|
||||
stylint = null;
|
||||
swiftformat = null;
|
||||
swiftlint = null;
|
||||
textidote = null;
|
||||
textlint = null;
|
||||
twigcs = null;
|
||||
vacuum = null;
|
||||
|
||||
# Sources without packages
|
||||
gitrebase = false;
|
||||
# TODO: Requires the go tree-sitter parser
|
||||
gomodifytags = false;
|
||||
# TODO: Requires the go tree-sitter parser
|
||||
impl = false;
|
||||
luasnip = false;
|
||||
printenv = false;
|
||||
refactoring = false;
|
||||
spell = false;
|
||||
tags = false;
|
||||
todo_comments = false;
|
||||
trail_space = false;
|
||||
ts_node_action = false;
|
||||
vsnip = false;
|
||||
};
|
||||
|
||||
# Check if the package is set to `false` or not
|
||||
hasBuiltinPackage =
|
||||
source:
|
||||
if builtins.hasAttr source builtinPackages then
|
||||
!(builtins.isBool builtinPackages.${source})
|
||||
else
|
||||
true;
|
||||
|
||||
builtinPackage = source: builtinPackages.${source} or null;
|
||||
# Does this builitin require a package ?
|
||||
builitinNeedsPackage = source: lib.hasAttr source packaged || lib.elem source unpackaged;
|
||||
in
|
||||
{
|
||||
imports = [ ./prettier.nix ];
|
||||
|
||||
options.plugins.none-ls.sources = builtins.mapAttrs (
|
||||
options.plugins.none-ls.sources = lib.mapAttrs (
|
||||
sourceType: sources:
|
||||
builtins.mapAttrs (
|
||||
source: _:
|
||||
{
|
||||
enable = mkEnableOption "the ${source} ${sourceType} source for none-ls";
|
||||
withArgs = helpers.mkNullOrOption helpers.nixvimTypes.strLua ''
|
||||
Raw Lua code passed as an argument to the source's `with` method.
|
||||
'';
|
||||
}
|
||||
// lib.optionalAttrs (hasBuiltinPackage source) {
|
||||
package =
|
||||
let
|
||||
pkg = builtinPackage source;
|
||||
in
|
||||
mkOption (
|
||||
{
|
||||
type = types.nullOr types.package;
|
||||
description =
|
||||
"Package to use for ${source} by none-ls. "
|
||||
+ (lib.optionalString (pkg == null) ''
|
||||
Not handled in nixvim, either install externally and set to null or set the option with a derivation.
|
||||
'');
|
||||
}
|
||||
// optionalAttrs (pkg != null) { default = pkg; }
|
||||
);
|
||||
}
|
||||
) sources
|
||||
lib.listToAttrs (
|
||||
lib.map (source: {
|
||||
name = source;
|
||||
value =
|
||||
{
|
||||
enable = lib.mkEnableOption "the ${source} ${sourceType} source for none-ls";
|
||||
withArgs = helpers.mkNullOrOption helpers.nixvimTypes.strLua ''
|
||||
Raw Lua code passed as an argument to the source's `with` method.
|
||||
'';
|
||||
}
|
||||
// lib.optionalAttrs (builitinNeedsPackage source) {
|
||||
package =
|
||||
let
|
||||
pkg = packaged.${source} or null;
|
||||
in
|
||||
lib.mkOption (
|
||||
{
|
||||
type = lib.types.nullOr lib.types.package;
|
||||
description =
|
||||
"Package to use for ${source} by none-ls. "
|
||||
+ (lib.optionalString (pkg == null) ''
|
||||
Not handled in nixvim, either install externally and set to null or set the option with a derivation.
|
||||
'');
|
||||
}
|
||||
// lib.optionalAttrs (pkg != null) { default = pkg; }
|
||||
);
|
||||
};
|
||||
}) sources
|
||||
)
|
||||
) noneLsBuiltins;
|
||||
|
||||
config =
|
||||
|
@ -288,36 +63,8 @@ in
|
|||
|
||||
enabledSources = builtins.filter (source: source.enable) flattenedSources;
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
# ASSERTIONS FOR DEVELOPMENT PURPOSES: Any failure should be caught by CI before deployment.
|
||||
# Ensure that the keys of the manually declared `builtinPackages` match the ones from upstream.
|
||||
warnings =
|
||||
let
|
||||
upstreamToolNames = unique (flatten (mapAttrsToList (_: attrNames) noneLsBuiltins));
|
||||
localToolNames = attrNames builtinPackages;
|
||||
|
||||
undeclaredToolNames =
|
||||
filter
|
||||
# Keep tool names which are not declared locally
|
||||
(toolName: !(elem toolName localToolNames))
|
||||
upstreamToolNames;
|
||||
|
||||
uselesslyDeclaredToolNames =
|
||||
filter
|
||||
# Keep tool names which are not in upstream
|
||||
(toolName: !(elem toolName upstreamToolNames))
|
||||
localToolNames;
|
||||
in
|
||||
(optional ((length undeclaredToolNames) > 0) ''
|
||||
[DEV] Nixvim (plugins.none-ls): Some tools from upstream are not declared locally in `builtinPackages`.
|
||||
-> [${concatStringsSep ", " undeclaredToolNames}]
|
||||
'')
|
||||
++ (optional ((length uselesslyDeclaredToolNames) > 0) ''
|
||||
[DEV] Nixvim (plugins.none-ls): Some tools are declared locally but are not in the upstream list of supported plugins.
|
||||
-> [${concatStringsSep ", " uselesslyDeclaredToolNames}]
|
||||
'');
|
||||
|
||||
plugins.none-ls.settings.sources = mkIf (enabledSources != [ ]) (
|
||||
lib.mkIf cfg.enable {
|
||||
plugins.none-ls.settings.sources = lib.mkIf (enabledSources != [ ]) (
|
||||
map (
|
||||
{
|
||||
sourceType,
|
||||
|
@ -326,10 +73,10 @@ in
|
|||
...
|
||||
}:
|
||||
"require('null-ls').builtins.${sourceType}.${sourceName}"
|
||||
+ optionalString (withArgs != null) ".with(${withArgs})"
|
||||
+ lib.optionalString (withArgs != null) ".with(${withArgs})"
|
||||
) enabledSources
|
||||
);
|
||||
plugins.gitsigns.enable = mkIf gitsignsEnabled true;
|
||||
plugins.gitsigns.enable = lib.mkIf gitsignsEnabled true;
|
||||
extraPackages = map (source: source.package or null) enabledSources;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue