mirror of
https://github.com/slint-ui/slint.git
synced 2025-12-23 09:19:32 +00:00
|
Some checks are pending
autofix.ci / lint_typecheck (push) Waiting to run
autofix.ci / format_fix (push) Waiting to run
CI / docs (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / material-components (push) Blocked by required conditions
CI / files-changed (push) Waiting to run
CI / python_test (macos-14) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, macos-14, stable) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, 1.88) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, 1.88) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / cpp_test_driver (macos-14) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.88) (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
In this new style, these are some of the options:
### Single import stays in single line
In:
```slint
import {Foo} from "file.slint";
```
Out:
```slint
import { Foo } from "file.slint";
```
### Multiple imports stays in single line if below line length threshold
In:
```slint
import {Foo, Bar, Zar} from "file.slint";
```
Out:
```slint
import { Foo, Bar, Zar } from "file.slint";
```
### Many imports are multiline if above line length threshold
```slint
import { Foo, Bar as BarBer, Quz, Baz, Snaf, Tatta, Tar, Jar } from "./here.slint";
```
Out:
```slint
import {
Foo,
Bar as BarBer,
Quz,
Baz,
Snaf,
Tatta,
Tar,
Jar,
} from "./here.slint";
```
### Trailing comma forces new line (whether it's one or more)
In:
```slint
import {Foo,} from "file.slint";
```
Out:
```slint
import {
Foo,
} from "file.slint";
```
|
||
|---|---|---|
| .. | ||
| fmt.rs | ||
| README.md | ||
| tool.rs | ||
| writer.rs | ||
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 stdoutslint-lsp format -i <path>- reads the file and saves the output to the same fileslint-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.
- Install the extension Custom Format by Vehmloewff. Marketplace link
- Build slint-lsp locally.
- 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"
}
]
}
- (Optional) Allow formatting or save, or set this formatter as default for .slint files.
- Enjoy! Your .slint files are now formatted.