Skip to content

Implement autoformatter for tree-sitter query language #878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pokey opened this issue Jul 18, 2022 · 0 comments
Open

Implement autoformatter for tree-sitter query language #878

pokey opened this issue Jul 18, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@pokey
Copy link
Member

pokey commented Jul 18, 2022

It's a bit cumbersome to write our new tree-sitter queries (#616) because there is no autoformatter. I don't know of one today, but we could probably write one by leveraging the tree-sitter parser for tree-sitter-query. We might want to build the formatter using dprint. A couple possibly useful resources on dprint:

Alternately, we might look into using the machinery that @wenkokke developed for https://github.com/wenkokke/talonfmt

This autoformatter would obviously be useful outside of Cursorless for the many other projects writing tree-sitter queries

Update: today we're relying on @AndreasArvidsson's VSCode extension to do autoformatting for scm files, which is great for development, but doesn't support CI.

Also, per @auscompgeek's suggestion, we may want to consider writing the formatter as a prettier plugin. I poked through the docs a bit and from what I saw it looks like it's potentially a nice fit

We may also consider using https://topiary.tweag.io/, which has experimental support for formatting .scm files, but as of 2023-12-01 doesn't yet have a VSCode extension (see tweag/topiary#655 to track)

@pokey pokey added the enhancement New feature or request label Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant