feat: add goctl parser and queries

This commit is contained in:
zhaown 2024-07-07 23:27:21 +08:00 committed by GitHub
parent ad43c7f19e
commit f9aa4f060e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 105 additions and 0 deletions

11
queries/goctl/folds.scm Normal file
View file

@ -0,0 +1,11 @@
[
(typeGroupSpec)
(typeSingleSpec)
(typeStruct)
(serviceSpec)
(serviceBody)
(importStatement)
(serviceServerSpec)
(infoStatement)
(structType)
] @fold

View file

@ -0,0 +1,79 @@
; Key Symbol
"=" @operator
[
"."
","
":"
";"
] @punctuation.delimiter
[
"("
")"
"{"
"}"
"["
"]"
] @punctuation.bracket
; Keywords
[
"syntax"
"info"
"service"
] @keyword
"import" @keyword.import
"returns" @keyword.return
[
"type"
"struct"
] @keyword.type
[
"@doc"
"@handler"
"@server"
] @attribute
; Service
(serviceName) @type
; Httpmethod
(HTTPMETHOD) @keyword.operator
; Field
(fieldType) @type.builtin
(fieldName) @variable.member
(anonymousField) @variable.member
; Functions
(handlerValue) @function.method
; Strings
(VALUE) @string
(tag) @string.documentation
(PATH) @string.special.path
; Comments
(comment) @comment @spell
(key) @variable.member
(identValue) @string
(DURATION) @number
(NUMBER) @number
; Struct
(structNameId) @type
(body) @type

View file

@ -0,0 +1,3 @@
; Inject comment language for goctl
((comment) @injection.content
(#set! injection.language "comment"))