From 0b93815db546e380be857d771356793ca7711446 Mon Sep 17 00:00:00 2001 From: traxys Date: Fri, 5 Jul 2024 18:45:37 +0200 Subject: [PATCH] dev: Add a script to generate the none-ls builtins --- flake-modules/updates/default.nix | 9 +- flake-modules/updates/none-ls.nix | 32 +++++ plugins/none-ls/packages.nix | 222 ++++++++++++++++++++++++++++++ 3 files changed, 261 insertions(+), 2 deletions(-) create mode 100644 flake-modules/updates/none-ls.nix create mode 100644 plugins/none-ls/packages.nix diff --git a/flake-modules/updates/default.nix b/flake-modules/updates/default.nix index 42600dca..6f23f23d 100644 --- a/flake-modules/updates/default.nix +++ b/flake-modules/updates/default.nix @@ -9,14 +9,18 @@ repo_root=$(git rev-parse --show-toplevel) generated_dir=$repo_root/generated - # Rust-Analyzer + echo "Rust-Analyzer" nix build .#rust-analyzer-options cat ./result >"$generated_dir"/rust-analyzer.nix - # efmls-configs + echo "efmls-configs" nix build .#efmls-configs-sources cat ./result >"$generated_dir"/efmls-configs.nix + echo "none-ls" + nix build .#none-ls-builtins + cat ./result >"$generated_dir"/none-ls.nix + nix fmt ''; }; @@ -24,6 +28,7 @@ packages = { rust-analyzer-options = pkgs.callPackage ./rust-analyzer.nix { }; efmls-configs-sources = pkgs.callPackage ./efmls-configs.nix { }; + none-ls-builtins = pkgs.callPackage ./none-ls.nix { }; }; }; } diff --git a/flake-modules/updates/none-ls.nix b/flake-modules/updates/none-ls.nix new file mode 100644 index 00000000..7f6b3312 --- /dev/null +++ b/flake-modules/updates/none-ls.nix @@ -0,0 +1,32 @@ +{ + vimPlugins, + lib, + writeText, + pkgs, +}: +let + inherit (import ../../plugins/none-ls/packages.nix pkgs) packaged noPackage unpackaged; + + builtinSources = lib.trivial.importJSON "${vimPlugins.none-ls-nvim.src}/doc/builtins.json"; + + builtinSourceNames = lib.mapAttrs (_: lib.attrNames) builtinSources; + + toolNames = lib.unique (lib.flatten (lib.attrValues builtinSourceNames)); + + undeclaredTool = lib.filter ( + name: !(lib.hasAttr name packaged || lib.elem name noPackage || lib.elem name unpackaged) + ) toolNames; + + uselesslyDeclaredTool = lib.filter (name: !(lib.elem name toolNames)) ( + unpackaged ++ noPackage ++ (lib.attrNames packaged) + ); +in +assert lib.assertMsg (lib.length undeclaredTool == 0) + "Undeclared tools: ${lib.generators.toPretty { } undeclaredTool}"; +assert lib.assertMsg (lib.length uselesslyDeclaredTool == 0) + "Tool is not supported upstream: ${lib.generators.toPretty { } uselesslyDeclaredTool}"; +writeText "efmls-configs-sources.nix" ( + "# WARNING: DO NOT EDIT\n" + + "# This file is generated with packages..none-ls-builtins, which is run automatically by CI\n" + + (lib.generators.toPretty { } builtinSourceNames) +) diff --git a/plugins/none-ls/packages.nix b/plugins/none-ls/packages.nix new file mode 100644 index 00000000..146160fd --- /dev/null +++ b/plugins/none-ls/packages.nix @@ -0,0 +1,222 @@ +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 + noPackage = [ + "gitrebase" + # TODO: Requires the go tree-sitter parser + "gomodifytags" + # TODO: Requires the go tree-sitter parser + "impl" + "luasnip" + "printenv" + "refactoring" + "spell" + "tags" + "todo_comments" + "trail_space" + "ts_node_action" + "vsnip" + ]; + + # nixpkgs packages for a given source + packaged = { + 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; + }; +}