plugins/none-ls: combine packaged+unpackaged lists

We can just make `packaged` nullable again.
This commit is contained in:
Matt Sturgeon 2024-07-11 22:52:53 +01:00
parent d8f3113e90
commit 4f3cd9f368
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
3 changed files with 223 additions and 226 deletions

View file

@ -5,7 +5,7 @@
pkgs, pkgs,
}: }:
let let
inherit (import ../../plugins/none-ls/packages.nix pkgs) packaged noPackage unpackaged; inherit (import ../../plugins/none-ls/packages.nix pkgs) packaged noPackage;
builtinSources = lib.trivial.importJSON "${vimPlugins.none-ls-nvim.src}/doc/builtins.json"; builtinSources = lib.trivial.importJSON "${vimPlugins.none-ls-nvim.src}/doc/builtins.json";
@ -14,11 +14,11 @@ let
toolNames = lib.unique (lib.flatten (lib.attrValues builtinSourceNames)); toolNames = lib.unique (lib.flatten (lib.attrValues builtinSourceNames));
undeclaredTool = lib.filter ( undeclaredTool = lib.filter (
name: !(lib.hasAttr name packaged || lib.elem name noPackage || lib.elem name unpackaged) name: !(lib.hasAttr name packaged || lib.elem name noPackage)
) toolNames; ) toolNames;
uselesslyDeclaredTool = lib.filter (name: !(lib.elem name toolNames)) ( uselesslyDeclaredTool = lib.filter (name: !(lib.elem name toolNames)) (
unpackaged ++ noPackage ++ (lib.attrNames packaged) noPackage ++ (lib.attrNames packaged)
); );
in in
writeText "efmls-configs-sources.nix" ( writeText "efmls-configs-sources.nix" (

View file

@ -8,7 +8,8 @@ sourceType: sourceName:
... ...
}: }:
let let
inherit (import ./packages.nix pkgs) packaged unpackaged; inherit (import ./packages.nix pkgs) packaged;
pkg = packaged.${sourceName};
cfg = config.plugins.none-ls; cfg = config.plugins.none-ls;
cfg' = config.plugins.none-ls.sources.${sourceType}.${sourceName}; cfg' = config.plugins.none-ls.sources.${sourceType}.${sourceName};
@ -22,27 +23,23 @@ in
''; '';
} }
# Only declare a package option if a package is required # Only declare a package option if a package is required
// lib.optionalAttrs (packaged ? ${sourceName} || lib.elem sourceName unpackaged) { // lib.optionalAttrs (packaged ? ${sourceName}) {
package = package = lib.mkOption (
let {
pkg = packaged.${sourceName} or null; type = lib.types.nullOr lib.types.package;
in description =
lib.mkOption ( "Package to use for ${sourceName}."
{ + (lib.optionalString (pkg == null) (
type = lib.types.nullOr lib.types.package; "\n\n"
description = + ''
"Package to use for ${sourceName}." Currently not packaged in nixpkgs.
+ (lib.optionalString (pkg == null) ( Either set this to `null` and install ${sourceName} outside of nix,
"\n\n" or set this to a custom nix package.
+ '' ''
Currently not packaged in nixpkgs. ));
Either set this to `null` and install ${sourceName} outside of nix, }
or set this to a custom nix package. // lib.optionalAttrs (pkg != null) { default = pkg; }
'' );
));
}
// lib.optionalAttrs (pkg != null) { default = pkg; }
);
}; };
config = lib.mkIf (cfg.enable && cfg'.enable) { config = lib.mkIf (cfg.enable && cfg'.enable) {

View file

@ -1,46 +1,4 @@
pkgs: { pkgs: {
# builtin sources that are not packaged in nixpkgs
unpackaged = [
"blade_formatter"
"bsfmt"
"bslint"
"cljstyle"
"cueimports"
"erb_lint"
"findent"
"forge_fmt"
"gccdiag"
"gersemi"
"markuplint"
"mlint"
"nginx_beautifier"
"npm_groovy_lint"
"ocdc"
"packer"
"perlimports"
"pint"
"pretty_php"
"purs_tidy"
"pyink"
"reek"
"regal"
"remark"
"rescript"
"saltlint"
"solhint"
"spectral"
"sqlfmt"
"sql_formatter"
"styler"
"stylint"
"swiftformat"
"swiftlint"
"textidote"
"textlint"
"twigcs"
"vacuum"
];
# builtin sources that don't require a package # builtin sources that don't require a package
noPackage = [ noPackage = [
"gitrebase" "gitrebase"
@ -60,163 +18,205 @@ pkgs: {
]; ];
# nixpkgs packages for a given source # nixpkgs packages for a given source
packaged = { packaged =
inherit (pkgs) {
actionlint inherit (pkgs)
alejandra actionlint
asmfmt alejandra
astyle asmfmt
bibclean astyle
biome bibclean
buf biome
cbfmt buf
checkmake cbfmt
checkstyle checkmake
clazy checkstyle
codespell clazy
commitlint codespell
cppcheck commitlint
csharpier cppcheck
deadnix csharpier
dfmt deadnix
djhtml dfmt
djlint djhtml
erlfmt djlint
fantomas erlfmt
fish fantomas
fnlfmt fish
fprettify fnlfmt
gitlint fprettify
gofumpt gitlint
golines gofumpt
hadolint golines
hclfmt hadolint
isort hclfmt
joker isort
just joker
ktlint just
leptosfmt ktlint
mdformat leptosfmt
mdl mdformat
mypy mdl
pmd mypy
prettierd pmd
proselint prettierd
protolint proselint
pylint protolint
revive pylint
rstcheck revive
rubocop rstcheck
rubyfmt rubocop
rufo rubyfmt
rustywind rufo
scalafmt rustywind
selene scalafmt
semgrep selene
shellharden semgrep
shfmt shellharden
smlfmt shfmt
sqlfluff smlfmt
statix sqlfluff
stylelint statix
stylua stylelint
tfsec stylua
topiary tfsec
treefmt topiary
trivy treefmt
typstfmt trivy
typstyle typstfmt
uncrustify typstyle
usort uncrustify
vale usort
verilator vale
yamlfix verilator
yamlfmt yamlfix
yamllint yamlfmt
yapf yamllint
zprint yapf
zsh zprint
; zsh
inherit (pkgs.nodePackages) alex prettier; ;
inherit (pkgs.python3.pkgs) black; inherit (pkgs.nodePackages) alex prettier;
inherit (pkgs.phpPackages) phpmd phpstan; inherit (pkgs.python3.pkgs) black;
inherit (pkgs.rubyPackages) htmlbeautifier; inherit (pkgs.phpPackages) phpmd phpstan;
inherit (pkgs.ocamlPackages) ocamlformat; inherit (pkgs.rubyPackages) htmlbeautifier;
ansiblelint = pkgs.ansible-lint; inherit (pkgs.ocamlPackages) ocamlformat;
bean_check = pkgs.beancount; ansiblelint = pkgs.ansible-lint;
bean_format = pkgs.beancount; bean_check = pkgs.beancount;
blackd = pkgs.black; bean_format = pkgs.beancount;
buildifier = pkgs.bazel-buildtools; blackd = pkgs.black;
cfn_lint = pkgs.python3.pkgs.cfn-lint; buildifier = pkgs.bazel-buildtools;
clang_format = pkgs.clang-tools; cfn_lint = pkgs.python3.pkgs.cfn-lint;
clj_kondo = pkgs.clj-kondo; clang_format = pkgs.clang-tools;
cmake_format = pkgs.cmake-format; clj_kondo = pkgs.clj-kondo;
cmake_lint = pkgs.cmake-format; cmake_format = pkgs.cmake-format;
credo = pkgs.elixir; cmake_lint = pkgs.cmake-format;
crystal_format = pkgs.crystal; credo = pkgs.elixir;
cue_fmt = pkgs.cue; crystal_format = pkgs.crystal;
d2_fmt = pkgs.d2; cue_fmt = pkgs.cue;
dart_format = pkgs.dart; d2_fmt = pkgs.d2;
dictionary = pkgs.curl; dart_format = pkgs.dart;
dotenv_linter = pkgs.dotenv-linter; dictionary = pkgs.curl;
dxfmt = pkgs.dioxus-cli; dotenv_linter = pkgs.dotenv-linter;
editorconfig_checker = pkgs.editorconfig-checker; dxfmt = pkgs.dioxus-cli;
elm_format = pkgs.elmPackages.elm-format; editorconfig_checker = pkgs.editorconfig-checker;
emacs_scheme_mode = pkgs.emacs; elm_format = pkgs.elmPackages.elm-format;
emacs_vhdl_mode = pkgs.emacs; emacs_scheme_mode = pkgs.emacs;
erb_format = pkgs.rubyPackages.erb-formatter; emacs_vhdl_mode = pkgs.emacs;
fish_indent = pkgs.fish; erb_format = pkgs.rubyPackages.erb-formatter;
format_r = pkgs.R; fish_indent = pkgs.fish;
# TODO: Added 2024-06-13; remove 2024-09-13 format_r = pkgs.R;
# Nixpkgs renamed to _3 & _4 without maintaining an alias # TODO: Added 2024-06-13; remove 2024-09-13
# Out of sync lock files could be using either attr name... # Nixpkgs renamed to _3 & _4 without maintaining an alias
gdformat = pkgs.gdtoolkit_4 or pkgs.gdtoolkit; # Out of sync lock files could be using either attr name...
gdlint = pkgs.gdtoolkit_4 or pkgs.gdtoolkit; gdformat = pkgs.gdtoolkit_4 or pkgs.gdtoolkit;
gitsigns = pkgs.git; gdlint = pkgs.gdtoolkit_4 or pkgs.gdtoolkit;
gleam_format = pkgs.gleam; gitsigns = pkgs.git;
glslc = pkgs.shaderc; gleam_format = pkgs.gleam;
gn_format = pkgs.gn; glslc = pkgs.shaderc;
gofmt = pkgs.go; gn_format = pkgs.gn;
goimports = pkgs.gotools; gofmt = pkgs.go;
goimports_reviser = pkgs.goimports-reviser; goimports = pkgs.gotools;
golangci_lint = pkgs.golangci-lint; goimports_reviser = pkgs.goimports-reviser;
google_java_format = pkgs.google-java-format; golangci_lint = pkgs.golangci-lint;
haml_lint = pkgs.mastodon; google_java_format = pkgs.google-java-format;
haxe_formatter = pkgs.haxe; haml_lint = pkgs.mastodon;
isortd = pkgs.isort; haxe_formatter = pkgs.haxe;
ltrs = pkgs.languagetool-rust; isortd = pkgs.isort;
markdownlint_cli2 = pkgs.markdownlint-cli2; ltrs = pkgs.languagetool-rust;
markdownlint = pkgs.nodePackages.markdownlint-cli; markdownlint_cli2 = pkgs.markdownlint-cli2;
mix = pkgs.elixir; markdownlint = pkgs.nodePackages.markdownlint-cli;
nimpretty = pkgs.nim; mix = pkgs.elixir;
nixfmt = pkgs.nixfmt-classic; nimpretty = pkgs.nim;
nixpkgs_fmt = pkgs.nixpkgs-fmt; nixfmt = pkgs.nixfmt-classic;
opacheck = pkgs.open-policy-agent; nixpkgs_fmt = pkgs.nixpkgs-fmt;
opentofu_fmt = pkgs.opentofu; opacheck = pkgs.open-policy-agent;
pg_format = pkgs.pgformatter; opentofu_fmt = pkgs.opentofu;
phpcbf = pkgs.phpPackages.php-codesniffer; pg_format = pkgs.pgformatter;
phpcsfixer = pkgs.phpPackages.php-cs-fixer; phpcbf = pkgs.phpPackages.php-codesniffer;
phpcs = pkgs.phpPackages.php-codesniffer; phpcsfixer = pkgs.phpPackages.php-cs-fixer;
prisma_format = pkgs.nodePackages.prisma; phpcs = pkgs.phpPackages.php-codesniffer;
ptop = pkgs.fpc; prisma_format = pkgs.nodePackages.prisma;
puppet_lint = pkgs.puppet-lint; ptop = pkgs.fpc;
qmlformat = pkgs.qt6.qtdeclarative; puppet_lint = pkgs.puppet-lint;
qmllint = pkgs.qt6.qtdeclarative; qmlformat = pkgs.qt6.qtdeclarative;
racket_fixw = pkgs.racket; qmllint = pkgs.qt6.qtdeclarative;
raco_fmt = pkgs.racket; racket_fixw = pkgs.racket;
rego = pkgs.open-policy-agent; raco_fmt = pkgs.racket;
rpmspec = pkgs.rpm; rego = pkgs.open-policy-agent;
sqlformat = pkgs.python3.pkgs.sqlparse; rpmspec = pkgs.rpm;
staticcheck = pkgs.go-tools; sqlformat = pkgs.python3.pkgs.sqlparse;
surface = pkgs.elixir; staticcheck = pkgs.go-tools;
swift_format = pkgs.swift-format; surface = pkgs.elixir;
teal = pkgs.luaPackages.tl; swift_format = pkgs.swift-format;
terraform_fmt = pkgs.terraform; teal = pkgs.luaPackages.tl;
terraform_validate = pkgs.terraform; terraform_fmt = pkgs.terraform;
tidy = pkgs.html-tidy; terraform_validate = pkgs.terraform;
verible_verilog_format = pkgs.verible; tidy = pkgs.html-tidy;
vint = pkgs.vim-vint; verible_verilog_format = pkgs.verible;
write_good = pkgs.write-good; vint = pkgs.vim-vint;
xmllint = pkgs.libxml2; write_good = pkgs.write-good;
}; xmllint = pkgs.libxml2;
}
# builtin sources that are not packaged in nixpkgs
// pkgs.lib.genAttrs [
"blade_formatter"
"bsfmt"
"bslint"
"cljstyle"
"cueimports"
"erb_lint"
"findent"
"forge_fmt"
"gccdiag"
"gersemi"
"markuplint"
"mlint"
"nginx_beautifier"
"npm_groovy_lint"
"ocdc"
"packer"
"perlimports"
"pint"
"pretty_php"
"purs_tidy"
"pyink"
"reek"
"regal"
"remark"
"rescript"
"saltlint"
"solhint"
"spectral"
"sqlfmt"
"sql_formatter"
"styler"
"stylint"
"swiftformat"
"swiftlint"
"textidote"
"textlint"
"twigcs"
"vacuum"
] (_: null);
} }