tree-sitter-grammars / tree-sitter-hlsl

HLSL grammar for tree-sitter
MIT License
10 stars 3 forks source link

feature: highlights.scm #70

Open XavierCS-dev opened 1 month ago

XavierCS-dev commented 1 month ago

Did you check the tree-sitter docs?

Is your feature request related to a problem? Please describe.

I need a highlights.scm file so I can use this grammar in an extension for the Zed code editor, but I have no idea how to create one myself.

Describe the solution you'd like

A highlights.scm file like this one https://github.com/tree-sitter/tree-sitter-cpp/blob/master/queries/highlights.scm.

Describe alternatives you've considered

I tried making one myself but couldn't figure out how to make one given the grammar files.

Additional context

No response

theHamsta commented 1 month ago

Hi! For nvim-treesitter you can inherit highlights of another grammar. I think this is not possible for zed. So you could take the highlights.scm that zed uses for C++ and extend it in a similar spirit as https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/hlsl/highlights.scm (just paste this additional text below Zed's highlight.scm for C++). You would need to replace #lua-match? by #match? and maybe #keyword.modifier by #keyword (I don't know whether the modifier is known to Zed)

I hope this helps. I don't know how I provide a hightlight.scm that would work for most editors. I know there have been some efforts to standardize. But I personally wouldn't feel confident what's the current state on this. Contributions welcome when they are in line what tree-sitter-c and tree-sitter-cpp offer

XavierCS-dev commented 1 month ago

Ah thank you! I didn't know about the existence of that!