Updated to latest grammars
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
# will have compiled files and executables
|
# will have compiled files and executables
|
||||||
debug
|
debug
|
||||||
target
|
target
|
||||||
|
grammars
|
||||||
|
|
||||||
# These are backup files generated by rustfmt
|
# These are backup files generated by rustfmt
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
id = "Marte"
|
id = "Marte"
|
||||||
name = "MARTe"
|
name = "MARTe"
|
||||||
version = "0.0.6"
|
version = "0.0.7"
|
||||||
schema_version = 1
|
schema_version = 1
|
||||||
description = "MARTe language support for Zed"
|
description = "MARTe language support for Zed"
|
||||||
themes = []
|
themes = []
|
||||||
@@ -11,8 +11,8 @@ kind = "Rust"
|
|||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
|
||||||
[grammars.marte]
|
[grammars.marte]
|
||||||
repository = "https://github.com/MARTe-Community/tree-sitter-marte"
|
repository = "https://github.com/Mandarancio/tree-sitter-marte"
|
||||||
rev = "1edbdc955fe6c0cf5bccd33368f0eb03a62d2682"
|
rev = "f092e34c05412013534f98f0aa93a09b8ebe4d04"
|
||||||
|
|
||||||
[language_servers.mdt]
|
[language_servers.mdt]
|
||||||
name = "mdt"
|
name = "mdt"
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,10 @@
|
|||||||
|
; ── Fold directive blocks ──────────────────────────────────────────
|
||||||
|
(if_block) @fold
|
||||||
|
(else_if_clause) @fold
|
||||||
|
(else_clause) @fold
|
||||||
|
(foreach_block) @fold
|
||||||
|
(template_definition) @fold
|
||||||
|
|
||||||
|
; ── Fold subnodes and array literals ───────────────────────────────
|
||||||
|
(subnode) @fold
|
||||||
|
(array_literal) @fold
|
||||||
+117
-16
@@ -1,17 +1,118 @@
|
|||||||
(property) @property
|
; ── Keywords / Directives ──────────────────────────────────────────────
|
||||||
(attribute) @attribute
|
"package" @keyword
|
||||||
(marte_common) @keyword
|
"var" @keyword
|
||||||
(app) @function
|
"let" @keyword
|
||||||
(string_literal) @string
|
"if" @keyword.conditional
|
||||||
(definition) @constructor
|
"else" @keyword.conditional
|
||||||
(builtintype) @type.builtin
|
"end" @keyword
|
||||||
(number) @number
|
"foreach" @keyword.repeat
|
||||||
(comment) @comment
|
"in" @keyword
|
||||||
(assign) @operator
|
"template" @keyword
|
||||||
(obrace) @punctuation.bracket
|
"use" @keyword
|
||||||
(cbrace) @punctuation.bracket
|
"as" @keyword
|
||||||
(opar) @punctuation.bracket
|
|
||||||
(cpar) @punctuation.bracket
|
|
||||||
(vbar) @operator
|
|
||||||
(comma) @punctuation.delimiter
|
|
||||||
|
|
||||||
|
; ── Boolean ─────────────────────────────────────────────────────────────
|
||||||
|
"true" @boolean
|
||||||
|
"false" @boolean
|
||||||
|
|
||||||
|
; ── Types ───────────────────────────────────────────────────────────────
|
||||||
|
(builtin_type) @type.builtin
|
||||||
|
(type_bound) @type
|
||||||
|
|
||||||
|
; ── Strings ─────────────────────────────────────────────────────────────
|
||||||
|
(string_literal) @string
|
||||||
|
|
||||||
|
; ── Numbers ─────────────────────────────────────────────────────────────
|
||||||
|
(number) @number
|
||||||
|
|
||||||
|
; ── Default identifier capture (overridden by specific rules below) ─────
|
||||||
|
(identifier) @variable
|
||||||
|
|
||||||
|
; ── Variables ───────────────────────────────────────────────────────────
|
||||||
|
(variable_reference) @variable
|
||||||
|
|
||||||
|
; ── Comments ────────────────────────────────────────────────────────────
|
||||||
|
(comment) @comment
|
||||||
|
(docstring) @comment.documentation
|
||||||
|
(pragma) @comment.note
|
||||||
|
|
||||||
|
; ── Operators ───────────────────────────────────────────────────────────
|
||||||
|
"=" @operator
|
||||||
|
"+" @operator
|
||||||
|
"-" @operator
|
||||||
|
"*" @operator
|
||||||
|
"/" @operator
|
||||||
|
"%" @operator
|
||||||
|
"^" @operator
|
||||||
|
"&" @operator
|
||||||
|
"|" @operator
|
||||||
|
"||" @operator
|
||||||
|
"&&" @operator
|
||||||
|
".." @operator
|
||||||
|
"==" @operator
|
||||||
|
"!=" @operator
|
||||||
|
"<" @operator
|
||||||
|
">" @operator
|
||||||
|
"<=" @operator
|
||||||
|
">=" @operator
|
||||||
|
"!" @operator
|
||||||
|
|
||||||
|
; ── Objects ─────────────────────────────────────────────────────────────
|
||||||
|
(object_definition
|
||||||
|
name: (identifier) @constructor)
|
||||||
|
(object_definition
|
||||||
|
prefix: "$" @constructor)
|
||||||
|
(object_definition
|
||||||
|
prefix: "+" @constructor)
|
||||||
|
|
||||||
|
; ── Punctuation ─────────────────────────────────────────────────────────
|
||||||
|
":" @punctuation.delimiter
|
||||||
|
"::" @punctuation.delimiter
|
||||||
|
"," @punctuation.delimiter
|
||||||
|
"." @punctuation.delimiter
|
||||||
|
"{" @punctuation.bracket
|
||||||
|
"}" @punctuation.bracket
|
||||||
|
"(" @punctuation.bracket
|
||||||
|
")" @punctuation.bracket
|
||||||
|
"[" @punctuation.bracket
|
||||||
|
"]" @punctuation.bracket
|
||||||
|
|
||||||
|
; ── Templates ───────────────────────────────────────────────────────────
|
||||||
|
(template_definition
|
||||||
|
name: (identifier) @function)
|
||||||
|
(template_use
|
||||||
|
template: (identifier) @function)
|
||||||
|
(template_use
|
||||||
|
instance: (identifier) @variable)
|
||||||
|
|
||||||
|
; ── Signal Shorthand ────────────────────────────────────────────────────
|
||||||
|
(signal_shorthand
|
||||||
|
datasource: (identifier) @namespace)
|
||||||
|
(signal_shorthand
|
||||||
|
signal: (identifier) @variable)
|
||||||
|
|
||||||
|
; ── Variables / Constants ───────────────────────────────────────────────
|
||||||
|
(var_declaration
|
||||||
|
name: (identifier) @variable)
|
||||||
|
(let_declaration
|
||||||
|
name: (identifier) @constant)
|
||||||
|
|
||||||
|
; ── Package ─────────────────────────────────────────────────────────────
|
||||||
|
(package_declaration
|
||||||
|
uri: (package_uri) @namespace)
|
||||||
|
|
||||||
|
; ── Fields ──────────────────────────────────────────────────────────────
|
||||||
|
(field
|
||||||
|
name: (identifier) @property)
|
||||||
|
|
||||||
|
; ── Parameters / Arguments ──────────────────────────────────────────────
|
||||||
|
(parameter
|
||||||
|
name: (identifier) @variable.parameter)
|
||||||
|
(argument
|
||||||
|
name: (identifier) @variable.parameter)
|
||||||
|
|
||||||
|
; ── Type Expressions ────────────────────────────────────────────────────
|
||||||
|
(type_expression
|
||||||
|
(identifier) @type)
|
||||||
|
|
||||||
|
(dynamic_object) @constructor
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
; ── Indent after opening braces ─────────────────────────────────────
|
||||||
|
(subnode "{" @indent) @branch
|
||||||
|
(array_literal "{" @indent) @branch
|
||||||
|
|
||||||
|
; ── Dedent on closing braces ───────────────────────────────────────
|
||||||
|
"}" @dedent
|
||||||
|
|
||||||
|
; ── Indent block bodies (if, foreach, template) ────────────────────
|
||||||
|
(if_block
|
||||||
|
"if" @branch
|
||||||
|
(_) @indent) @branch
|
||||||
|
|
||||||
|
(else_if_clause
|
||||||
|
"if" @branch
|
||||||
|
(_) @indent) @branch
|
||||||
|
|
||||||
|
(else_clause
|
||||||
|
"else" @branch
|
||||||
|
(_) @indent) @branch
|
||||||
|
|
||||||
|
(foreach_block
|
||||||
|
"foreach" @branch
|
||||||
|
(_) @indent) @branch
|
||||||
|
|
||||||
|
(template_definition
|
||||||
|
"template" @branch
|
||||||
|
(_) @indent) @branch
|
||||||
|
|
||||||
|
; ── Dedent on end keywords ─────────────────────────────────────────
|
||||||
|
"end" @dedent
|
||||||
|
|
||||||
|
; ── Dedent on else/else if (close previous block, open new) ────────
|
||||||
|
"else" @dedent
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
; ── Variable declarations: define the name as a local ──────────────
|
||||||
|
(var_declaration
|
||||||
|
name: (identifier) @local.definition)
|
||||||
|
|
||||||
|
; ── Constant declarations ──────────────────────────────────────────
|
||||||
|
(let_declaration
|
||||||
|
name: (identifier) @local.definition)
|
||||||
|
|
||||||
|
; ── Foreach loop variable ──────────────────────────────────────────
|
||||||
|
(foreach_block
|
||||||
|
value: (identifier) @local.definition)
|
||||||
|
|
||||||
|
; ── Foreach key variable (when present) ────────────────────────────
|
||||||
|
(foreach_block
|
||||||
|
key: (identifier) @local.definition)
|
||||||
|
|
||||||
|
; ── Template parameters ────────────────────────────────────────────
|
||||||
|
(parameter
|
||||||
|
name: (identifier) @local.definition)
|
||||||
|
|
||||||
|
; ── Variable references: point back to definitions ─────────────────
|
||||||
|
(variable_reference
|
||||||
|
(identifier) @local.reference)
|
||||||
|
|
||||||
|
; ── Scope blocks for locals ────────────────────────────────────────
|
||||||
|
; (file-level variables are global; foreach/template create scopes)
|
||||||
|
(foreach_block) @local.scope
|
||||||
|
(template_definition) @local.scope
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
; ── Object definitions (prefixed with + or $) ──────────────────────
|
||||||
|
(object_definition
|
||||||
|
prefix: "+"
|
||||||
|
name: (identifier) @name) @definition.class
|
||||||
|
|
||||||
|
(object_definition
|
||||||
|
prefix: "$"
|
||||||
|
name: (identifier) @name) @definition.interface
|
||||||
|
|
||||||
|
; ── Signal shorthand entries ───────────────────────────────────────
|
||||||
|
(signal_shorthand
|
||||||
|
signal: (identifier) @name) @definition.field
|
||||||
|
|
||||||
|
; ── Top-level fields (configuration values) ────────────────────────
|
||||||
|
(source_file
|
||||||
|
(definition
|
||||||
|
(field
|
||||||
|
name: (identifier) @name))) @definition.property
|
||||||
|
|
||||||
|
; ── Variable declarations ──────────────────────────────────────────
|
||||||
|
(var_declaration
|
||||||
|
name: (identifier) @name) @definition.variable
|
||||||
|
|
||||||
|
; ── Constants ──────────────────────────────────────────────────────
|
||||||
|
(let_declaration
|
||||||
|
name: (identifier) @name) @definition.constant
|
||||||
|
|
||||||
|
; ── Template definitions ───────────────────────────────────────────
|
||||||
|
(template_definition
|
||||||
|
name: (identifier) @name) @definition.function
|
||||||
|
|
||||||
|
; ── Template instantiations ────────────────────────────────────────
|
||||||
|
(template_use
|
||||||
|
instance: (identifier) @name) @definition.variable
|
||||||
|
|
||||||
|
; ── Package declaration ────────────────────────────────────────────
|
||||||
|
(package_declaration
|
||||||
|
uri: (package_uri) @name) @definition.module
|
||||||
|
|
||||||
|
; ── Docstrings attach to next definition ───────────────────────────
|
||||||
|
(docstring) @documentation
|
||||||
Reference in New Issue
Block a user