Skip to content
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

feat: implement format-on-save in vscode and baml-cli fmt #1246

Merged
merged 2 commits into from
Dec 14, 2024
Merged

Conversation

sxlijin
Copy link
Collaborator

@sxlijin sxlijin commented Dec 14, 2024

This wires up Dylan's work on setting up a BAML formatter and makes it possible to auto-format some BAML code:

  • it is now possible to format-on-save BAML code using the vscode extension by running baml.setDefaultFormatter as a command in vscode
  • baml-cli fmt will now work, if run in a dir containing a baml_src dir; it also supports dry-run (will write to stdout instead) and explicitly specifying baml files

The formatter itself is... not quite there yet. So baml-cli fmt will stay a hidden command.

  • there are some syntax rules it barfs on (enums? literals? something in integ-tests)
  • it rewrites comments possibly too aggressively (e.g. across multiple lines they're concatenated)
  • unclear how useful/useless it is without the ability to format template string contents
  • our current grammar can be pretty brittle in some cases (e.g. newlines are not allowed in angle brackets, c.f."map<\nstring, string>" is invalid)

Copy link

vercel bot commented Dec 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
baml ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 14, 2024 1:58am

Copy link
Contributor

ellipsis-dev bot commented Dec 14, 2024

⚠️ This PR is too big for Ellipsis, but support for larger PRs is coming soon. If you want us to prioritize this feature, let us know at [email protected]


Generated with ❤️ by ellipsis.dev

@sxlijin sxlijin changed the title feat: set up auto-format feat: implement format-on-save in vscode Dec 14, 2024
@sxlijin sxlijin changed the title feat: implement format-on-save in vscode feat: implement format-on-save in vscode and baml-cli fmt Dec 14, 2024
@sxlijin sxlijin added this pull request to the merge queue Dec 14, 2024
Merged via the queue into canary with commit 66af7c5 Dec 14, 2024
10 of 11 checks passed
@sxlijin sxlijin deleted the sam/baml-fmt branch December 14, 2024 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant