Stream: general

Topic: WIT formatter out now!


view this post on Zulip Mikhail Katychev (Apr 04 2025 at 19:48):

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

Install:

cargo install --git https://github.com/tweag/topiary --no-default-features topiary-cli --features=wit

Usage

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

Contribute to tweag/topiary development by creating an account on GitHub.
Tree Sitter grammar for Web Assembly Interface Types - GitHub - mkatychev/tree-sitter-wit at rc-1

view this post on Zulip Victor Adossi (Apr 06 2025 at 04:43):

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?

view this post on Zulip Mikhail Katychev (Apr 06 2025 at 17:22):

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

view this post on Zulip Mikhail Katychev (Apr 08 2025 at 15:23):

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

view this post on Zulip Ralph (Apr 10 2025 at 10:00):

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?).....

Extension for Visual Studio Code - WIT (WebAssembly Interface Type) Language Extension for VSCode
Visual Studio Code extension to recognize and highlight the WebAssembly Interface Type (WIT) IDL. - bytecodealliance/vscode-wit

view this post on Zulip Pat Hickey (Apr 10 2025 at 15:51):

@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?

view this post on Zulip Mikhail Katychev (Apr 15 2025 at 16:59):

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