Closed williamhCode closed 1 year ago
Not much that can be done here, unless tree-sitter-cpp returns a node for whatever
bob
is.
The ask is to give injections a (unconditionally?) higher priority than the parent language (when both would have normally the same priority). This could be implemented or at least have discussion on how users could influence.
Is the problem that variable
has smaller priority? Because it should actually be visible if the range is smaller than the literal.
Yes, that is indeed the case (in the C highlights, which C++ inherits):
; Lower priority to prefer @parameter when identifier appears in parameter_declaration.
((identifier) @variable (#set! "priority" 95))
May want to remove that (and rely on query ordering for precedence).
Describe the highlighting problem
In a markdown file, if I write some cpp code, the
@text.literal.markdown
highlight overrides@variable.cpp
, so the highlighting is off.bob should be red
:Inspect
-Example snippet that causes the problem
section [0, 0] - [4, 0] markdown fenced_code_block [0, 0] - [4, 0] markdown fenced_code_block_delimiter [0, 0] - [0, 3] markdown info_string [0, 3] - [0, 6] markdown language [0, 3] - [0, 6] markdown block_continuation [1, 0] - [1, 0] markdown code_fence_content [1, 0] - [3, 0] markdown declaration [1, 0] - [1, 16] cpp type: type_identifier [1, 0] - [1, 6] cpp declarator: init_declarator [1, 7] - [1, 15] cpp declarator: identifier [1, 7] - [1, 10] cpp "=" [1, 11] - [1, 12] cpp value: initializer_list [1, 13] - [1, 15] cpp "{" [1, 13] - [1, 14] cpp "}" [1, 14] - [1, 15] cpp ";" [1, 15] - [1, 16] cpp expression_statement [2, 0] - [2, 17] cpp assignment_expression [2, 0] - [2, 16] cpp left: field_expression [2, 0] - [2, 8] cpp argument: identifier [2, 0] - [2, 3] cpp operator: "." [2, 3] - [2, 4] cpp field: field_identifier [2, 4] - [2, 8] cpp operator: "=" [2, 9] - [2, 10] cpp right: string_literal [2, 11] - [2, 16] cpp """ [2, 11] - [2, 12] cpp """ [2, 15] - [2, 16] cpp ";" [2, 16] - [2, 17] cpp "=" [1, 11] - [1, 12] markdown "{" [1, 13] - [1, 14] markdown "}" [1, 14] - [1, 15] markdown ";" [1, 15] - [1, 16] markdown block_continuation [2, 0] - [2, 0] markdown "." [2, 3] - [2, 4] markdown "=" [2, 9] - [2, 10] markdown """ [2, 11] - [2, 12] markdown """ [2, 15] - [2, 16] markdown ";" [2, 16] - [2, 17] markdown block_continuation [3, 0] - [3, 0] markdown fenced_code_block_delimiter [3, 0] - [3, 3] markdown
Output of
nvim --version
Additional context
Only happens with cpp as far as I've experienced.