Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions ci/conform-nvim.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
vimPlugins,
lib,
writeText,
}:
lib.pipe "${vimPlugins.conform-nvim}/lua/conform/formatters" [
builtins.readDir
builtins.attrNames
(builtins.filter (lib.hasSuffix ".lua"))
(map (lib.removeSuffix ".lua"))
builtins.toJSON
(writeText "conform-formatters")
]
1 change: 1 addition & 0 deletions ci/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ lib.fix (self: {
none-ls-builtins = pkgs.callPackage ./none-ls.nix { };
rust-analyzer-options = pkgs.callPackage ./rust-analyzer { };
lspconfig-servers = pkgs.callPackage ./nvim-lspconfig { };
conform-formatters = pkgs.callPackage ./conform-nvim.nix { };
version-info = pkgs.callPackage ./version-info { };
})
23 changes: 15 additions & 8 deletions ci/generate.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
efmls-configs-sources,
none-ls-builtins,
lspconfig-servers,
nixfmt-rfc-style,
conform-formatters,
nixfmt,
nodePackages,
}:
writeShellApplication {
name = "generate";

runtimeInputs = [
nixfmt-rfc-style
nixfmt
nodePackages.prettier
];

Expand All @@ -32,18 +33,24 @@ writeShellApplication {
shift
done

generate() {
generate_nix() {
echo "$2"
cp "$1" "$generated_dir/$2.nix"
nixfmt "$generated_dir/$2.nix"
}

generate_json() {
echo "$2"
prettier --parser=json "$1" >"$generated_dir/$2.json"
}

mkdir -p "$generated_dir"
generate "${rust-analyzer-options}" "rust-analyzer"
generate "${efmls-configs-sources}" "efmls-configs"
generate "${none-ls-builtins}" "none-ls"
echo "lspconfig servers"
prettier --parser=json "${lspconfig-servers}" >"$generated_dir/lspconfig-servers.json"
generate_nix "${rust-analyzer-options}" "rust-analyzer"
generate_nix "${efmls-configs-sources}" "efmls-configs"
generate_nix "${none-ls-builtins}" "none-ls"

generate_json "${conform-formatters}" "conform-formatters"
generate_json "${lspconfig-servers}" "lspconfig-servers"

if [ -n "$commit" ]; then
cd "$generated_dir"
Expand Down
247 changes: 247 additions & 0 deletions generated/conform-formatters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
[
"air",
"alejandra",
"ansible-lint",
"asmfmt",
"ast-grep",
"astyle",
"auto_optional",
"autocorrect",
"autoflake",
"autopep8",
"awk",
"bake",
"bean-format",
"beautysh",
"bibtex-tidy",
"bicep",
"biome-check",
"biome-organize-imports",
"biome",
"black",
"blade-formatter",
"blue",
"bpfmt",
"bsfmt",
"buf",
"buildifier",
"cabal_fmt",
"caramel_fmt",
"cbfmt",
"cedar",
"clang-format",
"clang_format",
"cljfmt",
"cljstyle",
"cmake_format",
"codeql",
"codespell",
"commitmsgfmt",
"crlfmt",
"crystal",
"csharpier",
"css_beautify",
"cue_fmt",
"d2",
"darker",
"dart_format",
"dcm_fix",
"dcm_format",
"deno_fmt",
"dfmt",
"dioxus",
"djlint",
"docformatter",
"dockerfmt",
"docstrfmt",
"doctoc",
"dprint",
"easy-coding-standard",
"efmt",
"elm_format",
"erb_format",
"erlfmt",
"eslint_d",
"fantomas",
"findent",
"fish_indent",
"fixjson",
"fnlfmt",
"forge_fmt",
"format-dune-file",
"format-queries",
"fourmolu",
"fprettify",
"gawk",
"gci",
"gdformat",
"gersemi",
"ghdl",
"ghokin",
"gleam",
"gluon_fmt",
"gn",
"gofmt",
"gofumpt",
"goimports-reviser",
"goimports",
"gojq",
"golangci-lint",
"golines",
"google-java-format",
"grain_format",
"hcl",
"hindent",
"hledger-fmt",
"html_beautify",
"htmlbeautifier",
"hurlfmt",
"imba_fmt",
"indent",
"init",
"injected",
"inko",
"isort",
"janet-format",
"joker",
"jq",
"js_beautify",
"jsonnetfmt",
"just",
"kcl",
"kdlfmt",
"keep-sorted",
"ktfmt",
"ktlint",
"kulala-fmt",
"latexindent",
"leptosfmt",
"liquidsoap-prettier",
"llf",
"lua-format",
"mago_format",
"mago_lint",
"markdown-toc",
"markdownfmt",
"markdownlint-cli2",
"markdownlint",
"mdformat",
"mdsf",
"mdslw",
"mix",
"mojo_format",
"nginxfmt",
"nickel",
"nimpretty",
"nixfmt",
"nixpkgs_fmt",
"nomad_fmt",
"nph",
"npm-groovy-lint",
"nufmt",
"ocamlformat",
"ocp-indent",
"odinfmt",
"opa_fmt",
"ormolu",
"packer_fmt",
"pangu",
"perlimports",
"perltidy",
"pg_format",
"php_cs_fixer",
"phpcbf",
"phpinsights",
"pint",
"prettier",
"prettierd",
"pretty-php",
"prettypst",
"prolog",
"puppet-lint",
"purs-tidy",
"pycln",
"pyink",
"pymarkdownlnt",
"pyproject-fmt",
"python-ly",
"pyupgrade",
"qmlformat",
"reformat-gherkin",
"reorder-python-imports",
"rescript-format",
"roc",
"rstfmt",
"rubocop",
"rubyfmt",
"ruff",
"ruff_fix",
"ruff_format",
"ruff_organize_imports",
"rufo",
"runic",
"rustfmt",
"rustywind",
"scalafmt",
"shellcheck",
"shellharden",
"shfmt",
"sleek",
"smlfmt",
"snakefmt",
"spotless_gradle",
"spotless_maven",
"sql_formatter",
"sqlfluff",
"sqlfmt",
"sqruff",
"squeeze_blanks",
"standard-clj",
"standardjs",
"standardrb",
"stylelint",
"styler",
"stylish-haskell",
"stylua",
"superhtml",
"swift",
"swift_format",
"swiftformat",
"swiftlint",
"syntax_tree",
"taplo",
"templ",
"terraform_fmt",
"terragrunt_hclfmt",
"tex-fmt",
"tlint",
"tofu_fmt",
"tombi",
"treefmt",
"trim_newlines",
"trim_whitespace",
"twig-cs-fixer",
"typespec",
"typos",
"typstfmt",
"typstyle",
"ufmt",
"uncrustify",
"usort",
"v",
"verible",
"vsg",
"xmlformat",
"xmlformatter",
"xmllint",
"xmlstarlet",
"yamlfix",
"yamlfmt",
"yapf",
"yew-fmt",
"yq",
"zigfmt",
"ziggy",
"ziggy_schema",
"zprint"
]
78 changes: 78 additions & 0 deletions plugins/by-name/conform-nvim/auto-install.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
pkgs,
lib,
...
}:
let
inherit (lib) elem throwIfNot;
inherit (builtins)
filter
isString
isAttrs
attrValues
attrNames
concatMap
partition
;

inherit (import ./formatter-packages.nix { inherit pkgs lib; }) sType formatter-packages;
sTypeList = attrValues sType;
isSTypeAttrSet = x: lib.elem (x.mark or null) sTypeList;
in
rec {
cleanMaybePackageList = filter (x: !isSTypeAttrSet x);

getPackageByName =
{ configuredFormatters, overrides }:
name:
let
permittedNames = attrNames configuredFormatters;
isSType = x: elem x sTypeList;
notFoundMsg = ''
A package for the conform-nvim formatter '${name}' could not be found.
It is not a user defined formatter. Is the formatter name correct?
'';
maybePackage =
overrides.${name} or formatter-packages.${name} or pkgs.${name}
or (throwIfNot (elem name permittedNames) notFoundMsg null);
in
if isSType maybePackage then
{
inherit name;
mark = maybePackage;
}
else
maybePackage;

mkWarnsFromMaybePackageList =
opts: list:
let
mkWarn =
{ name, mark }:
lib.nixvim.mkWarnings "conform-nvim" [
{
when = true;
message = ''
You have enabled the '${name}' formatter that relies on a package marked '${mark}'.
Because of that it will not be installed. To disable this warning, explicitly disable installing the package
by setting the '${opts.autoInstall.overrides}.${name}' option to 'null'. You can also disable
all warnings related to packages not installed by 'autoInstall' with '${opts.autoInstall.enableWarnings}'.
'';
}
];
in
concatMap mkWarn (filter isSTypeAttrSet list);

collectFormatters =
formatters:
let
partitioned = lib.pipe formatters [
lib.flatten
(filter (x: isString x || isAttrs x))
(partition isString)
];
in
lib.optionals (formatters != [ ]) (
partitioned.right ++ concatMap (fmts: collectFormatters (attrValues fmts)) partitioned.wrong
);
}
Loading