fix(wit): update parser and queries (#6528)

This commit is contained in:
Liam Woodleigh-Hardinge 2024-04-28 18:13:51 +02:00 committed by GitHub
parent dbbaa3f66e
commit 223f8dd2e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 127 additions and 61 deletions

View file

@ -801,7 +801,7 @@
"revision": "bd1d35cf3e013dc7e189b46a593bdc2b281b0dd7"
},
"wit": {
"revision": "ed13e0a3ee77833900a095d57d2685a1f7f91237"
"revision": "16e263143e230b79a00f6cc353f6fd860c4e5de5"
},
"xcompose": {
"revision": "2383cc69a2c42cfade41c7cb971fb3862bec6df1"

View file

@ -1,81 +1,150 @@
; Comments
(line_comment) @comment
(comment) @comment @spell
(block_comment) @comment
(ty
(id)) @type
(package_decl
(id)) @module
(valid_semver) @string.special
(world_item
name: (id) @module)
(interface_item
name: (id) @module)
(import_item
name: (id) @module
(extern_type
(interface_body)))
(import_item
name: (id) @function
(extern_type
(func_type)))
(export_item
name: (id) @module
(extern_type
(interface_body)))
(export_item
name: (id) @function
(extern_type
(func_type)))
(type_item
alias: (id) @type.definition)
(func_item
name: (id) @function)
(handle
(id) @type)
(named_type
name: (id) @variable.parameter)
(record_item
name: (id) @type)
(record_field
name: (id) @variable.member)
(flags_items
name: (id) @type)
(flags_body
(id) @variable.member)
(variant_items
name: (id) @type)
(variant_case
name: (id) @type)
(enum_items
name: (id) @type)
(enum_body
enum_cases: (id) @constant)
(resource_item
name: (id) @type)
(resource_method
"constructor" @constructor)
(toplevel_use_item
"use" @keyword.import)
(use_item
"use" @keyword.import)
(use_path
(id) @module)
"func" @keyword.function
[
"type"
"interface"
"world"
"package"
"resource"
"record"
"enum"
"flags"
"variant"
] @keyword.type
"static" @keyword.modifier
[
"include"
"import"
"export"
] @keyword.import
; Primitive Types
[
"bool"
"s8"
"s16"
"s32"
"s64"
"u8"
"u16"
"u32"
"u64"
"float32"
"float64"
"s8"
"s16"
"s32"
"s64"
"f32"
"f64"
"char"
"bool"
"string"
; Container Types
"list"
"tuple"
"list"
"option"
"result"
"borrow"
] @type.builtin
"func" @keyword.function
; Keywords for file structure and components
[
"record"
"enum"
"variant"
"flags"
"resource"
] @keyword.type
; Keywords for importing and exporting
[
"package"
"world"
"use"
"import"
] @keyword.import
; Resource Keywords
"static" @keyword.modifier
; Named Types (Capitalized identifiers)
((identifier) @type
(#match? @type "^[A-Z]"))
((identifier) @variable
(#match? @variable "^[a-z_][a-zA-Z0-9_]*$"))
; Constants (UPPER_CASE names and Enums)
((identifier) @constant
(#match? @constant "^[A-Z][A-Z0-9_]+$"))
; Functions and Methods (lowercase names followed by parentheses)
((identifier) @function
(#match? @function "^[a-z_][a-zA-Z0-9_]*%("))
; Punctuation
[
";"
":"
"@"
"->"
] @punctuation.special
; Delimiters
"," @punctuation.delimiter
[
"/"
";"
":"
","
] @punctuation.delimiter
; Brackets
[
"{"
"}"
"("
")"
] @punctuation.bracket
"=" @operator

View file

@ -1,5 +1,2 @@
((line_comment) @comment
(#set! injection.language "comment"))
((block_comment) @comment
((comment) @injection.content
(#set! injection.language "comment"))