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
Last updated: Apr 08 2025 at 23:03 UTC