Skip to content

Commit

Permalink
Add Move language support
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Apr 18, 2024
1 parent 1d23796 commit f06a166
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 0 deletions.
14 changes: 14 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
157 changes: 157 additions & 0 deletions runtime/queries/move/highlights.scm
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f06a166

Please sign in to comment.