We identified that having a project file that's understood by the tooling around Slint would have several benefits to support larger scale projects by centralising settings in a well-defined location.
This issue proposes to introduce slint.project.json as a configuration file
File Format
The file format shall be JSON with the extension of supporting comments.
Location
The file shall be read by the Slint compiler, the preview tool as well as by the LSP implementation. When loading a .slint file in order to compile the entry component as instructed, the tools shall look in the directory of the .slint file and in the directory hierarchy upwards for a slint.project.json file. In the case of the slint::slint! macro in the Rust integration, the starting point for the lookup shall be the CARGO_MANIFEST_DIR.
Purpose
Initially the file shall allow configuring the following settings:
The default style to be used.
A list of include search paths for .slint files.
A list of file paths to custom fonts to load (replaces import "foo.ttf" syntax)
The version of Slint the .slint files are intended to be compatible with.
The license of Slint selected by the user.
This could also be extended in the future to allow defining an entry point, so that tools like the preview tool could be pointed to a slint.project.json file.
Priority
Some of these settings are also configurable through different means, such as the style with the SLINT_STYLE environment variable. The order of priority shall be from lowest to highest priority:
Environment variables
slint.project.json value
API / Command line option
Schema
A schema shall be provided, which allows for the validation of the project settings file and code completion in IDEs
The proposed initial schema is:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://slint.dev/slint.project.schema.json",
"title": "Slint Project Settings",
"description": "Various configurable settings when using Slint with .slint files",
"type": "object",
"properties": {
"style": {
"description": "The style to use when loading and rendering the UI",
"type": "string"
},
"includes": {
"description": "A list of include search paths, relative to the slint.project.json file",
"type": "array",
"items": {
"type": "string",
}
},
"fonts": {
"description": "A list of file paths to font files, relative to the slint.project.json file",
"type": "array",
"items": {
"type": "string",
}
},
"version": {
"description": "The Slint version number the project files are intended to be compatible with",
"type": "string",
}
}
}
We identified that having a project file that's understood by the tooling around Slint would have several benefits to support larger scale projects by centralising settings in a well-defined location.
This issue proposes to introduce
slint.project.json
as a configuration fileFile Format
The file format shall be JSON with the extension of supporting comments.
Location
The file shall be read by the Slint compiler, the preview tool as well as by the LSP implementation. When loading a .slint file in order to compile the entry component as instructed, the tools shall look in the directory of the .slint file and in the directory hierarchy upwards for a
slint.project.json
file. In the case of theslint::slint!
macro in the Rust integration, the starting point for the lookup shall be theCARGO_MANIFEST_DIR
.Purpose
Initially the file shall allow configuring the following settings:
import "foo.ttf"
syntax)This could also be extended in the future to allow defining an entry point, so that tools like the preview tool could be pointed to a
slint.project.json
file.Priority
Some of these settings are also configurable through different means, such as the style with the
SLINT_STYLE
environment variable. The order of priority shall be from lowest to highest priority:slint.project.json
valueSchema
A schema shall be provided, which allows for the validation of the project settings file and code completion in IDEs
The proposed initial schema is: