Formatters for Pragtical
- autoflake python formatter
- black python formatter
- clang-format
- cljfmt
- cmake-format
- crystal
- css-beautify
- dartformat
- dfmt
- elixir
- elm-format
- esformatter
- gdformat
- google-java-format
- goimports
- html-beautify
- isort python formatter
- js-beautify
- juliaformat
- luaformatter
- ocp-indent
- ormolu
- perltidy
- phpcbf
- prettier
- qmlformat
- rubocop
- ruff
- rustfmt
- shformat
- sql-formatter
- styluaformat
- tidy
- tsformat
- vfmt
- zigfmt
-
Clone this repository into the pragtical
plugins/formatter
folder -
Make sure you have the command that formatter uses installed, or it won't work.
-
Extra configuration: If you want to customize a formatter, you can do this from your
init.lua
script. Example:
config.plugins.formatter.jsbeautify = {
-- Optionally disable this formmater
enabled = false,
-- Optionally set path of executable
path = "/path/to/js-beautify",
-- Set jsBeautify arguments to indent with spaces.
args = "-r -s 4 -p -b end-expand"
}
the default keymap to format the current doc is alt+shift+f
the command is formatter:format-doc
to format a document at each save add the following config to
your user init.lua
as shown:
config.plugins.formatter.format_on_save = true
Example from jsbeautify.lua
:
-- for JS Beautify fortmatter
return {
label = "JS Beautifier",
file_patterns = {"%.js$"},
command = {"js-beautify", "$ARGS", "$FILENAME"},
-- make sure to keep -r arg if you change this
args = "-r -q -s 1 -t -p -b end-expand"
}
- choose a unique file name
- make sure to set a label
- make sure to add it to the list in readme.md (and keep it alphabetical)