Hi all, my WIT formatter just got merged into topiary main!
This formatter can handle newer stuff like async and feature gates!
https://github.com/tweag/topiary/blob/main/topiary-cli/tests/samples/input/wit.wit#L162-L184
cargo install --git https://github.com/tweag/topiary --no-default-features topiary-cli --features=wit
topiary fmt path/to/my_file.wit!
for stdin:
cat input.wit | topiary fmt --language wit
P.S.
A lot of these changes were based off of work on my fork of tree-sitter-wit https://github.com/mkatychev/tree-sitter-wit/tree/rc-1.
If your code editor supports tree-sitter, you can get the new syntax highlighting as well!
image.png
Hey this is awesome! :)
How would someone use this/get started using topiary? Is there an easy Emacs onboarding path? Neovim? VSCode, etc? Seems like it should be run as a binary alongside other tooling?
Hey Victor, I'm not sure about VSCode as I don't use it but for neovim I set an Autocmd (I'm sure emacs has an equivalent) to do a file format on save
Here's my use of topiary for WIT in neovim:
local autocmd = vim.api.nvim_create_autocmd
autocmd("BufWritePre", {
pattern = { "*.wit" },
callback = function()
local fmt_cmd_table = {
["wit"] = "topiary format --language wit",
}
format_buf(fmt_cmd_table[vim.bo.filetype])
end,
})
I've omitted other languages but the pattern should be the same for vimscript or emacs
there is https://marketplace.visualstudio.com/items?itemName=GordonSmith.wit-lang and also https://github.com/bytecodealliance/vscode-wit (which may be an earlier version?).....
@Mikhail Katychev Thanks for this! It doesnt look like topiary has a way to check for formatting like rustfmt --check, that would be nice to have in CI jobs. do you have any context with that project to know why its absent or if they'd be open to adding it?
Hey @Pat Hickey good callout! The test cases in the topiary-cli crate definitely have that logic in place. I think it's absent because the work just hasn't been done for it.
Last updated: Dec 06 2025 at 05:03 UTC