Variable: apheleia-formatters
apheleia-formatters is a customizable variable defined in
apheleia-formatters.el.
Value
Large value
((astyle "astyle"
(apheleia-formatters-locate-file "--options" ".astylerc"))
(asmfmt "asmfmt") (bean-format "bean-format" input)
(beautysh "beautysh"
(apheleia-formatters-indent "--tab" "--indent-size"
'sh-basic-offset)
"-")
(bibtex . apheleia-reformat-bibtex-buffer)
(black "black" (when (apheleia-formatters-extension-p "pyi") "--pyi")
(apheleia-formatters-fill-column "--line-length")
"--stdin-filename" filepath "-")
(brittany "brittany")
(buildifier "buildifier" "-type"
(cond ((eq major-mode 'bazel-workspace-mode) "workspace")
((eq major-mode 'bazel-module-mode) "module")
((eq major-mode 'bazel-build-mode) "build")
(t "auto")))
(biome "apheleia-npx" "biome" "check" "--write"
"--linter-enabled=false" "--stdin-file-path" filepath)
(caddyfmt "caddy" "fmt" "-")
(clang-format "clang-format" "-assume-filename"
(or (apheleia-formatters-local-buffer-file-name)
(apheleia-formatters-mode-extension) ".c"))
(cljfmt "cljfmt" "fix" "-") (cljstyle "cljstyle" "pipe")
(cmake-format "cmake-format" "-")
(crystal-tool-format "crystal" "tool" "format" "-")
(csharpier "csharpier" "format")
(css-beautify "css-beautify" "--file" "-" "--end-with-newline"
(apheleia-formatters-indent "--indent-with-tabs"
"--indent-size"))
(dart-format "dart" "format")
(denofmt "deno" "fmt" "-"
(apheleia-formatters-fill-column "--line-width"))
(denofmt-js "deno" "fmt" "-" "--ext" "js"
(apheleia-formatters-fill-column "--line-width"))
(denofmt-json "deno" "fmt" "-" "--ext" "json"
(apheleia-formatters-fill-column "--line-width"))
(denofmt-jsonc "deno" "fmt" "-" "--ext" "jsonc"
(apheleia-formatters-fill-column "--line-width"))
(denofmt-jsx "deno" "fmt" "-" "--ext" "jsx"
(apheleia-formatters-fill-column "--line-width"))
(denofmt-md "deno" "fmt" "-" "--ext" "md"
(apheleia-formatters-fill-column "--line-width"))
(denofmt-ts "deno" "fmt" "-" "--ext" "ts"
(apheleia-formatters-fill-column "--line-width"))
(denofmt-tsx "deno" "fmt" "-" "--ext" "tsx"
(apheleia-formatters-fill-column "--line-width"))
(denofmt-yaml "deno" "fmt" "-" "--ext" "yaml"
(apheleia-formatters-fill-column "--line-width"))
(dhall-format "dhall" "format")
(docformatter "apheleia-docformatter" inplace)
(dockerfmt "dockerfmt") (dprint "dprint" "fmt" "--stdin" filepath)
(elm-format "elm-format" "--yes" "--stdin")
(fish-indent "fish_indent")
(fourmolu "fourmolu" "--stdin-input-file" filepath)
(gawk "gawk" "-f" "-" "--pretty-print=-") (gdformat "gdformat" "-")
(gleam "gleam" "format" "--stdin") (gofmt "gofmt")
(gofumpt "gofumpt") (goimports "goimports")
(golangci-lint "golangci-lint" "fmt" "--stdin")
(google-java-format "google-java-format" "-") (hclfmt "hclfmt")
(html-beautify "html-beautify" "--file" "-" "--end-with-newline"
(apheleia-formatters-indent "--indent-with-tabs"
"--indent-size"))
(html-tidy "tidy" "--quiet" "yes" "--tidy-mark" "no"
"--vertical-space" "yes" "-indent"
(when (derived-mode-p 'nxml-mode) "-xml")
(apheleia-formatters-indent "--indent-with-tabs"
"--indent-spaces")
(apheleia-formatters-fill-column "-wrap"))
(hurlfmt "hurlfmt" "--no-color") (isort "isort" "-")
(js-beautify "js-beautify" "--file" "-" "--end-with-newline"
(apheleia-formatters-indent "--indent-with-tabs"
"--indent-size"))
(jq "jq" "." "-M" (apheleia-formatters-indent "--tab" "--indent"))
(lisp-indent . apheleia-indent-lisp-buffer)
(ktlint "ktlint" "--log-level=none" "--stdin" "-F" "-")
(latexindent "latexindent" "--logfile=/dev/null")
(mago "mago" "--no-version-check" "format" "--stdin-input"
"--stdin-filepath" filepath)
(mbake "mbake" "format" "--stdin")
(meson "meson" "format" "--editor-config" "--source-file-path"
filepath "-")
(mix-format "apheleia-from-project-root" ".formatter.exs"
"apheleia-mix-format" filepath)
(muon "muon" "fmt" "-e" "-") (nixfmt "nixfmt")
(nomad "nomad" "fmt" "-")
(ocamlformat "ocamlformat" "-" "--name" filepath
"--enable-outside-detected-project")
(ocp-indent "ocp-indent")
(ormolu "ormolu" "--stdin-input-file" filepath)
(opentofu "tofu" "fmt" "-") (oxfmt "apheleia-npx" "oxfmt" inplace)
(perltidy "perltidy" "--quiet" "--standard-error-output"
(apheleia-formatters-indent "-t" "-i")
(apheleia-formatters-fill-column "-l"))
(pgformatter "pg_format"
(apheleia-formatters-indent "--tabs" "--spaces"
'tab-width)
(apheleia-formatters-fill-column "--wrap-limit"))
(phpcs "apheleia-phpcs") (pkl "apheleia-pkl" "format" "-")
(prettier "apheleia-npx" "prettier" "--stdin-filepath" filepath
(apheleia-formatters-js-indent "--use-tabs" "--tab-width"))
(prettier-css "apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=css"
(apheleia-formatters-js-indent "--use-tabs"
"--tab-width"))
(prettier-html "apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=html"
(apheleia-formatters-js-indent "--use-tabs"
"--tab-width"))
(prettier-graphql "apheleia-npx" "prettier" "--stdin-filepath"
filepath "--parser=graphql"
(apheleia-formatters-js-indent "--use-tabs"
"--tab-width"))
(prettier-javascript "apheleia-npx" "prettier" "--stdin-filepath"
filepath "--parser=babel-flow"
(apheleia-formatters-js-indent "--use-tabs"
"--tab-width"))
(prettier-json "apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=json"
(apheleia-formatters-js-indent "--use-tabs"
"--tab-width"))
(prettier-json-stringify "apheleia-npx" "prettier" "--stdin-filepath"
filepath "--parser=json-stringify"
(apheleia-formatters-js-indent "--use-tabs"
"--tab-width"))
(prettier-markdown "apheleia-npx" "prettier" "--stdin-filepath"
filepath "--parser=markdown"
(apheleia-formatters-js-indent "--use-tabs"
"--tab-width"))
(prettier-ruby "apheleia-npx" "prettier" "--stdin-filepath" filepath
"--plugin=@prettier/plugin-ruby" "--parser=ruby"
(apheleia-formatters-js-indent "--use-tabs"
"--tab-width"))
(prettier-scss "apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=scss"
(apheleia-formatters-js-indent "--use-tabs"
"--tab-width"))
(prettier-svelte "apheleia-npx" "prettier" "--stdin-filepath"
filepath "--plugin=prettier-plugin-svelte"
"--parser=svelte"
(apheleia-formatters-js-indent "--use-tabs"
"--tab-width"))
(prettier-typescript "apheleia-npx" "prettier" "--stdin-filepath"
filepath "--parser=typescript"
(apheleia-formatters-js-indent "--use-tabs"
"--tab-width"))
(prettier-yaml "apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=yaml"
(apheleia-formatters-js-indent "--use-tabs"
"--tab-width"))
(purs-tidy "apheleia-npx" "purs-tidy" "format")
(pyang "pyang" "--ignore-errors" "-f" "yang")
(robotidy "robotidy" "--no-color" "-"
(apheleia-formatters-indent nil "--indent")
(apheleia-formatters-fill-column "--line-length"))
(r-styler "R" "--no-echo" "--no-save" "--no-restore" "-e"
"styler::style_text(readLines(file('stdin')))")
(python3-json "python3" "-m" "json.tool"
(apheleia-formatters-indent "--tab" "--indent"))
(rubocop "rubocop" "--stdin" filepath "-a" "--stderr" "--format"
"quiet" "--fail-level" "fatal" "--force-exclusion")
(ruby-standard "standardrb" "--stdin" filepath "--fix" "--stderr"
"--format" "quiet" "--fail-level" "fatal")
(ruby-syntax-tree "apheleia-from-project-root" ".streerc" "stree"
"format" filepath)
(rumdl "rumdl" "fmt" "--stdin" "--stdin-filename" filepath)
(ruff "ruff" "format" "--silent"
(apheleia-formatters-fill-column "--line-length")
"--stdin-filename" filepath "-")
(ruff-isort "ruff" "check" "-n" "--select" "I" "--fix" "--fix-only"
"--stdin-filename" filepath "-")
(slint "slint-lsp" "format" filepath)
(snakefmt "snakefmt"
(apheleia-formatters-fill-column "--line-length") "-")
(sqlfluff "sqlfluff" "format" "--disable-progress-bar" "-")
(shfmt "shfmt" "-filename" filepath "-")
(rufo "rufo" "--filename" filepath "--simple-exit")
(stylua "stylua" "-") (rustfmt "rustfmt" "--quiet" "--emit" "stdout")
(taplo "taplo" "format" "--colors" "never" "-")
(terraform "terraform" "fmt" "-")
(treefmt "treefmt" "--stdin" filepath) (typstyle "typstyle")
(vfmt "v" "fmt") (xmllint "xmllint" "--format" "-") (yapf "yapf")
(yq-csv "yq" "--prettyPrint" "--no-colors" "--input-format" "csv"
"--output-format" "csv")
(yq-json "yq" "--prettyPrint" "--no-colors" "--input-format" "json"
"--output-format" "json"
(apheleia-formatters-indent nil "--indent"))
(yq-properties "yq" "--prettyPrint" "--no-colors" "--input-format"
"props" "--output-format" "props")
(yq-toml "yq" "--prettyPrint" "--no-colors" "--input-format" "toml"
"--output-format" "toml")
(yq-tsv "yq" "--prettyPrint" "--no-colors" "--input-format" "tsv"
"--output-format" "tsv")
(yq-xml "yq" "--prettyPrint" "--no-colors" "--input-format" "xml"
"--output-format" "xml"
(apheleia-formatters-indent nil "--indent"))
(yq-yaml "yq" "--prettyPrint" "--no-colors" "--input-format" "yaml"
"--output-format" "yaml"
(apheleia-formatters-indent nil "--indent"))
(zig-fmt "zig" "fmt" "--stdin"))
Documentation
Alist of code formatting commands.
The keys may be any symbols you want, and the values are shell commands, lists of strings and symbols, or a function symbol.
If the value is a function, the function will be called with
keyword arguments (see the implementation of
apheleia--run-formatter-function to see which). It should use
cl-defun with &allow-other-keys for forward compatibility.
Otherwise in Lisp code, the format of commands is similar to what
you pass to make-process, except as follows.
Normally, the contents of the current buffer are passed to the
command on stdin, and the output is read from stdout. However, if
you use the symbol file as one of the elements of commands,
then the filename of the current buffer is substituted for
it. (Use filepath instead of file if you need the filename of
the current buffer, but you still want its contents to be passed
on stdin.)
If you instead use the symbol input as one of the elements of
commands, then the contents of the current buffer are written to
a temporary file and its name is substituted for input. Also,
if you use the symbol output as one of the elements of
commands, then it is substituted with the name of a temporary
file. In that case, it is expected that the command writes to
that file, and the file is then read into an Emacs buffer.
If you use the symbol inplace as one of the elements of the
list, then the contents of the current buffer are written to a
temporary file and its name is substituted for inplace.
However, unlike input, it is expected that the formatter write
the formatted file back to the same file in place. In other
words, inplace is like input and output together.
If you use the symbol npx as one of the elements of commands,
then the first string element of the command list is resolved
inside node_modules/.bin if such a directory exists anywhere
above the current default-directory.
(However, instead of using npx, consider using
"apheleia-npx", which is a built-in script that will replicate
the effect, but will also work with Yarn PNP projects and other
npm project types that may exist in the future.)
Any list elements that are not strings and not any of the special symbols mentioned above will be evaluated when the formatter is invoked, and spliced into the list. A form can evaluate either to a string or to a list of strings.
The "scripts/formatters" subdirectory of the Apheleia source
repository is automatically prepended to $PATH (variable
exec-path(var)/exec-path(fun), to be specific) when invoking external formatters.
This is intended for internal use. If you would like to define
your own script, you can simply place it on your normal $PATH
rather than using this system.
Source Code
;; Defined in /nix/store/lwcwryzabcmvjcwwzzs65jrwf7p7d7cs-emacs-packages-deps/share/emacs/site-lisp/elpa/apheleia-20260915.1628/apheleia-formatters.el
(defcustom apheleia-formatters
'((astyle . ("astyle" (apheleia-formatters-locate-file
"--options" ".astylerc")))
(asmfmt . ("asmfmt"))
(bean-format . ("bean-format" input))
(beautysh . ("beautysh"
(apheleia-formatters-indent
"--tab" "--indent-size" 'sh-basic-offset)
"-"))
(bibtex . apheleia-reformat-bibtex-buffer)
(black . ("black"
(when (apheleia-formatters-extension-p "pyi") "--pyi")
(apheleia-formatters-fill-column "--line-length")
"--stdin-filename" filepath
"-"))
(brittany . ("brittany"))
(buildifier . ("buildifier" "-type"
(cond
((eq major-mode 'bazel-workspace-mode) "workspace")
((eq major-mode 'bazel-module-mode) "module")
((eq major-mode 'bazel-build-mode) "build")
(t "auto")
)))
(biome . ("apheleia-npx" "biome" "check" "--write"
"--linter-enabled=false" "--stdin-file-path" filepath))
(caddyfmt . ("caddy" "fmt" "-"))
(clang-format . ("clang-format"
"-assume-filename"
(or (apheleia-formatters-local-buffer-file-name)
(apheleia-formatters-mode-extension)
".c")))
(cljfmt . ("cljfmt" "fix" "-"))
(cljstyle . ("cljstyle" "pipe"))
(cmake-format . ("cmake-format" "-"))
(crystal-tool-format . ("crystal" "tool" "format" "-"))
(csharpier . ("csharpier" "format"))
(css-beautify "css-beautify" "--file" "-" "--end-with-newline"
(apheleia-formatters-indent
"--indent-with-tabs" "--indent-size"))
(dart-format . ("dart" "format"))
(denofmt . ("deno" "fmt" "-"
(apheleia-formatters-fill-column "--line-width")))
(denofmt-js . ("deno" "fmt" "-" "--ext" "js"
(apheleia-formatters-fill-column "--line-width")))
(denofmt-json . ("deno" "fmt" "-" "--ext" "json"
(apheleia-formatters-fill-column "--line-width")))
(denofmt-jsonc . ("deno" "fmt" "-" "--ext" "jsonc"
(apheleia-formatters-fill-column "--line-width")))
(denofmt-jsx . ("deno" "fmt" "-" "--ext" "jsx"
(apheleia-formatters-fill-column "--line-width")))
(denofmt-md . ("deno" "fmt" "-" "--ext" "md"
(apheleia-formatters-fill-column "--line-width")))
(denofmt-ts . ("deno" "fmt" "-" "--ext" "ts"
(apheleia-formatters-fill-column "--line-width")))
(denofmt-tsx . ("deno" "fmt" "-" "--ext" "tsx"
(apheleia-formatters-fill-column "--line-width")))
(denofmt-yaml . ("deno" "fmt" "-" "--ext" "yaml"
(apheleia-formatters-fill-column "--line-width")))
(dhall-format . ("dhall" "format"))
(docformatter . ("apheleia-docformatter" inplace))
(dockerfmt . ("dockerfmt"))
(dprint . ("dprint" "fmt" "--stdin" filepath))
(elm-format . ("elm-format" "--yes" "--stdin"))
(fish-indent . ("fish_indent"))
(fourmolu . ("fourmolu" "--stdin-input-file" filepath))
(gawk . ("gawk" "-f" "-" "--pretty-print=-"))
(gdformat . ("gdformat" "-"))
(gleam . ("gleam" "format" "--stdin"))
(gofmt . ("gofmt"))
(gofumpt . ("gofumpt"))
(goimports . ("goimports"))
(golangci-lint . ("golangci-lint" "fmt" "--stdin"))
(google-java-format . ("google-java-format" "-"))
(hclfmt . ("hclfmt"))
(html-beautify "html-beautify" "--file" "-" "--end-with-newline"
(apheleia-formatters-indent
"--indent-with-tabs" "--indent-size"))
(html-tidy "tidy"
"--quiet" "yes"
"--tidy-mark" "no"
"--vertical-space" "yes"
"-indent"
(when (derived-mode-p 'nxml-mode)
"-xml")
(apheleia-formatters-indent
"--indent-with-tabs" "--indent-spaces")
(apheleia-formatters-fill-column "-wrap"))
(hurlfmt . ("hurlfmt" "--no-color"))
(isort . ("isort" "-"))
(js-beautify "js-beautify" "--file" "-" "--end-with-newline"
(apheleia-formatters-indent
"--indent-with-tabs" "--indent-size"))
(jq "jq" "." "-M"
(apheleia-formatters-indent "--tab" "--indent"))
(lisp-indent . apheleia-indent-lisp-buffer)
(ktlint . ("ktlint" "--log-level=none" "--stdin" "-F" "-"))
(latexindent . ("latexindent" "--logfile=/dev/null"))
(mago . ("mago" "--no-version-check"
"format" "--stdin-input" "--stdin-filepath" filepath))
(mbake . ("mbake" "format" "--stdin"))
(meson . ("meson" "format"
"--editor-config" "--source-file-path" filepath "-"))
(mix-format . ("apheleia-from-project-root"
".formatter.exs" "apheleia-mix-format" filepath))
(muon . ("muon" "fmt" "-e" "-"))
(nixfmt . ("nixfmt"))
(nomad . ("nomad" "fmt" "-"))
(ocamlformat . ("ocamlformat" "-" "--name" filepath
"--enable-outside-detected-project"))
(ocp-indent . ("ocp-indent"))
(ormolu . ("ormolu" "--stdin-input-file" filepath))
(opentofu . ("tofu" "fmt" "-"))
(oxfmt . ("apheleia-npx" "oxfmt" inplace))
(perltidy . ("perltidy" "--quiet" "--standard-error-output"
(apheleia-formatters-indent "-t" "-i")
(apheleia-formatters-fill-column "-l")))
(pgformatter . ("pg_format"
(apheleia-formatters-indent "--tabs" "--spaces" 'tab-width)
(apheleia-formatters-fill-column "--wrap-limit")))
(phpcs . ("apheleia-phpcs"))
(pkl . ("apheleia-pkl" "format" "-"))
(prettier
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(prettier-css
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=css"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(prettier-html
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=html"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(prettier-graphql
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=graphql"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(prettier-javascript
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=babel-flow"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(prettier-json
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=json"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(prettier-json-stringify
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=json-stringify"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(prettier-markdown
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=markdown"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(prettier-ruby
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
"--plugin=@prettier/plugin-ruby" "--parser=ruby"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(prettier-scss
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=scss"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(prettier-svelte
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
"--plugin=prettier-plugin-svelte" "--parser=svelte"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(prettier-typescript
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=typescript"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(prettier-yaml
. ("apheleia-npx" "prettier" "--stdin-filepath" filepath
"--parser=yaml"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(purs-tidy . ("apheleia-npx" "purs-tidy" "format"))
(pyang . ("pyang" "--ignore-errors" "-f" "yang"))
(robotidy . ("robotidy" "--no-color" "-"
(apheleia-formatters-indent nil "--indent")
(apheleia-formatters-fill-column "--line-length")))
(r-styler . ("R" "--no-echo" "--no-save" "--no-restore" "-e"
"styler::style_text(readLines(file('stdin')))"))
(python3-json
. ("python3" "-m" "json.tool"
(apheleia-formatters-indent "--tab" "--indent")))
(rubocop . ("rubocop" "--stdin" filepath "-a"
"--stderr" "--format" "quiet" "--fail-level" "fatal"
"--force-exclusion"))
(ruby-standard . ("standardrb" "--stdin" filepath "--fix" "--stderr"
"--format" "quiet" "--fail-level" "fatal"))
(ruby-syntax-tree . ("apheleia-from-project-root"
".streerc" "stree" "format" filepath))
(rumdl . ("rumdl" "fmt" "--stdin" "--stdin-filename" filepath))
(ruff . ("ruff" "format"
"--silent"
(apheleia-formatters-fill-column "--line-length")
"--stdin-filename" filepath
"-"))
(ruff-isort . ("ruff" "check"
"-n"
"--select" "I"
"--fix" "--fix-only"
"--stdin-filename" filepath
"-"))
(slint . ("slint-lsp" "format" filepath))
(snakefmt . ("snakefmt"
(apheleia-formatters-fill-column "--line-length")
"-"))
(sqlfluff . ("sqlfluff" "format" "--disable-progress-bar" "-"))
;; Note: do not pass any parser or printer flags to shfmt,
;; doing so causes editorconfig configuration to be bypassed altogether.
(shfmt . ("shfmt" "-filename" filepath "-"))
(rufo . ("rufo" "--filename" filepath "--simple-exit"))
(stylua . ("stylua" "-"))
(rustfmt . ("rustfmt" "--quiet" "--emit" "stdout"))
(taplo . ("taplo" "format" "--colors" "never" "-"))
(terraform . ("terraform" "fmt" "-"))
(treefmt . ("treefmt" "--stdin" filepath))
(typstyle . ("typstyle"))
(vfmt . ("v" "fmt"))
(xmllint . ("xmllint" "--format" "-"))
(yapf . ("yapf"))
(yq-csv . ("yq" "--prettyPrint" "--no-colors"
"--input-format" "csv" "--output-format" "csv"))
(yq-json . ("yq" "--prettyPrint" "--no-colors"
"--input-format" "json" "--output-format" "json"
(apheleia-formatters-indent nil "--indent")))
(yq-properties . ("yq" "--prettyPrint" "--no-colors"
"--input-format" "props" "--output-format" "props"))
(yq-toml . ("yq" "--prettyPrint" "--no-colors"
"--input-format" "toml" "--output-format" "toml"))
(yq-tsv . ("yq" "--prettyPrint" "--no-colors"
"--input-format" "tsv" "--output-format" "tsv"))
(yq-xml . ("yq" "--prettyPrint" "--no-colors"
"--input-format" "xml" "--output-format" "xml"
(apheleia-formatters-indent nil "--indent")))
(yq-yaml . ("yq" "--prettyPrint" "--no-colors"
"--input-format" "yaml" "--output-format" "yaml"
(apheleia-formatters-indent nil "--indent")))
(zig-fmt . ("zig" "fmt" "--stdin")))
"Alist of code formatting commands.
The keys may be any symbols you want, and the values are shell
commands, lists of strings and symbols, or a function symbol.
If the value is a function, the function will be called with
keyword arguments (see the implementation of
`apheleia--run-formatter-function' to see which). It should use
`cl-defun' with `&allow-other-keys' for forward compatibility.
Otherwise in Lisp code, the format of commands is similar to what
you pass to `make-process', except as follows.
Normally, the contents of the current buffer are passed to the
command on stdin, and the output is read from stdout. However, if
you use the symbol `file' as one of the elements of commands,
then the filename of the current buffer is substituted for
it. (Use `filepath' instead of `file' if you need the filename of
the current buffer, but you still want its contents to be passed
on stdin.)
If you instead use the symbol `input' as one of the elements of
commands, then the contents of the current buffer are written to
a temporary file and its name is substituted for `input'. Also,
if you use the symbol `output' as one of the elements of
commands, then it is substituted with the name of a temporary
file. In that case, it is expected that the command writes to
that file, and the file is then read into an Emacs buffer.
If you use the symbol `inplace' as one of the elements of the
list, then the contents of the current buffer are written to a
temporary file and its name is substituted for `inplace'.
However, unlike `input', it is expected that the formatter write
the formatted file back to the same file in place. In other
words, `inplace' is like `input' and `output' together.
If you use the symbol `npx' as one of the elements of commands,
then the first string element of the command list is resolved
inside node_modules/.bin if such a directory exists anywhere
above the current `default-directory'.
\(However, instead of using `npx', consider using
\"apheleia-npx\", which is a built-in script that will replicate
the effect, but will also work with Yarn PNP projects and other
npm project types that may exist in the future.)
Any list elements that are not strings and not any of the special
symbols mentioned above will be evaluated when the formatter is
invoked, and spliced into the list. A form can evaluate either to
a string or to a list of strings.
The \"scripts/formatters\" subdirectory of the Apheleia source
repository is automatically prepended to $PATH (variable
`exec-path', to be specific) when invoking external formatters.
This is intended for internal use. If you would like to define
your own script, you can simply place it on your normal $PATH
rather than using this system."
:type '(alist
:key-type symbol
:value-type
(choice
(repeat
(choice
(string :tag "Argument")
(const :tag "Look for command in node_modules/.bin" npx)
(const :tag "TODO: docstring" inplace)
(const :tag "Name of file being formatted" filepath)
(const :tag "Name of real file used for input" file)
(const :tag "Name of temporary file used for input" input)
(const :tag "Name of temporary file used for output" output)))
(function :tag "Formatter function")))
:group 'apheleia)