Open AlejandroSuero opened 6 months ago
How would you expect them to be highlighted?
@clason I am not sure, inside the define call it could treat them as bash|zsh|sh|...
commands when in an .{bash|zsh|sh|...}
files. For example:
define style_calls
inside a .sh
file: (command) ; [31:3 - 20]
name: (command_name) ; [31:3 - 8]
(word) ; [31:3 - 8]
argument: (word) ; [31:10 - 20]
(command) ; [32:4 - 24]
name: (command_name) ; [32:4 - 24]
(command_substitution) ; [32:4 - 24]
(command) ; [32:6 - 23]
name: (command_name) ; [32:6 - 9]
(word) ; [32:6 - 9]
argument: (concatenation) ; [32:11 - 16]
(simple_expansion) ; [32:11 - 12]
(special_variable_name) ; [32:12 - 12]
(word) ; [32:13 - 16]
argument: (word) ; [32:18 - 18]
argument: (command_substitution) ; [32:20 - 23]
(command) ; [32:22 - 22]
name: (command_name) ; [32:22 - 22]
(number) ; [32:22 - 22]
(command) ; [33:4 - 25]
name: (command_name) ; [33:4 - 7]
(word) ; [33:4 - 7]
argument: (concatenation) ; [33:9 - 25]
(expansion) ; [33:9 - 16]
(variable_name) ; [33:11 - 15]
(ERROR) ; [33:17 - 20]
(word) ; [33:21 - 24]
(word) ; [33:25 - 25]
(command) ; [34:4 - 18]
name: (command_name) ; [34:4 - 7]
(word) ; [34:4 - 7]
argument: (expansion) ; [34:9 - 18]
(variable_name) ; [34:11 - 17]
(command) ; [35:3 - 7]
name: (command_name) ; [35:3 - 7]
(word) ; [35:3 - 7]
:Inspect
: style_calls
as @variable.parameter
and numbers
and Uppercase variables
as @string
.
sh
: (command) ; [31:3 - 7]
name: (command_name) ; [31:3 - 7]
(word) ; [31:3 - 7]
(command) ; [32:4 - 43]
name: (command_name) ; [32:4 - 43]
(concatenation) ; [32:4 - 43]
(word) ; [32:4 - 4]
(command_substitution) ; [32:5 - 43]
(command) ; [32:7 - 42]
name: (command_name) ; [32:7 - 10]
(word) ; [32:7 - 10]
argument: (concatenation) ; [32:12 - 42]
(word) ; [32:12 - 23]
(string) ; [32:24 - 42]
(string_content) ; [32:25 - 41]
:Inspect
: style_calls
as @variable.parameter
and "..."
as @string
That's not possible, though. The make query can't know what file it is in. Feel free to make a PR adding a bash
injection; maybe that is good enough. But if it isn't, then the current state is the best we can do.
@clason it will be my first time touching this code base, do you know where should I do it?
The relevant query is make/injections.scm
.
@clason one question I have, what should I do to put the injection?
make/injections.scm
contains.((comment) @injection.content
(#set! injection.language "comment"))
((shell_text) @injection.content
(#set! injection.language "bash"))
((shell_command) @injection.content
(#set! injection.language "bash"))
make/highlights.scm
contains:(define_directive
"define" @keyword
name: (word) @string.special.symbol
[
"="
":="
"::="
; ":::="
"?="
"!="
]? @operator
"endef" @keyword)
My question is, wouldn't be better to assign to highlights.scm
value: (...)
and try to match it there? Seems that the problem that I have is that value:
is not set and therefore it takes it as raw_text
as default.
No, since we can only assign single captures to single nodes exposed by the parser.
If you are not (yet) sufficiently familiar with treesitter queries, no worries; but then you'll have to wait for some else to do this. (Queries are community contributed.)
@clason I haven't written a single one yet 😥 but I will give it a try, in the meantime if anyone does it will be nice too ✌️.
Describe the highlighting problem
Makefile
and using adefine <name>\n...\n endef
the inside values will be highlighted as a whole and withraw_text
.target
calling thedefine
with$(call <defined>,"...")
it highlights the arguments astext
, including thestrings
.Example snippet that causes the problem
Tree-sitter parsing result
Example screenshot
:Inspect
of both:rose-pine-moon
more on how to configure here:Expected behavior
To have highlights other than
raw_text
ortext
, at least thestrings
.Output of
:checkhealth nvim-treesitter
Output of
nvim --version
Additional context
No response