diff options
| author | Santos Gallegos <stsewd@protonmail.com> | 2021-10-26 22:47:59 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-26 22:47:59 -0500 |
| commit | fe4e4aa286ba14e949948ef6e826d69c63048cdb (patch) | |
| tree | 82946fc7049d1d312833040df99d2e5b553baa37 | |
| parent | Update lockfile.json (diff) | |
| download | nvim-treesitter-fe4e4aa286ba14e949948ef6e826d69c63048cdb.tar nvim-treesitter-fe4e4aa286ba14e949948ef6e826d69c63048cdb.tar.gz nvim-treesitter-fe4e4aa286ba14e949948ef6e826d69c63048cdb.tar.bz2 nvim-treesitter-fe4e4aa286ba14e949948ef6e826d69c63048cdb.tar.lz nvim-treesitter-fe4e4aa286ba14e949948ef6e826d69c63048cdb.tar.xz nvim-treesitter-fe4e4aa286ba14e949948ef6e826d69c63048cdb.tar.zst nvim-treesitter-fe4e4aa286ba14e949948ef6e826d69c63048cdb.zip | |
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
```
| -rw-r--r-- | queries/yaml/highlights.scm | 41 | ||||
| -rw-r--r-- | queries/yaml/locals.scm | 6 |
2 files changed, 33 insertions, 14 deletions
diff --git a/queries/yaml/highlights.scm b/queries/yaml/highlights.scm index 818352bb7..89b9f20c0 100644 --- a/queries/yaml/highlights.scm +++ b/queries/yaml/highlights.scm @@ -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 diff --git a/queries/yaml/locals.scm b/queries/yaml/locals.scm index be91b5ca7..89167cf58 100644 --- a/queries/yaml/locals.scm +++ b/queries/yaml/locals.scm @@ -1,4 +1,8 @@ -(document) @scope +[ + (stream) + (document) + (block_node) +] @scope (anchor_name) @definition (alias_name) @reference |
