gdamore / tree-sitter-d

D Grammar for Tree Sitter
MIT License
41 stars 7 forks source link

Q: How do you actually use the grammar? #25

Closed snosov1 closed 8 months ago

snosov1 commented 8 months ago

Hello!

Sorry for the stupid question, but after installing - how do I actually use the grammar? The online tutorials mention the language major mode needs to be implemented with tree-sitter in mind (and the current convention is that for each <lang>-mode people would implement <lang>-ts-mode). Some languages have these modes in MELPA. But others including D (which, I guess, you can explain by relatively low popularity - but even Python don't seem to have it). There's also conflicting pieces of information about built-in tree-sitter (the one I have) and external packages (that seem to suggest using built-in instead).

Can you, please, shed the light on it? Maybe, point to a relevant tutorial or smth?

dejlek commented 8 months ago

I would like to know that too. :) Asked on IRC earlier today - nobody knew the answer. I've seen helix and neovim (can) use tree-sitter, but I could not find information how, so it would be really nice if someone writes a section in the REDME about how to use it...

snosov1 commented 8 months ago

Vladimir @CyberShadow, maybe, you have some pointers?

gdamore commented 8 months ago

The details of the manner in which you use the grammar are totally dependent upon the editor your use. If you're using emacs (it sounds like that), then you'll need to read the documentation.

Typically in addition to the grammar itself you need to pick up the query list. One thing I've noticed recently is that we weren't doing the best job of exposing the query list in a discoverable way.

snosov1 commented 8 months ago

Yeah, my question is about Emacs, specifically. From your answer I get that you use something else and have no experience using it with Emacs, right?

gdamore commented 8 months ago

Correct. I use this grammar with Nova, and I've tested it with Helix, and I know others have used it with Lapce and with Vim.

gdamore commented 8 months ago

I've added some metadata that might help. I don't know how this works with emacs, but if you've followed instructions try again.

The following might help:

https://www.masteringemacs.org/article/how-to-get-started-tree-sitter

snosov1 commented 8 months ago

Got it, thanks! Yeah, there are some docs that introduce tree-sitter in Emacs - still, I can't seem to find a way other than "let's hack some elisp code myself" which feels wrong (like, am I the first/only one trying to use it?!). Anyway, thanks - I'll keep looking!