language-formatters-pre-commit-hooks icon indicating copy to clipboard operation
language-formatters-pre-commit-hooks copied to clipboard

Allow sorting TOML table keys

Open orf opened this issue 1 year ago • 0 comments
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.

orf avatar Nov 08 '24 21:11 orf