mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
yaml: improve highlights and locals (#946)
- More scopes
- Highlight strings as strings
- Recognize more keys/fields
Improvements can be seen with this weird yaml:
```yaml
{ foo: bar }
---
{a: [b, c], [d, e]: f}
---
- { single line, a: b}
- { multi
line, a: b}
---
"fooo": bar
'foo': bar
one: two
```
This commit is contained in:
parent
0bbc6e3d16
commit
fe4e4aa286
2 changed files with 33 additions and 14 deletions
|
|
@ -1,9 +1,9 @@
|
|||
(block_mapping_pair key: (_) @field)
|
||||
(flow_mapping (_ key: (_) @field))
|
||||
(boolean_scalar) @boolean
|
||||
(null_scalar) @constant.builtin
|
||||
(double_quote_scalar) @string
|
||||
(single_quote_scalar) @string
|
||||
(block_scalar) @string
|
||||
(string_scalar) @string
|
||||
(escape_sequence) @string.escape
|
||||
(integer_scalar) @number
|
||||
(float_scalar) @number
|
||||
|
|
@ -14,20 +14,35 @@
|
|||
(yaml_directive) @keyword
|
||||
(ERROR) @error
|
||||
|
||||
(block_mapping_pair
|
||||
key: (flow_node [(double_quote_scalar) (single_quote_scalar)] @field))
|
||||
(block_mapping_pair
|
||||
key: (flow_node (plain_scalar (string_scalar) @field)))
|
||||
|
||||
(flow_mapping
|
||||
(_ key: (flow_node [(double_quote_scalar) (single_quote_scalar)] @field)))
|
||||
(flow_mapping
|
||||
(_ key: (flow_node (plain_scalar (string_scalar) @field))))
|
||||
|
||||
[
|
||||
","
|
||||
"-"
|
||||
":"
|
||||
">"
|
||||
"?"
|
||||
"|"
|
||||
","
|
||||
"-"
|
||||
":"
|
||||
">"
|
||||
"?"
|
||||
"|"
|
||||
] @punctuation.delimiter
|
||||
|
||||
[
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
["*" "&"] @punctuation.special
|
||||
[
|
||||
"*"
|
||||
"&"
|
||||
"---"
|
||||
"..."
|
||||
] @punctuation.special
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
(document) @scope
|
||||
[
|
||||
(stream)
|
||||
(document)
|
||||
(block_node)
|
||||
] @scope
|
||||
|
||||
(anchor_name) @definition
|
||||
(alias_name) @reference
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue