Closed hungnguyen1503 closed 1 year ago
I don't understand the question. Are you saying that you want the braces to be highlighted when the cursor is on top of the zero, or do you not want the braces to be highlighted?
Yes, That's what I want.
Which of the two?
I don't want the braces to be highlighted in #if 0
because #if 0
is equivalent to comment code in C language
Your code won't work because it is invalid C. You need a name for the new type after the structure declaration:
typedef struct {
struct_b b;
} my_struct_t;
But even with that out of the way, I don't know how to make it work. Here is a query which matches your requirements:
(preproc_if
condition: (number_literal) @cond (#not-eq? @cond "0")
(type_definition
(struct_specifier
(field_declaration_list
"{" @opening
"}" @closing) @container)))
The key is the predicate check (#not-eq? @cond "0")
which makes sure that the
number (which must be a literal) is not zero. However, you will still get
highlighting because this other query still matches:
(field_declaration_list
(("{" @opening)
("}" @closing))) @container
You could try to remove that query, but then highlighting of structure brackets
won't work anywhere but an #if
context. The only solution I could imagine is
to write a custom predicate (see :h treesitter-predicates
) which checks that the
syntax highlight group of the @container
capture to see if it is the comment
group.
Hi, I checked the issues of my source code, and it seems that the error is from clangd, I tried config Clangd on Visual Studio Code and it gives me the same error. Your plugin works great. Thank you for your support, this ticket can be closed.
Describe the bug
If brackets are inside 0 then the rainbow will highlight it.
Expected behavior
Could you please support me with a config rainbow plugin?
Screenshots