tree-sitter / tree-sitter-rust

Rust grammar for tree-sitter
MIT License
338 stars 96 forks source link

Highlight struct/enum/union keywords using @structure #180

Closed ebkalderon closed 1 year ago

ebkalderon commented 1 year ago

According to this resource, the Structure highlight group is meant to highlight keywords such as struct, enum, union, etc. By default, the @structure highlight group in nvim-treesitter links to Structure. As such, this parser should highlight the struct, enum, and union keywords using @structure instead of @keyword.

This change would enable third-party color schemes to highlight this keyword separately from other Rust keywords. For example, see this screenshot of Monokai in Sublime Text 4 doing just that.

Screenshot from 2023-05-29 20-13-33

amaanq commented 1 year ago

wrong repo

ebkalderon commented 1 year ago

Hello there, @amaanq! Would you mind clarifying a little what you mean? The request described above is to change the highlights.scm query script provided with tree-sitter-rust to emit the @structure highlight when the keywords struct, enum, and union are encountered, rather than emitting @keyword, as is currently done. This would increase the flexibility of downstream projects depending on tree-sitter-rust for highlighting. Is this understanding not accurate?

ebkalderon commented 11 months ago

Sorry to ping directly again, @amaanq, but I was wondering if you might be able to clarify why this issue is outside the scope of this repository? I understand that this repo contains the highlights.scm file which defines the highlight queries and TS groups, correct? Thanks again.

amaanq commented 10 months ago

Sorry, just seeing this again after cleaning my issues - it belongs in the tool that you use for highlighting, I am not sure what your screenshot is from but it's definitely not tree-sitter cli output, so file an issue there

ebkalderon commented 5 months ago

I know it's been a while since I last opened this issue, but I have no clue what I was thinking when I first wrote the issue description. I think I misunderstood what purpose tree-sitter-rust served in relation to nvim-treesitter and how queries in TS work in general. Sorry about that!

I have since opened a separate issue on the nvim-treesitter repo instead with a hopefully clearer explanation of what I was originally looking for: https://github.com/nvim-treesitter/nvim-treesitter/issues/6205