2023-02-20 11:42:13 +01:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
2024-03-01 13:24:14 +01:00
|
|
|
helpers,
|
2023-02-20 11:42:13 +01:00
|
|
|
...
|
2023-12-02 17:58:49 +01:00
|
|
|
}:
|
|
|
|
with lib;
|
|
|
|
let
|
2024-03-01 13:24:14 +01:00
|
|
|
noneLsBuiltins = builtins.fromJSON (
|
|
|
|
builtins.readFile "${pkgs.vimPlugins.none-ls-nvim.src}/doc/builtins.json"
|
|
|
|
);
|
|
|
|
|
|
|
|
# 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
|
|
|
|
uncrustify
|
|
|
|
usort
|
|
|
|
vale
|
|
|
|
verilator
|
2024-03-06 10:59:16 +01:00
|
|
|
yamlfix
|
2024-03-01 13:24:14 +01:00
|
|
|
yamlfmt
|
|
|
|
yamllint
|
|
|
|
yapf
|
|
|
|
zprint
|
|
|
|
zsh
|
|
|
|
;
|
|
|
|
inherit (pkgs.nodePackages) alex prettier;
|
|
|
|
inherit (pkgs.python3.pkgs) black;
|
|
|
|
inherit (pkgs.phpPackages) phpmd phpstan;
|
2024-04-03 23:49:05 +02:00
|
|
|
inherit (pkgs.rubyPackages) htmlbeautifier;
|
2024-03-01 13:24:14 +01:00
|
|
|
inherit (pkgs.ocamlPackages) ocamlformat;
|
|
|
|
ansiblelint = pkgs.ansible-lint;
|
2024-04-22 14:35:02 +02:00
|
|
|
bean_check = pkgs.beancount;
|
2024-03-01 13:24:14 +01:00
|
|
|
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;
|
2024-04-22 14:35:02 +02:00
|
|
|
dxfmt = pkgs.dioxus-cli;
|
2024-03-01 13:24:14 +01:00
|
|
|
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;
|
|
|
|
gdformat = pkgs.gdtoolkit;
|
|
|
|
gdlint = pkgs.gdtoolkit;
|
|
|
|
gitsigns = pkgs.git;
|
2024-03-18 10:28:50 +01:00
|
|
|
gleam_format = pkgs.gleam;
|
2024-03-01 13:24:14 +01:00
|
|
|
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;
|
2024-04-04 10:24:39 +02:00
|
|
|
nixfmt = pkgs.nixfmt-classic;
|
2024-03-01 13:24:14 +01:00
|
|
|
nixpkgs_fmt = pkgs.nixpkgs-fmt;
|
|
|
|
opacheck = pkgs.open-policy-agent;
|
|
|
|
pg_format = pkgs.pgformatter;
|
|
|
|
phpcbf = pkgs.phpPackages.php-codesniffer;
|
|
|
|
phpcsfixer = pkgs.phpPackages.php-cs-fixer;
|
|
|
|
phpcs = pkgs.phpPackages.php-codesniffer;
|
2024-04-22 14:35:02 +02:00
|
|
|
prisma_format = pkgs.nodePackages.prisma;
|
2024-03-01 13:24:14 +01:00
|
|
|
ptop = pkgs.fpc;
|
2024-03-18 10:28:50 +01:00
|
|
|
puppet_lint = pkgs.puppet-lint;
|
2024-03-01 13:24:14 +01:00
|
|
|
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;
|
|
|
|
|
|
|
|
# Sources not present in nixpkgs
|
|
|
|
blade_formatter = null;
|
|
|
|
bsfmt = null;
|
|
|
|
bslint = null;
|
|
|
|
cljstyle = null;
|
|
|
|
cueimports = null;
|
|
|
|
erb_lint = null;
|
2024-03-18 10:28:50 +01:00
|
|
|
findent = null;
|
2024-03-01 13:24:14 +01:00
|
|
|
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;
|
2022-08-05 12:08:19 +00:00
|
|
|
};
|
2024-03-01 13:24:14 +01:00
|
|
|
|
|
|
|
# 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;
|
2023-02-20 11:42:13 +01:00
|
|
|
in
|
|
|
|
{
|
2024-03-01 13:24:14 +01:00
|
|
|
imports = [ ./prettier.nix ];
|
|
|
|
|
|
|
|
options.plugins.none-ls.sources = builtins.mapAttrs (
|
|
|
|
sourceType: sources:
|
|
|
|
builtins.mapAttrs (
|
|
|
|
source: _:
|
|
|
|
{
|
|
|
|
enable = mkEnableOption "the ${source} ${sourceType} source for none-ls";
|
2024-03-03 02:39:13 -08:00
|
|
|
withArgs = helpers.mkNullOrOption helpers.nixvimTypes.strLua ''
|
2024-03-01 13:24:14 +01:00
|
|
|
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
|
|
|
|
) noneLsBuiltins;
|
2022-12-30 22:04:43 +01:00
|
|
|
|
2023-02-20 11:42:13 +01:00
|
|
|
config =
|
|
|
|
let
|
2023-10-13 11:43:42 -06:00
|
|
|
cfg = config.plugins.none-ls;
|
2023-05-21 17:19:38 +02:00
|
|
|
gitsignsEnabled = cfg.sources.code_actions.gitsigns.enable;
|
2024-03-01 13:24:14 +01:00
|
|
|
|
|
|
|
flattenedSources = lib.flatten (
|
|
|
|
lib.mapAttrsToList (
|
|
|
|
sourceType: sources:
|
|
|
|
(lib.mapAttrsToList (sourceName: source: source // { inherit sourceType sourceName; }) sources)
|
|
|
|
) cfg.sources
|
|
|
|
);
|
|
|
|
|
|
|
|
enabledSources = builtins.filter (source: source.enable) flattenedSources;
|
2023-02-20 11:42:13 +01:00
|
|
|
in
|
2023-12-02 17:58:49 +01:00
|
|
|
mkIf cfg.enable {
|
2024-03-07 10:24:34 +01:00
|
|
|
# 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.
|
2024-03-18 10:36:35 +01:00
|
|
|
warnings =
|
|
|
|
let
|
2024-03-07 10:24:34 +01:00
|
|
|
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;
|
2024-03-18 10:36:35 +01:00
|
|
|
in
|
|
|
|
(optional ((length undeclaredToolNames) > 0) ''
|
|
|
|
[DEV] Nixvim (plugins.none-ls): Some tools from upstream are not declared locally in `builtinPackages`.
|
2024-03-07 10:24:34 +01:00
|
|
|
-> [${concatStringsSep ", " undeclaredToolNames}]
|
2024-03-18 10:36:35 +01:00
|
|
|
'')
|
|
|
|
++ (optional ((length uselesslyDeclaredToolNames) > 0) ''
|
|
|
|
[DEV] Nixvim (plugins.none-ls): Some tools are declared locally but are not in the upstream list of supported plugins.
|
2024-03-07 10:24:34 +01:00
|
|
|
-> [${concatStringsSep ", " uselesslyDeclaredToolNames}]
|
2024-03-18 10:36:35 +01:00
|
|
|
'');
|
2024-03-07 10:24:34 +01:00
|
|
|
|
2024-03-01 13:24:14 +01:00
|
|
|
plugins.none-ls.sourcesItems = builtins.map (
|
|
|
|
source:
|
|
|
|
let
|
|
|
|
sourceItem = "${source.sourceType}.${source.sourceName}";
|
2024-03-03 02:39:13 -08:00
|
|
|
withArgs = if source.withArgs == null then sourceItem else "${sourceItem}.with(${source.withArgs})";
|
2024-03-01 13:24:14 +01:00
|
|
|
in
|
|
|
|
helpers.mkRaw ''
|
|
|
|
require("null-ls").builtins.${withArgs}
|
|
|
|
''
|
|
|
|
) enabledSources;
|
2023-12-02 17:58:49 +01:00
|
|
|
plugins.gitsigns.enable = mkIf gitsignsEnabled true;
|
2024-04-23 16:41:27 +02:00
|
|
|
extraPackages = map (source: source.package or null) enabledSources;
|
2022-12-30 22:04:43 +01:00
|
|
|
};
|
2022-08-05 12:08:19 +00:00
|
|
|
}
|