language-formatters-pre-commit-hooks
language-formatters-pre-commit-hooks copied to clipboard
Allow sorting TOML table keys
trafficstars
Quite often you want to keep the overall structure of a TOML file, but sort the keys within. For example, a Cargo.toml file:
[package]
name = "xyz"
[dependencies]
tokio = {version = "1.38.0", features = ["full"]}
clap = {version = "4.5.4", features = ["derive", "env"]}
Right now this will be re-formatted as
[dependencies]
clap = {version = "4.5.4", features = ["derive", "env"]}
tokio = {version = "1.38.0", features = ["full"]}
[package]
name = "xyz"
Which is annoying - I'd like to keep the [package] table at the top, but just sort the keys (dependencies, mostly) within:
[package]
name = "xyz"
[dependencies]
clap = {version = "4.5.4", features = ["derive", "env"]}
tokio = {version = "1.38.0", features = ["full"]}
This MR adds a flag to support this.