gdamore / tree-sitter-d

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

Special characters in strings are not being highlighted #33

Closed al1-ce closed 1 month ago

al1-ce commented 4 months ago

image

Top string is highlighted correctly (and actually good according to my syntax file) (seems tree-sitter or t-s-d dies on warning lines) Bottom string is highlighted via tree-sitter-d and it does not show \" correctly (and also does not respect syntax file)

gdamore commented 1 month ago

Yes, we don't do interior parsing of the strings. This is indeed something we could do.

gdamore commented 1 month ago

(If you're curious, the reason we don't do an grammatical check on the interior strings is that D's use of multiline strings means that you really need to assess this at lexing time, rather than during grammar parsing. I've chosen, for better or worse, to treat the strings as single grammatical objects as a result of lexing phase. Which means that they don't get treatment like what you're asking for.)

Fixing this is certainly possible, but it will be not particularly trivial, and might rather substantially slow down the grammar, and add a lot of bloat to what is already the most complex tree-sitter grammar in existence. I'll need to think about whether it's something important enough to do.)

gdamore commented 1 month ago

Good news... I have a change coming that will give you this!

gdamore commented 1 month ago

As of right now in master, the necessary grammar bits are present, I have to update queries, and then I'll close this bug.

gdamore commented 1 month ago

Queries for nova, the main basic highlighter are done, and I've posted a PR to update Zed.dev.

This probably won't help you with neovim, but the maintainer of that plugin will need to update accordingly. I am happy to provide guidance to that person if needed.

In the meantime I am closing this bug. You may want to file another bug against neovim to pick up the updates.

al1-ce commented 1 month ago

Treesitter plugin for neovim uses upstream of default (or specified) branch of language repo, so, everything is technically already should be updated, I'll check if it works a bit later