On 18/02/2023 05:27, Dmitry Gutov wrote: > On 16/02/2023 03:53, Dmitry Gutov wrote: >> But the new one will need to check that the parent is >> 'scoped_identifier', and the grandparent is not a 'call_expression' >> node, or 'use_as_clause', or 'use_declaration', etc, and the name >> itself is lowercase -- when so, skip highlighting. And highlight with >> one of the two faces when otherwise. >> >> Shouldn't be too hard to do, but I'm wary about the additional cost at >> runtime. > > So, this seems to work. > > At the cost of some performance overhead due to :pred in the 'variable' > query (the rest of the changes don't seem to affect the runtime -- guess > the Lisp calls were balanced out by fewer queries). It seems the check could be further simplified (no variable can be part of a scoping expression, I believe): (defun rust-ts-mode--variable-p (node) (let* ((parent (treesit-node-parent node)) (parent-type (treesit-node-type parent))) ;; Everything in a token_tree is an identifier. (not (string-match-p "token_tree\\|scoped_identifier" parent-type)))) But that does not improve performance. I also tried to create a query with negation, but it seems you can't do that for parent type. What works, and removes the performance drop, is enumerating all possible parent types which can contain an identifier to be highlighted as a variable. It's a moderately large list, see if I maybe missed some. Randy, Jostein, feedback welcome.