feat(cue): add context support for CUE

This commit is contained in:
Hoang Nguyen 2023-11-18 00:00:00 +07:00 committed by Lewis Russell
parent 0ddf6f069f
commit 4757afb4f9
3 changed files with 109 additions and 0 deletions

View file

@ -25,6 +25,7 @@ Note: if you need support for Neovim 0.6.x please use the tag `compat/0.6`.
- [x] `cpp`
- [x] `css`
- [x] `cuda`
- [x] `cue`
- [x] `d`
- [x] `dart`
- [x] `elixir`

19
queries/cue/context.scm Normal file
View file

@ -0,0 +1,19 @@
([
(import_declaration)
(let_clause)
] @context)
(field
(value (_) @context.end)
) @context
(call_expression
(arguments (_) @context.end)
) @context
(_
([
(for_clause)
(guard_clause)
] (_)+ @context.end)
) @context

89
test/test.cue Normal file
View file

@ -0,0 +1,89 @@
package main
import (
"strings"
"encoding/json"
)
jsonVal: json.Marshal({
hello: strings.ToUpper("world")
list: [1, 2]
nested: foo: "bar"
})
apps: ["nginx", "express", "postgres"]
#labels: [string]: string
stack: {
let local = {
name: "Alice"
}
local
injected: _ @tag(inj, type=int)
for i, app in apps
if app != "nginx" {
"\(app)": {
if app == "postgres" {
isPostgres: true
}
name: app
labels: #labels & {
app: "foo"
tier: "\(i)"
}
}
}
}