Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gdamore
Copy link

@gdamore gdamore commented Dec 2, 2023

  • [ x ] Added an entry to CHANGELOG.md if this change could be valuable to users

I'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).

@@ -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 }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this added?

Copy link
Author

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.

Copy link
Collaborator

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

Copy link
Author

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.)

Copy link
Author

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.

Copy link
Author

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. :-)

@dzhou121
Copy link
Collaborator

dzhou121 commented Dec 2, 2023

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.

@gdamore
Copy link
Author

gdamore commented Dec 2, 2023

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.

@gdamore
Copy link
Author

gdamore commented Dec 2, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants