slint/tools/lsp/fmt
Olivier Goffart 233b238465
fmt: Keep spaces after element node even if the last token is a space (#9256)
So that callback connection keep their spacing even if the space is now
attached to the connection rather than to the parent.

Fixes #9055

This was a regression because #8764 added a
`test(SyntaxKind::Semicolon)` which caused the whitespaces to be attached
to the previous node
2025-08-26 16:48:57 +02:00
..
fmt.rs fmt: Keep spaces after element node even if the last token is a space (#9256) 2025-08-26 16:48:57 +02:00
README.md Simplify commercial license (#3063) 2024-05-31 14:06:17 +02:00
tool.rs Ensure error reporting when using buffered file writes 2025-08-20 10:22:45 +02:00
writer.rs Fix clippy issues, plus a few manual cleanups 2025-02-06 17:28:51 +01:00

Slint-fmt

This tool for formatting .slint syntax is in a very early stage. There might be certain parts of the language that are not yet supported. If you find any such examples, please open an issue including the example and the expected output.

Building

This tool is part of slint-lsp. See the README file in lsp for building information.

Usage

The built binary can be used in following ways:

  • slint-lsp format <path> - reads the file and outputs the formatted version to stdout
  • slint-lsp format -i <path> - reads the file and saves the output to the same file
  • slint-lsp format /dev/stdin - using /dev/stdin you can achieve the special behavior of reading from stdin and writing to stdout

Note that .slint files are formatted, while .md and .rs files are searched for .slint blocks. All other files are left untouched.

Usage with VSCode

While we don't yet have a proper VSCode integration for this formatter, here is a simple way how you can get around it.

  1. Install the extension Custom Format by Vehmloewff. Marketplace link
  2. Build slint-lsp locally.
  3. Add a section like this to your vscode settings.json:
{
  "custom-format.formatters": [
    {
      "language": "slint",
      "command": "/path/to/your/built/slint-lsp format /dev/stdin"
    }
  ]
}
  1. (Optional) Allow formatting or save, or set this formatter as default for .slint files.
  2. Enjoy! Your .slint files are now formatted.