lite-formatters
lite-formatters copied to clipboard
Code formatters for https://github.com/rxi/lite and https://github.com/franko/lite-xl
Formatters for lite and lite-xl
List of formatters (Keep alphabetical)
- autoflake python formatter:
formatter_autoflake.lua - black python formatter:
formatter_black.lua - clang-format:
formatter_clangformat.lua - cljfmt:
formatter_cljfmt.lua - cmake-format:
formatter_cmakeformat.lua - crystal:
formatter_crystal.lua - css-beautify:
formatter_cssbeautify.lua - dartformat:
formatter_dartformat.lua - dfmt:
formatter_dfmt.lua - elixir:
formatter_elixir.lua - elm-format:
formatter_elmformat.lua - esformatter:
formatter_esformatter.lua - gdformat:
formatter_gdformat.lua - google-java-format:
formatter_googlejavaformat.lua - goimports:
formatter_golang.lua - html-beautify:
formatter_htmlbeautify.lua - isort python formatter:
formatter_isort.lua - js-beautify:
formatter_jsbeautify.lua - luaformatter:
formatter_luaformatter.lua - ormolu:
formatter_ormolu.lua - perltidy:
formatter_perltidy.lua - ocp-indent:
formatter_ocpindent.lua - qmlformat:
formatter_qml.lua - rubocop:
formatter_rubocop.lua - rustfmt:
formatter_rustfmt.lua - shfmt:
formatter_shfmt.lua - vfmt:
formatter_vfmt.lua - sql-formatter:
formatter_sqlformatter.lua - zigfmt:
formatter_zigfmt.lua
Installation instructions
-
Copy the
formatter.luafile into the lite/lite-xldata/pluginsfolder -
To install any specific formatter, copy the corresponding file into the
data/pluginsfolder. List of formatters is at the top of this file. -
Make sure you have the command that formatter uses installed, or it won't work.
-
Extra configuration: If you want to customize the cli arguments for a specific formatter, you can do this from your
init.luascript. Example:
config.jsbeautify_args = {"-r", "-s 4", "-p", "-b end-expand"} -- set jsBeautify arguments to indent with spaces.
using the formatter
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.format_on_save = true
Adding a formatter
here is an example formatter:
-- mod-version:1 lite-xl 2.00
-- ^^^ lite-xl version tag ^^^
-- for JS Beautify fortmatter
local config = require "core.config"
local formatter = require "plugins.formatter"
config.jsbeautify_args = {"-r", "-q", "-s 1", "-t", "-p", "-b end-expand"} -- make sure to keep -r arg if you change this
formatter.add_formatter {
name = "JS Beautifier",
file_patterns = {"%.js$"},
command = "js-beautify $ARGS $FILENAME",
args = config.jsbeautify_args
}
a few things to keep in mind
- make sure to add the lite-xl version tag at the top
- make sure to keep the arguments inside
config.yourformatter_args - make sure to set a name
- make sure to add it to the list in readme.md (and keep it alphabetical)