Compare commits
10
Commits
c41b19222d
...
48da2ebd5e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48da2ebd5e | ||
|
|
368ee5d3e6 | ||
|
|
f3b96fa221 | ||
|
|
1983f353b2 | ||
|
|
abce2be529 | ||
|
|
ae0d37dd43 | ||
|
|
40133b4bf3 | ||
|
|
ddb854253d | ||
|
|
882a4449e5 | ||
|
|
3ba75eeae8 |
@@ -1,6 +1,6 @@
|
|||||||
# mason-conform.nvim
|
# mason-conform.nvim
|
||||||
|
|
||||||
Auto install formatters registered with `conform.nvim` via [Mason](https://github.com/williamboman/mason.nvim).
|
Automatically install formatters registered with [conform.nvim](https://github.com/stevearc/conform.nvim) via [Mason](https://github.com/williamboman/mason.nvim).
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
|
|
||||||
@@ -26,7 +26,9 @@ access the mason registry.
|
|||||||
# Configuration
|
# Configuration
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
require("mason-conform").setup()
|
require("mason-conform").setup({
|
||||||
|
ignore_install = {'prettier'} -- List of formatters to ignore during install
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
# Available formatters
|
# Available formatters
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local registry = require("mason-registry")
|
|||||||
local mapping = require("mason-conform.mapping")
|
local mapping = require("mason-conform.mapping")
|
||||||
|
|
||||||
local function auto_install()
|
local function auto_install()
|
||||||
|
local config = require("mason-conform").config
|
||||||
local formatters_by_ft = require("conform").formatters_by_ft;
|
local formatters_by_ft = require("conform").formatters_by_ft;
|
||||||
|
|
||||||
local formatters_to_install = {}
|
local formatters_to_install = {}
|
||||||
@@ -19,6 +20,11 @@ local function auto_install()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Filter out formatters that the user wants to ignore
|
||||||
|
for _, formatter_to_ignore in pairs(config.ignore_install) do
|
||||||
|
formatters_to_install[formatter_to_ignore] = nil
|
||||||
|
end
|
||||||
|
|
||||||
for conformFormatter, _ in pairs(formatters_to_install) do
|
for conformFormatter, _ in pairs(formatters_to_install) do
|
||||||
local package = mapping.conform_to_package[conformFormatter]
|
local package = mapping.conform_to_package[conformFormatter]
|
||||||
if package ~= nil then
|
if package ~= nil then
|
||||||
|
|||||||
@@ -1,7 +1,15 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.setup()
|
M.config = {
|
||||||
require "mason-conform.auto_install" ()
|
ignore_install = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
function M.setup(cfg)
|
||||||
|
if cfg and cfg.ignore_install then
|
||||||
|
M.config.ignore_install = cfg.ignore_install
|
||||||
|
end
|
||||||
|
|
||||||
|
require("mason-conform.auto_install")()
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ function M.try_install(mason_package_name)
|
|||||||
:if_present(
|
:if_present(
|
||||||
function(pkg)
|
function(pkg)
|
||||||
if not pkg:is_installed() then
|
if not pkg:is_installed() then
|
||||||
|
if require("mason.version").MAJOR_VERSION == 2 then
|
||||||
|
if pkg:is_installing() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
install_package(pkg, version)
|
install_package(pkg, version)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+118
-15
@@ -3,7 +3,9 @@ local M = {}
|
|||||||
-- conform formatter to mason package mapping
|
-- conform formatter to mason package mapping
|
||||||
-- https://mason-registry.dev/registry/list
|
-- https://mason-registry.dev/registry/list
|
||||||
M.conform_to_package = {
|
M.conform_to_package = {
|
||||||
-- alejandra
|
["air"] = "air",
|
||||||
|
["alejandra"] = "alejandra",
|
||||||
|
["ansible-lint"] = "ansible-lint",
|
||||||
["asmfmt"] = "asmfmt",
|
["asmfmt"] = "asmfmt",
|
||||||
["ast-grep"] = "ast-grep",
|
["ast-grep"] = "ast-grep",
|
||||||
-- astyle
|
-- astyle
|
||||||
@@ -11,70 +13,136 @@ M.conform_to_package = {
|
|||||||
-- autocorrect
|
-- autocorrect
|
||||||
["autoflake"] = "autoflake",
|
["autoflake"] = "autoflake",
|
||||||
["autopep8"] = "autopep8",
|
["autopep8"] = "autopep8",
|
||||||
-- awk
|
|
||||||
-- bean-format
|
-- bean-format
|
||||||
["beautysh"] = "beautysh",
|
["beautysh"] = "beautysh",
|
||||||
["bibtex-tidy"] = "bibtex-tidy",
|
["bibtex-tidy"] = "bibtex-tidy",
|
||||||
-- biome-check
|
-- bicep; it exists on Mason, but as LSP (exec: `bicep-lsp`)
|
||||||
["biome"] = "biome",
|
["biome"] = "biome",
|
||||||
|
-- biome-check
|
||||||
|
-- biome-organize-imports
|
||||||
["black"] = "black",
|
["black"] = "black",
|
||||||
["blade-formatter"] = "blade-formatter",
|
["blade-formatter"] = "blade-formatter",
|
||||||
["blue"] = "blue",
|
["blue"] = "blue",
|
||||||
|
-- bpfmt
|
||||||
|
["bsfmt"] = "brighterscript-formatter",
|
||||||
["buf"] = "buf",
|
["buf"] = "buf",
|
||||||
["buildifier"] = "buildifier",
|
["buildifier"] = "buildifier",
|
||||||
|
-- cabal_fmt
|
||||||
|
-- caramel_fmt
|
||||||
["cbfmt"] = "cbfmt",
|
["cbfmt"] = "cbfmt",
|
||||||
["clang_format"] = "clang-format",
|
-- cedar
|
||||||
|
["clang-format"] = "clang-format",
|
||||||
|
["cljfmt"] = "cljfmt",
|
||||||
-- cljstyle
|
-- cljstyle
|
||||||
["cmake_format"] = "cmakelang",
|
["cmake_format"] = "cmakelang",
|
||||||
|
-- codeql; it exists on Mason, but as LSP (exec: `codeql`)
|
||||||
["codespell"] = "codespell",
|
["codespell"] = "codespell",
|
||||||
|
-- commitmsgfmt
|
||||||
|
["crlfmt"] = "crlfmt",
|
||||||
|
-- crystal
|
||||||
["csharpier"] = "csharpier",
|
["csharpier"] = "csharpier",
|
||||||
|
-- css_beautify
|
||||||
-- cue_fmt
|
-- cue_fmt
|
||||||
|
-- d2
|
||||||
["darker"] = "darker",
|
["darker"] = "darker",
|
||||||
-- dart_format
|
-- dart_format
|
||||||
|
["dcm_fix"] = "dcm",
|
||||||
|
["dcm_format"] = "dcm",
|
||||||
["deno_fmt"] = "deno",
|
["deno_fmt"] = "deno",
|
||||||
-- dfmt
|
-- dfmt
|
||||||
|
-- dioxus
|
||||||
["djlint"] = "djlint",
|
["djlint"] = "djlint",
|
||||||
|
["docformatter"] = "docformatter",
|
||||||
|
-- docstrfmt
|
||||||
|
["doctoc"] = "doctoc",
|
||||||
["dprint"] = "dprint",
|
["dprint"] = "dprint",
|
||||||
["easy-coding-standard"] = "easy-coding-standard",
|
["easy-coding-standard"] = "easy-coding-standard",
|
||||||
|
-- efmt
|
||||||
["elm_format"] = "elm-format",
|
["elm_format"] = "elm-format",
|
||||||
-- erb_format
|
["erb_format"] = "erb-formatter",
|
||||||
|
-- erlfmt
|
||||||
["eslint_d"] = "eslint_d",
|
["eslint_d"] = "eslint_d",
|
||||||
["fantomas"] = "fantomas",
|
["fantomas"] = "fantomas",
|
||||||
|
["findent"] = "findent",
|
||||||
-- fish_indent
|
-- fish_indent
|
||||||
["fixjson"] = "fixjson",
|
["fixjson"] = "fixjson",
|
||||||
-- fnlfmt
|
-- fnlfmt
|
||||||
|
-- forge_fmt
|
||||||
|
-- format-dune-file
|
||||||
|
-- format-queries
|
||||||
["fourmolu"] = "fourmolu",
|
["fourmolu"] = "fourmolu",
|
||||||
|
["fprettify"] = "fprettify",
|
||||||
|
-- gawk
|
||||||
["gci"] = "gci",
|
["gci"] = "gci",
|
||||||
["gdformat"] = "gdtoolkit",
|
["gdformat"] = "gdtoolkit",
|
||||||
["gersemi"] = "gersemi",
|
["gersemi"] = "gersemi",
|
||||||
|
-- ghokin
|
||||||
|
-- gleam
|
||||||
|
-- gluon_fmt
|
||||||
-- gn
|
-- gn
|
||||||
-- gofmt
|
-- gofmt
|
||||||
["gofumpt"] = "gofumpt",
|
["gofumpt"] = "gofumpt",
|
||||||
["goimports-reviser"] = "goimports-reviser",
|
|
||||||
["goimports"] = "goimports",
|
["goimports"] = "goimports",
|
||||||
|
["goimports-reviser"] = "goimports-reviser",
|
||||||
|
-- gojq
|
||||||
|
["golangci-lint"] = "golangci-lint",
|
||||||
["golines"] = "golines",
|
["golines"] = "golines",
|
||||||
["google-java-format"] = "google-java-format",
|
["google-java-format"] = "google-java-format",
|
||||||
|
-- grain_format
|
||||||
|
["hcl"] = "hclfmt",
|
||||||
|
-- hindent
|
||||||
|
-- hledger-fmt
|
||||||
|
-- html_beautify
|
||||||
["htmlbeautifier"] = "htmlbeautifier",
|
["htmlbeautifier"] = "htmlbeautifier",
|
||||||
|
-- hurlfmt
|
||||||
|
-- imba_fmt
|
||||||
-- indent
|
-- indent
|
||||||
-- init
|
-- init
|
||||||
-- injected
|
-- injected
|
||||||
|
-- inko
|
||||||
["isort"] = "isort",
|
["isort"] = "isort",
|
||||||
|
-- janet-format
|
||||||
["joker"] = "joker",
|
["joker"] = "joker",
|
||||||
["jq"] = "jq",
|
["jq"] = "jq",
|
||||||
|
-- js_beautify
|
||||||
["jsonnetfmt"] = "jsonnetfmt",
|
["jsonnetfmt"] = "jsonnetfmt",
|
||||||
-- just
|
-- just
|
||||||
|
["kcl"] = "kcl",
|
||||||
|
["kdlfmt"] = "kdlfmt",
|
||||||
|
-- keep-sorted
|
||||||
|
["ktfmt"] = "ktfmt",
|
||||||
["ktlint"] = "ktlint",
|
["ktlint"] = "ktlint",
|
||||||
|
["kulala-fmt"] = "kulala-fmt",
|
||||||
["latexindent"] = "latexindent",
|
["latexindent"] = "latexindent",
|
||||||
|
-- leptosfmt
|
||||||
|
-- liquidsoap-prettier
|
||||||
|
-- llf
|
||||||
|
["lua-format"] = "luaformatter",
|
||||||
|
-- mago_format
|
||||||
|
-- mago_lint
|
||||||
["markdown-toc"] = "markdown-toc",
|
["markdown-toc"] = "markdown-toc",
|
||||||
["markdownlint-cli2"] = "markdownlint-cli2",
|
-- markdownfmt
|
||||||
["markdownlint"] = "markdownlint",
|
["markdownlint"] = "markdownlint",
|
||||||
|
["markdownlint-cli2"] = "markdownlint-cli2",
|
||||||
["mdformat"] = "mdformat",
|
["mdformat"] = "mdformat",
|
||||||
|
["mdsf"] = "mdsf",
|
||||||
["mdslw"] = "mdslw",
|
["mdslw"] = "mdslw",
|
||||||
-- mix
|
-- mix
|
||||||
-- nixfmt
|
-- mojo_format
|
||||||
|
-- nginxfmt
|
||||||
|
-- nickel; it exists on Mason, but as LSP (exec: `nls`)
|
||||||
|
-- nimpretty
|
||||||
|
["nixfmt"] = "nixfmt",
|
||||||
["nixpkgs_fmt"] = "nixpkgs-fmt",
|
["nixpkgs_fmt"] = "nixpkgs-fmt",
|
||||||
|
["nomad_fmt"] = "nomad",
|
||||||
|
-- nph
|
||||||
|
["npm-groovy-lint"] = "npm-groovy-lint",
|
||||||
|
-- nufmt
|
||||||
["ocamlformat"] = "ocamlformat",
|
["ocamlformat"] = "ocamlformat",
|
||||||
-- opa_fmt
|
-- ocp-indent
|
||||||
|
-- odinfmt
|
||||||
|
["opa_fmt"] = "opa",
|
||||||
|
["ormolu"] = "ormolu",
|
||||||
-- packer_fmt
|
-- packer_fmt
|
||||||
-- pangu
|
-- pangu
|
||||||
-- perlimports
|
-- perlimports
|
||||||
@@ -87,51 +155,86 @@ M.conform_to_package = {
|
|||||||
["prettier"] = "prettier",
|
["prettier"] = "prettier",
|
||||||
["prettierd"] = "prettierd",
|
["prettierd"] = "prettierd",
|
||||||
["pretty-php"] = "pretty-php",
|
["pretty-php"] = "pretty-php",
|
||||||
|
["prettypst"] = "prettypst",
|
||||||
-- puppet-lint
|
-- puppet-lint
|
||||||
|
["purs-tidy"] = "purescript-tidy",
|
||||||
|
-- pycln
|
||||||
|
["pyink"] = "pyink",
|
||||||
|
["pyproject-fmt"] = "pyproject-fmt",
|
||||||
|
-- python-ly
|
||||||
|
-- pyupgrade
|
||||||
|
["reformat-gherkin"] = "reformat-gherkin",
|
||||||
["reorder-python-imports"] = "reorder-python-imports",
|
["reorder-python-imports"] = "reorder-python-imports",
|
||||||
-- rescript-format
|
-- rescript-format
|
||||||
|
-- roc
|
||||||
|
-- rstfmt
|
||||||
["rubocop"] = "rubocop",
|
["rubocop"] = "rubocop",
|
||||||
["rubyfmt"] = "rubyfmt",
|
["rubyfmt"] = "rubyfmt",
|
||||||
-- ruff
|
|
||||||
["ruff_fix"] = "ruff",
|
["ruff_fix"] = "ruff",
|
||||||
["ruff_format"] = "ruff",
|
["ruff_format"] = "ruff",
|
||||||
|
["ruff_organize_imports"] = "ruff",
|
||||||
["rufo"] = "rufo",
|
["rufo"] = "rufo",
|
||||||
["rustfmt"] = "rustfmt",
|
-- runic
|
||||||
|
-- ["rustfmt"] = "rustfmt", Deprecated by mason
|
||||||
["rustywind"] = "rustywind",
|
["rustywind"] = "rustywind",
|
||||||
-- scalafmt
|
-- scalafmt
|
||||||
["shellcheck"] = "shellcheck",
|
["shellcheck"] = "shellcheck",
|
||||||
["shellharden"] = "shellharden",
|
["shellharden"] = "shellharden",
|
||||||
["shfmt"] = "shfmt",
|
["shfmt"] = "shfmt",
|
||||||
|
["sleek"] = "sleek",
|
||||||
|
-- smlfmt
|
||||||
|
["snakefmt"] = "snakefmt",
|
||||||
["sql_formatter"] = "sql-formatter",
|
["sql_formatter"] = "sql-formatter",
|
||||||
["sqlfluff"] = "sqlfluff",
|
["sqlfluff"] = "sqlfluff",
|
||||||
["sqlfmt"] = "sqlfmt",
|
["sqlfmt"] = "sqlfmt",
|
||||||
|
["sqruff"] = "sqruff",
|
||||||
-- squeeze_blanks
|
-- squeeze_blanks
|
||||||
|
-- standard-clj
|
||||||
["standardjs"] = "standardjs",
|
["standardjs"] = "standardjs",
|
||||||
["standardrb"] = "standardrb",
|
["standardrb"] = "standardrb",
|
||||||
["stylelint"] = "stylelint",
|
["stylelint"] = "stylelint",
|
||||||
-- styler
|
-- styler
|
||||||
|
-- stylish-haskell
|
||||||
["stylua"] = "stylua",
|
["stylua"] = "stylua",
|
||||||
|
["superhtml"] = "superhtml",
|
||||||
|
-- swift
|
||||||
-- swift_format
|
-- swift_format
|
||||||
-- swiftformat
|
-- swiftformat
|
||||||
|
["swiftlint"] = "swiftlint",
|
||||||
|
-- syntax_tree
|
||||||
["taplo"] = "taplo",
|
["taplo"] = "taplo",
|
||||||
["templ"] = "templ",
|
["templ"] = "templ",
|
||||||
-- terraform_fmt
|
["terraform_fmt"] = "terraform",
|
||||||
-- terragrunt_hclfmt
|
-- terragrunt_hclfmt
|
||||||
|
["tex-fmt"] = "tex-fmt",
|
||||||
["tlint"] = "tlint",
|
["tlint"] = "tlint",
|
||||||
|
-- tofu_fmt
|
||||||
|
["tombi"] = "tombi",
|
||||||
|
-- treefmt
|
||||||
-- trim_newlines
|
-- trim_newlines
|
||||||
-- trim_whitespace
|
-- trim_whitespace
|
||||||
-- twig-cs-fixer
|
["twig-cs-fixer"] = "twig-cs-fixer",
|
||||||
|
-- typespec
|
||||||
["typos"] = "typos",
|
["typos"] = "typos",
|
||||||
-- typstfmt
|
-- typstyle
|
||||||
|
-- ufmt
|
||||||
-- uncrustify
|
-- uncrustify
|
||||||
["usort"] = "usort",
|
["usort"] = "usort",
|
||||||
["xmlformat"] = "xmlformatter",
|
-- v
|
||||||
|
["verible"] = "verible",
|
||||||
|
["vsg"] = "vsg",
|
||||||
|
["xmlformat"] = "xmlformatter", -- Deprecated in conform.nvim; redirects to xmlformatter
|
||||||
|
["xmlformatter"] = "xmlformatter",
|
||||||
-- xmllint
|
-- xmllint
|
||||||
|
-- xmlstarlet
|
||||||
["yamlfix"] = "yamlfix",
|
["yamlfix"] = "yamlfix",
|
||||||
["yamlfmt"] = "yamlfmt",
|
["yamlfmt"] = "yamlfmt",
|
||||||
["yapf"] = "yapf",
|
["yapf"] = "yapf",
|
||||||
|
-- yew-fmt
|
||||||
["yq"] = "yq",
|
["yq"] = "yq",
|
||||||
-- zigfmt
|
-- zigfmt
|
||||||
|
-- ziggy
|
||||||
|
-- ziggy_schema
|
||||||
["zprint"] = "zprint",
|
["zprint"] = "zprint",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user