-
Notifications
You must be signed in to change notification settings - Fork 992
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
Modern D tree-sitter grammar and queries #2827
base: master
Are you sure you want to change the base?
Conversation
@@ -33,6 +33,7 @@ tree-sitter = "0.20.10" | |||
tree-sitter-bash = { git = "https://github.com/tree-sitter/tree-sitter-bash", rev = "4488aa41406547e478636a4fcfd24f5bbc3f2f74", optional = true } | |||
tree-sitter-c = { version = "0.20.6", optional = true } | |||
tree-sitter-cpp = { version = "0.20.0", optional = true } | |||
tree-sitter-d = { version = "0.3.8", optional = true } |
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.
why was this added?
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 believe you need the actual tree-sitter grammar for D. I was literally following the pattern used elsewhere.
Note that the crate associated with tree-sitter-d was only created by me last night. But it is a crate now.
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.
It's already added to lapce, but we don't use crates and we don't add grammars directly
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.
Um. Ok. (Btw, if this was documented somewhere it would have helped me.)
What do I need to do to make lapce find my grammar if not this? (Note that this is a different grammar than the one gishadow added -- the grammar he used is older and has some flaws. I created my grammar about a year ago because of defects in the cybershadow grammar.)
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, the queries have to match the grammar! My queries are written against my grammar, and won't work with the other one.
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'll try updating the submodule instead, now that I know about it. :-)
tree-sitter grammars are now dynamically loaded and I can see D is included in it. So you don't need to add the tree-sitter dependencie. The only thing you'll need to add is the queries. |
So how does it know how to find the grammar itself? Maybe I'm missing something here, but I was following (I thought) the pattern used for other grammars. |
Ah, I see now, gishadow used a fork of my grammar, but unfortunately it doesn't have the right queries. That's because the highlights query there is probably not ideal for lapce. The default highlights is based on the highlighting used by upstream. |
CHANGELOG.md
if this change could be valuable to usersI'm the author of the tree-sitter-d crate (and the grammar itself), and have provided this grammar for other editors. I did test this and it seems to work, whereas the stock build I downloaded does not seem to have syntax highlighting for D at all, which was very disappointing (as I use D in my day job).