Closed lukepighetti closed 4 years ago
mint format
does support formatting individual files such as mint format file.mint
, this should not be difficult to implement.
Related for development: https://code.visualstudio.com/blogs/2016/11/15/formatters-best-practices
@s0kil I have never touched VSCode extensions before, I'd be happy to take a stab at it, is there a quick start guide somewhere?
EDIT: just saw your link, let me take a stab at it tonight
Also, format on save is controlled by VS Code, if the option is enabled in user settings, it calls the configured formatter.
It looks like VSCode wants the formatted text returned instead of having the command line tool edit the file in place. Do we have any way to output the mint format src/foo.mint
result to the terminal instead of editing the file in place?
Edit: It looks like the mint
CLI only outputs to file. https://github.com/mint-lang/mint/blob/master/src/commands/format.cr
We could have a hack similar to https://github.com/pragmagic/vscode-nim/blob/master/src/nimFormatting.ts, they save the current file as a temporary file /tmp/vscodenimdirty.nim
format that file with nimpretty
command, and then return the contents of that temporarily file to replace the file being formatted in the editor.
Resolved by https://github.com/s0kil/mint-vscode/pull/7
@lukepighetti Thank You!
What do we need to enable Option+Shift+F file formatting support?
It looks like
mint format
doesn't have any arguments for a specific file which is not ideal for this feature, but triggering a global format would be better than nothing. Also format on save.