aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirawi2021-11-29 01:38:17 +0000
committerGitHub2021-11-29 01:38:17 +0000
commit6f1a7b1220c2ae565a2542fb089eb6d87f0a9421 (patch)
treec0ee12e9208129b15ec7dc35d52f8cf00f5c0abb
parentdc53e65b9e9be71c49eaa86e0f4dabb69f586e2e (diff)
Add llvm grammar (#1167)
-rw-r--r--.gitmodules4
-rw-r--r--book/src/themes.md5
-rw-r--r--languages.toml8
-rw-r--r--runtime/queries/llvm/highlights.scm14
4 files changed, 29 insertions, 2 deletions
diff --git a/.gitmodules b/.gitmodules
index 039a3ee3..6295b9e9 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -146,3 +146,7 @@
path = helix-syntax/languages/tree-sitter-wgsl
url = https://github.com/szebniok/tree-sitter-wgsl
shallow = true
+[submodule "helix-syntax/tree-sitter-llvm"]
+ path = helix-syntax/languages/tree-sitter-llvm
+ url = https://github.com/benwilliamgraham/tree-sitter-llvm
+ shallow = true
diff --git a/book/src/themes.md b/book/src/themes.md
index ecbbb6e9..fd3f5b1e 100644
--- a/book/src/themes.md
+++ b/book/src/themes.md
@@ -145,11 +145,12 @@ We use a similar set of scopes as
- `conditional` - `if`, `else`
- `repeat` - `for`, `while`, `loop`
- `import` - `import`, `export`
- - (TODO: return?)
+ - `return`
+ - `operator` - `or`, `in`
- `directive` - Preprocessor directives (`#if` in C)
- `function` - `fn`, `func`
-- `operator` - `||`, `+=`, `>`, `or`
+- `operator` - `||`, `+=`, `>`
- `function`
- `builtin`
diff --git a/languages.toml b/languages.toml
index 5dcbd872..4208e4b6 100644
--- a/languages.toml
+++ b/languages.toml
@@ -413,3 +413,11 @@ file-types = ["wgsl"]
roots = []
comment-token = "//"
indent = { tab-width = 4, unit = " " }
+
+[[language]]
+name = "llvm"
+scope = "source.llvm"
+roots = []
+file-types = ["ll"]
+comment-token = ";"
+indent = { tab-width = 2, unit = " " }
diff --git a/runtime/queries/llvm/highlights.scm b/runtime/queries/llvm/highlights.scm
new file mode 100644
index 00000000..73afe85e
--- /dev/null
+++ b/runtime/queries/llvm/highlights.scm
@@ -0,0 +1,14 @@
+(type) @type
+(statement) @keyword.operator
+(number) @constant.numeric.integer
+(comment) @comment
+(string) @string
+(label) @label
+(keyword) @keyword
+"ret" @keyword.control.return
+(boolean) @constant.builtin.boolean
+(float) @constant.numeric.float
+(constant) @constant
+(identifier) @variable
+(symbol) @punctuation.delimiter
+(bracket) @punctuation.bracket