Closed radimsuckr closed 1 year ago
Hey @radimsuckr,
thanks for flagging the issue! Parsing the text
stage {
action {
provider = "bar"
}
}
results in
(body [0, 0] - [4, 1]
(block [0, 0] - [4, 1]
(identifier [0, 0] - [0, 5])
(block_start [0, 6] - [0, 7])
(body [1, 2] - [3, 3]
(block [1, 2] - [3, 3]
(identifier [1, 2] - [1, 8])
(block_start [1, 9] - [1, 10])
(body [2, 4] - [2, 20]
(attribute [2, 4] - [2, 20]
(identifier [2, 4] - [2, 12])
(expression [2, 15] - [2, 20]
(literal_value [2, 15] - [2, 20]
(string_lit [2, 15] - [2, 20]
(quoted_template_start [2, 15] - [2, 16])
(template_literal [2, 16] - [2, 19])
(quoted_template_end [2, 19] - [2, 20]))))))
(block_end [3, 2] - [3, 3])))
(block_end [4, 0] - [4, 1]))))
so "provider" is an attribute of the "action" block and its value is a literal string. That seems parsed about right.
The queries in nvim-treesitter
are very tailored to terraform, i suspect this line https://github.com/nvim-treesitter/nvim-treesitter/blob/6d0cee2f570ab848c0049be5a84a20acba3e8217/queries/hcl/highlights.scm#L93
Would you mind reraising this issue in nvim-treesitter
? I suspect the long-term solution would be something like https://github.com/tree-sitter/tree-sitter-typescript does with TSX and Typescript, just with terraform, packer, etc; so that nvim-treesitter can use a proper terraform parser.
Hey, im currently rewriting the queries for nvim-treesitter terraform; ill make sure to write a test for this situation!
Ok worked on highlights a bit on a branch, FPs should be a bit better; references also now have their leading part ( the resource to reference ) highlighted with same color as the resource block, which should help to identify them in templateas better. Ill submit a PR to nvim-treesitter once my PR introducing terraform as a distinct dialect is merged. before:
after:
This should be solved with the latest version of nvim-treesitter
Describe the bug The
provider
keyword is highlighted as a keyword even though it is part of a configuration block of a resource.To Reproduce Steps to reproduce the behavior:
action
block nested in astage
block of aaws_codepipeline
resourceprovider
argument in theaction
blockprovider
argument is highlighted as a keywordExpected behavior
provider
should be a plain argument, not a keyword.Screenshots
Additional context I use the latest version provided by nvim-treesitter/nvim-treesitter.