Open MarkMcCulloh opened 1 month ago
Would it make sense that by default wing compile
will also format?
It would be a pretty bold choice, not sure I've seen any compilers/tools mutate user-created sources automatically during compilation. We could start with a --fix flag, which could also do other things like inserting semicolons.
Sounds good for the CLI, but can we make this the default behavior in VSCode? Format on save?
Use Case
An opinioned formatting tool helps keep code beautiful and frees PRs from formatting nitpicks. We have https://github.com/winglang/wing/issues/475 but it focuses on enforcing certain stylistic things present in the spec. It would be useful to focus on a minimal but useful whitespace formatter.
Proposed Solution
wing fmt
defaults to all wing files in the current directory, can otherwise provide a path to do the following:let x = 2;
becomeslet x = 2;
let x=2;
becomeslet x = 2;
func(a,b)
should becomefunc(a, b)
{
at end of line and unindenting for}
Additionally, we should expose this formatter in the vscode extension (see here)
Implementation Notes
Ideally this is something that can be implemented solely with the tree-sitter tree to keep it simple.
Component
No response
Community Notes