-
Notifications
You must be signed in to change notification settings - Fork 51
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 meson as formatter #261
Conversation
Super excited for this! |
Me too, but still figuring out, what the best way of doing this is. I never managed to create an issue in meson, since some things don't work as expected. With muon you can use You are also a contributor in meson, so maybe you have an idea how to do this in a way, that is already supported in v1.5.0 and we should create an issue there, so that it would be supported in a better way, than through a hack 🤔 Edit: I created mesonbuild/meson#13791 |
8f2d7d8
to
96c5f1f
Compare
Maybe that is an issue that I can get to in the future. |
61d1fef
to
de9d504
Compare
de9d504
to
8f9a2f0
Compare
Since meson v1.7.0 released today, this now works, there are two version checks in the code atm, since only >=1.7.0 supports the needed feature, to use the stdin. I tried several ways to "polyfill" this behavior in >=1.5.0 < 1.7.0 but didn't succeed. Feel free to try this, it should work as expected. |
Since meson 1.5.0 meson has a format subcommand, see https://mesonbuild.com/Commands.html#format
now we have two version checks atm, but this is here, to make it clear, why only > 1.7.0 is supported for this feature
09f3914
to
3d212e8
Compare
Add meson as formatter
Since meson
1.5.0
meson has a format subcommand, see hereMeson has support for stdin as input since
1.7.0
see here (from the PR from here: mesonbuild/meson#13793)Notes
This only works since meson 1.7.0 because:
I tested several ways on how to get this to work with >= 1.5.0 and < 1.7.0. But after countless attempts, it didn't work, for some tests see e.g. Totto16/vscode-meson:add_meson_formatter_experiments and in the files utils.ts:55 and utils.ts:104
The main problem with using somethings like "/dev/stdin" "/dev/fd/0" "/proc/self/fd/0" instead of the "-" option only supported since 1.7.0 is the way node child processes handle stdin, see here

If anyone has an idea, on how to "polyfill" stdin in >=1.5.0 < 1.7.0 please share it with me 😓
Conclusion
Otherwise this works fine, I tested it with the 1.7.0 release and it works as expected.
Every new setting works as expected, it is a bit annoying, that, if you make some errors in the config, you have to check the output, and don't get intellisense (the error) in the file (if it's in the current workspace) , but thats a "premium" feature and not essential to this PR
TODO
meson.format
files