-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add option to specifiy a custom config #411
Comments
I have an easy fix: use VSCode instead. :D On a more serious note, it sounds like the ideal solution would be to have a flag that prints the formatted file to stdout, rather than replacing the file. Then you don't have to get the formatter's config semantics right. |
I'll respond to your serious note first: As for VSCode: |
I'm not sure how feasible it is to actually embed formatter in your macro, but with the recent API changes it would be possible to get a correct config file and use it on some code you have in memory or in a file somewhere else. stdin / stdout is probably doable, but as you say there needs to be absolutely no other output (stderr should be fine). I am not sure stdin will fully work, since we need the full file before we can start parsing and formatting, so anything other than |
One issue with compiling to C# is that you need to update each time the formatter updates, and then you probably always lag behind a bit. |
Reading from stdin - if it's necessary to read the entire input until EOF, then format and emit it, then so be it, I don't think there's a need to do streaming-style formatting. FYI: As @Gama11 mentioned - embedding the formatter in the C# macro would be not so feasible. I will setup the macro for every developer in our team who uses FlashDevelop - and do it only once, the |
added CLI option --stdin to switch to stdin/stdout mode, fixes HaxeCheckstyle#411
I'd like to have an option to manually tell the formatter which config file to use (overriding the default "closest parent directory" algorithm).
Use case:
I've implemented a Macro for FlashDevelop that adds automatic formatting when saving a file (similar to the VS Code integration's feature).
To retain Undo history (as VS Code does), I can't modify the file in place then tell FD, instead I have to create a temporary file with the same contents, run the formatter on that file, then load the contents and replace the editor's text itself with them - this retains the Undo. The limitation is that I have to create the temporary file in the same directory as the original file, to be sure it gets formatted with the current config. This is not very nice for multiple reasons (e.g. if something goes wrong and the file doesn't get deleted, it might accidentally be committed, also in same rare case it may crash FD), so I'd like to create the temporary file in a temp dir, determine which config is correct by performing the same "closest-parent" lookup as haxe-formatter does, and then tell haxe-formatter to format the temp file using that proper config.
If someone is interested, here it is (rename to HXFormat.cs):
HXFormat.txt
The text was updated successfully, but these errors were encountered: