aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiam Woodleigh-Hardinge <liam.woodleigh@gmail.com>2024-04-15 13:01:56 +0200
committerGitHub <noreply@github.com>2024-04-15 11:01:56 +0000
commit2a95ff14764af20d32ec1edb27e11c38a84b9478 (patch)
tree86866919963a36c9e23bd529409f2eb62290cb82
parentbot(lockfile): update cpp, cuda, glsl, hlsl, http, julia, norg, slang, unison, v (diff)
downloadnvim-treesitter-2a95ff14764af20d32ec1edb27e11c38a84b9478.tar
nvim-treesitter-2a95ff14764af20d32ec1edb27e11c38a84b9478.tar.gz
nvim-treesitter-2a95ff14764af20d32ec1edb27e11c38a84b9478.tar.bz2
nvim-treesitter-2a95ff14764af20d32ec1edb27e11c38a84b9478.tar.lz
nvim-treesitter-2a95ff14764af20d32ec1edb27e11c38a84b9478.tar.xz
nvim-treesitter-2a95ff14764af20d32ec1edb27e11c38a84b9478.tar.zst
nvim-treesitter-2a95ff14764af20d32ec1edb27e11c38a84b9478.zip
feat(wit): Add wit parser (#6428)
feat: Add injections.scm fix: reverse order of matching Co-authored-by: 再生花 <hoangtun0810@gmail.com> fix: lua match for functions doc: Resolve conflict fix: Amend incorrect alphabetical order
-rw-r--r--README.md1
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua8
-rw-r--r--queries/wit/highlights.scm81
-rw-r--r--queries/wit/injections.scm5
5 files changed, 98 insertions, 0 deletions
diff --git a/README.md b/README.md
index 52540cafe..2bf7c9175 100644
--- a/README.md
+++ b/README.md
@@ -438,6 +438,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [wgsl](https://github.com/szebniok/tree-sitter-wgsl) (maintained by @szebniok)
- [x] [wgsl_bevy](https://github.com/theHamsta/tree-sitter-wgsl-bevy) (maintained by @theHamsta)
- [x] [wing](https://github.com/winglang/tree-sitter-wing) (maintained by @gshpychka, @MarkMcCulloh)
+- [x] [wit](https://github.com/liamwh/tree-sitter-wit) (maintained by @liamwh)
- [x] [xcompose](https://github.com/ObserverOfTime/tree-sitter-xcompose) (maintained by @ObserverOfTime)
- [x] [xml](https://github.com/tree-sitter-grammars/tree-sitter-xml) (maintained by @ObserverOfTime)
- [x] [yaml](https://github.com/tree-sitter-grammars/tree-sitter-yaml) (maintained by @amaanq)
diff --git a/lockfile.json b/lockfile.json
index 5bf2f0ebf..529ad4e93 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -794,6 +794,9 @@
"wing": {
"revision": "5b6c2a5818a602557778d1bfc265d016cafa0712"
},
+ "wit": {
+ "revision": "39e81d6b4b0d811a62bcde46c876bf32e1475b5b"
+ },
"xcompose": {
"revision": "2383cc69a2c42cfade41c7cb971fb3862bec6df1"
},
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 9f1cb76c3..8e69192cd 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -2303,6 +2303,14 @@ list.wing = {
maintainers = { "@gshpychka", "@MarkMcCulloh" },
}
+list.wit = {
+ install_info = {
+ url = "https://github.com/liamwh/tree-sitter-wit",
+ files = { "src/parser.c" },
+ },
+ maintainers = { "@liamwh" },
+}
+
list.xcompose = {
install_info = {
url = "https://github.com/ObserverOfTime/tree-sitter-xcompose",
diff --git a/queries/wit/highlights.scm b/queries/wit/highlights.scm
new file mode 100644
index 000000000..237858ba2
--- /dev/null
+++ b/queries/wit/highlights.scm
@@ -0,0 +1,81 @@
+; Comments
+(line_comment) @comment
+
+(block_comment) @comment
+
+; Primitive Types
+[
+ "bool"
+ "s8"
+ "s16"
+ "s32"
+ "s64"
+ "u8"
+ "u16"
+ "u32"
+ "u64"
+ "float32"
+ "float64"
+ "char"
+ "string"
+ ; Container Types
+ "list"
+ "tuple"
+ "option"
+ "result"
+] @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
+
+; Brackets
+[
+ "{"
+ "}"
+ "("
+ ")"
+] @punctuation.bracket
diff --git a/queries/wit/injections.scm b/queries/wit/injections.scm
new file mode 100644
index 000000000..50b9b8fa9
--- /dev/null
+++ b/queries/wit/injections.scm
@@ -0,0 +1,5 @@
+((line_comment) @comment
+ (#set! injection.language "comment"))
+
+((block_comment) @comment
+ (#set! injection.language "comment"))