-
Notifications
You must be signed in to change notification settings - Fork 74
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
Dune syntax highlighting fix #742
Conversation
A couple of things I've noticed so far:
@rgrinberg: do you know of any large dune files that could be used to verify the syntax highlighting? |
I used this dune docs(https://dune.readthedocs.io/en/stable/dune-files.html#dune) which I assumed is the official doc for referencing of the stanzas and It didn't contain |
Hmm. You are right about The executable fields are all listed though: https://dune.readthedocs.io/en/stable/dune-files.html#executable |
Also, I assumed the declarations were variables because the available syntax highlight options with a foreground color were either constants, variables, keywords, or strings. And I was certain they weren't constants or keywords. What do you recommend I use instead so I can make necessary changes |
If it's not one of those, then don't include the |
syntaxes/dune.json
Outdated
"1": { "name": "keyword.language.dune" } | ||
}, | ||
"patterns": [{ | ||
"comment": "name/public_name/package/libraries/link_flags/link_deps/modules/root_module/preprocess/preprocessor_deps/modules_without_implementation/optional/enabled_if/promote/foreign_stubs/foreign_archives/forbidden_libraries/embed_in_plugin_libraries", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mnxn The executable optional fields were listed here. I'll go through it again to see why they weren't highlighted in your tests
Feel free to open an issue on dune (https://github.com/ocaml/dune) if you notice undocumented fields @SaySayo. |
Noted. I'll make the necessary changes. |
To be clear, Do you mean |
Yes, that's right. |
syntaxes/dune.json
Outdated
}, | ||
"patterns": [{ | ||
"comment": "name/public_name/package/libraries/link_flags/link_deps/modules/root_module/preprocess/preprocessor_deps/modules_without_implementation/optional/enabled_if/promote/foreign_stubs/foreign_archives/forbidden_libraries/embed_in_plugin_libraries", | ||
"begin": "\\([[:space:]]*(name|public_name|package/libraries|link_flags|link_deps|modules|root_module|preprocess|preprocessor_deps|modules_without_implementation|optional|enabled_if|promote|foreign_stubs|foreign_archives|forbidden_libraries|embed_in_plugin_libraries)\\b", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the /
in package/libraries
is a typo here. It should be package|libraries
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also name|public_name
should be separated into it's own rule with "contentName": "variable.other.declaration.dune"
the same way as in a library
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modes
is missing: https://dune.readthedocs.io/en/stable/dune-files.html#executables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntaxes/dune.json
Outdated
}, | ||
{ | ||
"comment": "executable/executables", | ||
"begin": "\\([[:space:]]*(executables*)\\b", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The *
makes the rule match executable
followed by any number of s
's.
It should be:
"begin": "\\([[:space:]]*(executables*)\\b", | |
"begin": "\\([[:space:]]*(executable|executables)\\b", |
Also executables
needs to support names
and public_names
: https://dune.readthedocs.io/en/stable/dune-files.html#executables
@SaySayo do you plan to work on this PR? |
Yes I do. I made the changes @mnxn requested and I'm waiting on a review. |
Sorry for not looking at this earlier. I tested this syntax with some example I think there is still a lot of work left until this syntax is complete. The core issue is that there are too many unrelated fields in certain rules: like this line for example. Some of the fields can have extra options or specific input, so it doesn't make sense to combine them all. What could make this easier to work on is an example I don't want to merge this PR until the syntax is complete. You are free to keep working on this if you want, but I can't guarantee to keep up with code reviews. I've had much less time for reviews recently and this is a very big PR. |
I'll keep working on this PR till it fixes all the issues you mentioned, might take me a couple weeks as I have less time to work on it. I'll ping you when I think its fully ready for a review so as to reduce the amount of times you have to run a review on this PR. In the meantime I'll convert this PR to a draft since it's not ready to be merged while I continue to work on it. |
Sounds good. Thanks. |
@mnxn We're currently reviewing the PR with @SaySayo and are not sure how to address your comment about the unrecognized fields. You previously mentioned:
And advised that some fields should not be highlighted. In your last comment, though, you're mentioning that
IIUC, these were previously highlighted, but @SaySayo removed it after your comment. What would you recommend we do? Should we create a new scope for these? Do you have any guidelines you're following to decide what is a Personally, I think that's fine if all the fields are highlighted, but we'll follow your recommendation here. |
Hello @mnxn I updated the dune syntax to address all the things you mentioned. Works well locally. Please review when you can and let me know if there's any required changes. Thank you! |
Yes that's fine @tmattio. Thank you for your time! |
@mnxn I completed an initial review of the PR and I believe it is ready for you to review as well. I noticed some issues that should be addressed:
However, fixing these shouldn't require massive changes, so it's not conflicting with additional reviews. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay in review.
This looks great! It's a huge improvement over the current syntax. Thank you for all your hard work!
Before merging, the .DS_Store
file needs to be removed and the branch needs to be rebased to fix the CHANGES.md
conflict.
@tmattio: |
930a815
to
ca44d22
Compare
Fixed the dune syntax by rewriting the dune.json in a similar fashion to the dune-project.json and dune-workspace.json syntaxes (#106). @mnxn please review