tree-sitter / tree-sitter-rust

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

both struct and trait share `type_identifier` nodes - perhaps better on separate nodes #182

Closed EdmundsEcho closed 1 year ago

EdmundsEcho commented 1 year ago

I'm using neovim with tree-sitter and treesitter-playground. I was hoping to highlight traits differently compared to struct. However, each node seems to be tagged the same way.


trait MyTrait {}
//    ^ type_identifier

struct MyStruct {}
//     ^ type_identifier

Here is a sample of the complete output using :TSNodeUnderCursor

# Treesitter
* Parser: rust
* Node: type_identifier
* Range: 
  - Start row: 11
  - End row: 11
  - Start col: 8
  - End col: 15

Generally (likely an aside), but traits are not types... dyn Traits on the other hand are. IMO it may be useful to maintain a distinction between all three (types, from Trait, from dyn Trait).

amaanq commented 1 year ago

you can write queries that can distinguish them