Taplo supports configuration via file, unsurprisingly it uses the TOML format.
By default, every tool looks for one in the working directory or the root of the workspace by the following names (in precedence order):
include property is an array of glob path strings that are relative to the working directory (or root of the workspace), the matched files are included in the operations by the tools unless explicitly overwritten. The pattern supports globstars (
**) for recursive search.
If this property is omitted,
TOML files will be searched in the entire child directory tree from the root.
include is present but empty, no files will be included.
include = ["Cargo.toml", "some_directory/**/*.toml"]
exclude property has the same semantics as
include and takes precedence over it.
The following will exclude
Cargo.toml from the includes written above, so files matching
some_directory/**/*.toml will be included only.
exclude = ["Cargo.toml"]
formatting table contains optional formatting options for the formatter:
[formatting] align_entries = false
schema table consists of only two keys:
path: the path of the schema, this can be either path to a local file or an URL with the schemes
filescheme is also accepted, it is the same as specifying a local path)
enabled: whether to enable the schema or not (
[schema] path = "./path/to/schema.json" enabled = true
Or a configuration that uses a built-in schema:
[schema] path = "taplo://taplo.toml"
Or a remote one:
[schema] path = "https://example.com/my_schema.json"
rule array of tables consist of rules that overwrite the above configuration based on some conditions. Thus it has the same
schema settings, and the
exclude with the same semantics as their global variants, however this time they are used to determine whether the rule applies.
keys of a rule is an array of dotted keys that scope the rule to a specific part within a single document. The keys also support glob patterns.
In case of overlapping rules, the last defined rule always takes precedence.
Let's say we want to sort our
Cargo dependencies, but nothing else, here is how we would do that:
[formatting] reorder_keys = false [[rule]] include = ["**/Cargo.toml"] keys = ["dependencies"] [rule.formatting] reorder_keys = true