Unnamed repository; edit this file 'description' to name the repository.
Add Move language support
Blaž Hrastnik 2024-04-18
parent 1d23796 · commit f06a166
-rw-r--r--languages.toml14
-rw-r--r--runtime/queries/move/highlights.scm157
2 files changed, 171 insertions, 0 deletions
diff --git a/languages.toml b/languages.toml
index 5ac2b2fe..bc23f708 100644
--- a/languages.toml
+++ b/languages.toml
@@ -3544,3 +3544,17 @@ comment-token = ";"
[[grammar]]
name = "xtc"
source = { git = "https://github.com/Alexis-Lapierre/tree-sitter-xtc", rev = "7bc11b736250c45e25cfb0215db2f8393779957e" }
+
+[[language]]
+name = "move"
+scope = "source.move"
+injection-regex = "move"
+roots = ["Move.toml"]
+file-types = ["move"]
+comment-token = "//"
+indent = { tab-width = 4, unit = " " }
+language-servers = []
+
+[[grammar]]
+name = "move"
+source = { git = "https://github.com/tzakian/tree-sitter-move", rev = "8bc0d1692caa8763fef54d48068238d9bf3c0264" }
diff --git a/runtime/queries/move/highlights.scm b/runtime/queries/move/highlights.scm
new file mode 100644
index 00000000..86a79dc2
--- /dev/null
+++ b/runtime/queries/move/highlights.scm
@@ -0,0 +1,157 @@
+(ability) @keyword
+
+; ---
+; Primitives
+; ---
+
+(address_literal) @constant
+(bool_literal) @constant.builtin.boolean
+(num_literal) @constant.numeric
+[
+ (hex_string_literal)
+ (byte_string_literal)
+] @string
+; TODO: vector_literal
+
+[
+ (line_comment)
+ (block_comment)
+] @comment
+
+(annotation) @function.macro
+
+(borrow_expression "&" @keyword.storage.modifier.ref)
+(borrow_expression "&mut" @keyword.storage.modifier.mut)
+
+(constant_identifier) @constant
+((identifier) @constant
+ (#match? @constant "^[A-Z][A-Z\\d_]*$"))
+
+(function_identifier) @function
+
+(struct_identifier) @type
+(pack_expression
+ access: (module_access
+ member: (identifier) @type))
+(apply_type
+ (module_access
+ member: (identifier) @type))
+(field_identifier) @variable.other.member
+
+; -------
+; Functions
+; -------
+
+(call_expression
+ access: (module_access
+ member: (identifier) @function))
+
+(macro_call_expression
+ access: (macro_module_access
+ access: (module_access
+ member: [(identifier) @function.macro])
+ "!" @function.macro))
+
+; -------
+; Paths
+; -------
+
+(module_identifier) @namespace
+
+; -------
+; Operators
+; -------
+
+[
+ "*"
+ "="
+ "!"
+] @operator
+(binary_operator) @operator
+
+; ---
+; Punctuation
+; ---
+
+[
+ "::"
+ "."
+ ";"
+ ","
+] @punctuation.delimiter
+
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
+
+[
+ "abort"
+ ; "acquires"
+ "as"
+ "break"
+ "const"
+ "continue"
+ "copy"
+ "else"
+ "false"
+ "friend"
+ "fun"
+ "has"
+ "if"
+ ; "invariant"
+ "let"
+ "loop"
+ "module"
+ "move"
+ "native"
+ "public"
+ "return"
+ ; "script"
+ "spec"
+ "struct"
+ "true"
+ "use"
+ "while"
+
+ "entry"
+
+ ; "aborts_if"
+ ; "aborts_with"
+ "address"
+ "apply"
+ "assume"
+ ; "axiom"
+ ; "choose"
+ "decreases"
+ ; "emits"
+ "ensures"
+ "except"
+ ; "forall"
+ "global"
+ "include"
+ "internal"
+ "local"
+ ; "min"
+ ; "modifies"
+ "mut"
+ "phantom"
+ "post"
+ "pragma"
+ ; "requires"
+ ; "Self"
+ "schema"
+ "succeeds_if"
+ "to"
+ ; "update"
+ "where"
+ "with"
+] @keyword
+
+(primitive_type) @type.buildin
+
+(identifier) @variable