feat: add cue

This commit is contained in:
Amaan Qureshi 2023-03-04 04:31:11 -05:00
parent d7cef15b01
commit 376d74006f
8 changed files with 237 additions and 0 deletions

View file

@ -196,6 +196,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [cpp](https://github.com/tree-sitter/tree-sitter-cpp) (maintained by @theHamsta)
- [x] [css](https://github.com/tree-sitter/tree-sitter-css) (maintained by @TravonteD)
- [x] [cuda](https://github.com/theHamsta/tree-sitter-cuda) (maintained by @theHamsta)
- [x] [cue](https://github.com/eonpatapon/tree-sitter-cue) (maintained by @amaanq)
- [x] [d](https://github.com/CyberShadow/tree-sitter-d) (experimental, maintained by @nawordar)
- [x] [dart](https://github.com/UserNobody14/tree-sitter-dart) (maintained by @akinsho)
- [x] [devicetree](https://github.com/joelspadin/tree-sitter-devicetree) (maintained by @jedrzejboczar)

View file

@ -68,6 +68,9 @@
"cuda": {
"revision": "91c3ca3e42326e0f7b83c82765940bbf7f91c847"
},
"cue": {
"revision": "4ffcda8c2bdfee1c2ba786cd503d0508ea92cca2"
},
"d": {
"revision": "c2fbf21bd3aa45495fe13247e040ad5815250032"
},

View file

@ -271,6 +271,14 @@ list.cuda = {
maintainers = { "@theHamsta" },
}
list.cue = {
install_info = {
url = "https://github.com/eonpatapon/tree-sitter-cue",
files = { "src/parser.c", "src/scanner.c" },
},
maintainers = { "@amaanq" },
}
list.d = {
install_info = {
url = "https://github.com/CyberShadow/tree-sitter-d",

5
queries/cue/folds.scm Normal file
View file

@ -0,0 +1,5 @@
[
(import_spec_list)
(field)
(string)
] @fold

164
queries/cue/highlights.scm Normal file
View file

@ -0,0 +1,164 @@
; Includes
[
"package"
"import"
] @include
; Namespaces
(package_identifier) @namespace
(import_spec ["." "_"] @punctuation.special)
[
(attr_path)
(package_path)
] @text.uri ;; In attributes
; Attributes
(attribute) @attribute
; Conditionals
"if" @conditional
; Repeats
[
"for"
] @repeat
(for_clause "_" @punctuation.special)
; Keywords
[
"let"
] @keyword
[
"in"
] @keyword.operator
; Operators
[
"+"
"-"
"*"
"/"
"|"
"&"
"||"
"&&"
"=="
"!="
"<"
"<="
">"
">="
"=~"
"!~"
"!"
"="
] @operator
; Fields & Properties
(field
(label
(identifier) @field))
(selector_expression
(_)
(identifier) @property)
; Functions
(call_expression
function: (identifier) @function.call)
(call_expression
function: (selector_expression
(_)
(identifier) @function.call))
(call_expression
function: (builtin_function) @function.call)
(builtin_function) @function.builtin
; Variables
(identifier) @variable
; Types
(primitive_type) @type.builtin
((identifier) @type
(#match? @type "^(#|_#)"))
[
(slice_type)
(pointer_type)
] @type ;; In attributes
; Punctuation
[
","
":"
] @punctuation.delimiter
[ "{" "}" ] @punctuation.bracket
[ "[" "]" ] @punctuation.bracket
[ "(" ")" ] @punctuation.bracket
[ "<" ">" ] @punctuation.bracket
[
(ellipsis)
"?"
] @punctuation.special
; Literals
(string) @string
[
(escape_char)
(escape_unicode)
] @string.escape
(number) @number
(float) @float
(si_unit
(float)
(_) @symbol)
(boolean) @boolean
[
(null)
(top)
(bottom)
] @constant.builtin
; Interpolations
(interpolation "\\(" @punctuation.special (_) ")" @punctuation.special) @none
(interpolation "\\(" (identifier) @variable ")")
; Commments
(comment) @comment @spell
; Errors
(ERROR) @error

21
queries/cue/indents.scm Normal file
View file

@ -0,0 +1,21 @@
[
(import_spec_list)
(field)
] @indent
[
"}"
"]"
")"
] @indent_end
[ "{" "}" ] @branch
[ "[" "]" ] @branch
[ "(" ")" ] @branch
[
(ERROR)
(comment)
] @auto

View file

@ -0,0 +1 @@
(comment) @comment

34
queries/cue/locals.scm Normal file
View file

@ -0,0 +1,34 @@
; Scopes
[
(source_file)
(field)
(for_clause)
] @scope
; References
(identifier) @reference
; Definitions
(import_spec
path: (string) @definition.import)
(field
(label
(identifier) @definition.field))
(package_identifier) @definition.namespace
(for_clause
(identifier) @definition.variable
(expression))
(for_clause
(identifier)
(identifier) @definition.variable
(expression))
(let_clause
(identifier) @definition.variable)