aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiam Woodleigh-Hardinge <liam.woodleigh@gmail.com>2024-04-28 18:13:51 +0200
committerGitHub <noreply@github.com>2024-04-28 16:13:51 +0000
commit223f8dd2e475ab790d9fede23681cd3c016fab79 (patch)
treee615f0f2986050ccfa635a8621f34e795b984061
parentfix(latex): update parser and queries (diff)
downloadnvim-treesitter-223f8dd2e475ab790d9fede23681cd3c016fab79.tar
nvim-treesitter-223f8dd2e475ab790d9fede23681cd3c016fab79.tar.gz
nvim-treesitter-223f8dd2e475ab790d9fede23681cd3c016fab79.tar.bz2
nvim-treesitter-223f8dd2e475ab790d9fede23681cd3c016fab79.tar.lz
nvim-treesitter-223f8dd2e475ab790d9fede23681cd3c016fab79.tar.xz
nvim-treesitter-223f8dd2e475ab790d9fede23681cd3c016fab79.tar.zst
nvim-treesitter-223f8dd2e475ab790d9fede23681cd3c016fab79.zip
fix(wit): update parser and queries (#6528)
-rw-r--r--lockfile.json2
-rw-r--r--queries/wit/highlights.scm177
-rw-r--r--queries/wit/injections.scm5
3 files changed, 125 insertions, 59 deletions
diff --git a/lockfile.json b/lockfile.json
index 74266b4c5..7970934ce 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -801,7 +801,7 @@
"revision": "bd1d35cf3e013dc7e189b46a593bdc2b281b0dd7"
},
"wit": {
- "revision": "ed13e0a3ee77833900a095d57d2685a1f7f91237"
+ "revision": "16e263143e230b79a00f6cc353f6fd860c4e5de5"
},
"xcompose": {
"revision": "2383cc69a2c42cfade41c7cb971fb3862bec6df1"
diff --git a/queries/wit/highlights.scm b/queries/wit/highlights.scm
index 237858ba2..983987b90 100644
--- a/queries/wit/highlights.scm
+++ b/queries/wit/highlights.scm
@@ -1,81 +1,150 @@
-; Comments
-(line_comment) @comment
+(comment) @comment @spell
-(block_comment) @comment
+(ty
+ (id)) @type
-; Primitive Types
-[
- "bool"
- "s8"
- "s16"
- "s32"
- "s64"
- "u8"
- "u16"
- "u32"
- "u64"
- "float32"
- "float64"
- "char"
- "string"
- ; Container Types
- "list"
- "tuple"
- "option"
- "result"
-] @type.builtin
+(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
-; Keywords for file structure and components
[
+ "type"
+ "interface"
+ "world"
+ "package"
+ "resource"
"record"
"enum"
- "variant"
"flags"
- "resource"
+ "variant"
] @keyword.type
-; Keywords for importing and exporting
+"static" @keyword.modifier
+
[
- "package"
- "world"
- "use"
+ "include"
"import"
+ "export"
] @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_]*%("))
+[
+ "u8"
+ "u16"
+ "u32"
+ "u64"
+ "s8"
+ "s16"
+ "s32"
+ "s64"
+ "f32"
+ "f64"
+ "char"
+ "bool"
+ "string"
+ "tuple"
+ "list"
+ "option"
+ "result"
+ "borrow"
+] @type.builtin
-; Punctuation
[
- ";"
- ":"
+ "@"
"->"
] @punctuation.special
-; Delimiters
-"," @punctuation.delimiter
+[
+ "/"
+ ";"
+ ":"
+ ","
+] @punctuation.delimiter
-; Brackets
[
"{"
"}"
"("
")"
] @punctuation.bracket
+
+"=" @operator
diff --git a/queries/wit/injections.scm b/queries/wit/injections.scm
index 50b9b8fa9..2f0e58eb6 100644
--- a/queries/wit/injections.scm
+++ b/queries/wit/injections.scm
@@ -1,5 +1,2 @@
-((line_comment) @comment
- (#set! injection.language "comment"))
-
-((block_comment) @comment
+((comment) @injection.content
(#set! injection.language "comment"))