1
0
Fork
You've already forked lite-formatters
0
A simple formatter plugin for lite-xl. (fork from GitHub)
  • Lua 100%
2026年07月04日 17:22:20 -04:00
modules fix: Don't use prettier for JSON; use yq instead. 2026年07月04日 12:52:32 -04:00
.gitignore Reworked data storage with module system and updated formatter modules docs references 2025年11月21日 20:36:34 +01:00
init.lua fix: Whoops, forgot the pcall here. 2026年07月04日 17:22:20 -04:00
license add MIT license 2021年04月28日 14:01:23 -07:00
manifest.json Reworked data storage with module system and updated formatter modules docs references 2025年11月21日 20:36:34 +01:00
README.md docs: Note that this is a fork. 2026年06月09日 19:01:37 +02:00

Formatter Plugin

This repository is a fork of https://github.com/vincens2005/lite-formatters. It is not the officially accepted version available in lpm.

A simple formatter plugin for lite and Lite XL.

Installation

Use lpm to install this plugin: lpm install formatter.

Note

This plugin does not provide the bundled executable binary files needed to run the formatters themselves. You must install the desired formatters yourself.

If you want to customize the cli arguments for a specific formatter, you can do this from your init.lua script.

Here's and example:

config.jsbeautify_args = {"-r", "-s 4", "-p", "-b end-expand"} -- set jsBeautify arguments to indent with spaces.

Usage

The default keymap to format the current doc is alt+shift+f.

The command is formatter:format-doc.

To make Lite XL automatically format the current document on each save, add the following config to USERDIR/init.lua:

config.plugins.formatter = common.merge({
 format_on_save = true
}, config.plugins.formatter)

Adding a formatter module

Here is an example of a formatter module:

formatter_jsbeautify.lua

-- mod-version:3 lite-xl 2.1
-- https://www.npmjs.com/package/js-beautify
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:

  • Add the correct Lite XL version tag at the top
  • Keep the arguments inside config.formattername_args
  • Set a name
  • Add it to the list in README.md and keep it alphabetically sorted

Then make a pull request on Github.