From 4cd6bea89791706b34b473addb5325035316d9cf Mon Sep 17 00:00:00 2001 From: Jen-Chieh Date: Wed, 6 Dec 2023 02:44:43 -0800 Subject: [PATCH] feat: Add LLVM support --- .gitmodules | 6 ++ CHANGELOG.md | 1 + queries/llvm/highlights.scm | 156 ++++++++++++++++++++++++++++++++++++ repos/llvm | 1 + tree-sitter-langs.el | 1 + 5 files changed, 165 insertions(+) create mode 100644 queries/llvm/highlights.scm create mode 160000 repos/llvm diff --git a/.gitmodules b/.gitmodules index 976c43ce..ab8eca8a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -534,3 +534,9 @@ update = none ignore = dirty branch = main +[submodule "repos/llvm"] + path = repos/llvm + url = https://github.com/benwilliamgraham/tree-sitter-llvm + update = none + ignore = dirty + branch = main diff --git a/CHANGELOG.md b/CHANGELOG.md index 67204081..8883bb1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## Unreleased +- Add `LLVM` support ## 0.12.82 - 2023-12-03 diff --git a/queries/llvm/highlights.scm b/queries/llvm/highlights.scm new file mode 100644 index 00000000..b82c6845 --- /dev/null +++ b/queries/llvm/highlights.scm @@ -0,0 +1,156 @@ +(type) @type +(type_keyword) @type.builtin + +(type [ + (local_var) + (global_var) + ] @type) + +(argument) @variable.parameter + +(_ inst_name: _ @keyword) + +[ + "catch" + "filter" +] @keyword + +[ + "to" + "nuw" + "nsw" + "exact" + "unwind" + "from" + "cleanup" + "swifterror" + "volatile" + "inbounds" + "inrange" +] @keyword +(icmp_cond) @keyword +(fcmp_cond) @keyword + +(fast_math) @keyword + +(_ callee: _ @function) +(function_header name: _ @function) + +[ + "declare" + "define" +] @keyword.function +(calling_conv) @keyword + +[ + "target" + "triple" + "datalayout" + "source_filename" + "addrspace" + "blockaddress" + "align" + "syncscope" + "within" + "uselistorder" + "uselistorder_bb" + "module" + "asm" + "sideeffect" + "alignstack" + "inteldialect" + "unwind" + "type" + "global" + "constant" + "externally_initialized" + "alias" + "ifunc" + "section" + "comdat" + "thread_local" + "localdynamic" + "initialexec" + "localexec" + "any" + "exactmatch" + "largest" + "nodeduplicate" + "samesize" + "distinct" + "attributes" + "vscale" + "no_cfi" +] @keyword + +(linkage_aux) @keyword +(dso_local) @keyword +(visibility) @keyword +(dll_storage_class) @keyword +(unnamed_addr) @keyword +(attribute_name) @keyword + +(function_header [ + (linkage) + (calling_conv) + (unnamed_addr) + ] @keyword) + +(number) @cnumber +(comment) @comment +(string) @string +(cstring) @string +(label) @label +(_ inst_name: "ret" @keyword) +(float) @number + +[ + (local_var) + (global_var) +] @variable + +[ + (struct_value) + (array_value) + (vector_value) +] @constructor + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<" + ">" + "<{" + "}>" +] @punctuation.bracket + +[ + "," + ":" +] @punctuation.delimiter + +[ + "=" + "|" + "x" + "..." +] @operator + +[ + "true" + "false" +] @constant.builtin + +[ + "undef" + "poison" + "null" + "none" + "zeroinitializer" +] @constant.builtin + +(ERROR) @error diff --git a/repos/llvm b/repos/llvm new file mode 160000 index 00000000..1b96e58f --- /dev/null +++ b/repos/llvm @@ -0,0 +1 @@ +Subproject commit 1b96e58faf558ce057d4dc664b904528aee743cb diff --git a/tree-sitter-langs.el b/tree-sitter-langs.el index 12e10a1f..06a678fa 100644 --- a/tree-sitter-langs.el +++ b/tree-sitter-langs.el @@ -162,6 +162,7 @@ See `tree-sitter-langs-repos'." (julia-mode . julia) (kotlin-mode . kotlin) (latex-mode . latex) + (llvm-mode . llvm) (lua-mode . lua) (makefile-mode . make) (makefile-automake-mode . make)