on master help sign in
Add support for MATLAB/Octave files (#5192)
042d032g-s-k
book/src/generated/lang-support.md+1
@@ -78,6 +78,7 @@
78| make | ✓ | | | |
78| make | ✓ | | | |
79| markdown | ✓ | | | `marksman` |
79| markdown | ✓ | | | `marksman` |
80| markdown.inline | ✓ | | | |
80| markdown.inline | ✓ | | | |
81+| matlab | ✓ | | | |
81| mermaid | ✓ | | | |
82| mermaid | ✓ | | | |
82| meson | ✓ | | ✓ | |
83| meson | ✓ | | ✓ | |
83| mint | | | | `mint` |
84| mint | | | | `mint` |
languages.toml+13
@@ -2068,3 +2068,16 @@ indent = { tab-width = 4, unit = " " }
2068[[grammar]]
2068[[grammar]]
2069name = "mermaid"
2069name = "mermaid"
2070source = { git = "https://github.com/monaqa/tree-sitter-mermaid", rev = "d787c66276e7e95899230539f556e8b83ee16f6d" }
2070source = { git = "https://github.com/monaqa/tree-sitter-mermaid", rev = "d787c66276e7e95899230539f556e8b83ee16f6d" }
2071+
2072+[[language]]
2073+name = "matlab"
2074+scope = "source.m"
2075+file-types = ["m"]
2076+comment-token = "%"
2077+shebangs = ["octave-cli", "matlab"]
2078+roots = []
2079+indent = { tab-width = 2, unit = " " }
2080+
2081+[[grammar]]
2082+name = "matlab"
2083+source = { git = "https://github.com/mstanciu552/tree-sitter-matlab", rev = "2d5d3d5193718a86477d4335aba5b34e79147326" }
runtime/queries/matlab/highlights.scmnew file+97
@@ -0,0 +1,97 @@
1+ ; highlights.scm
2+
3+function_keyword: (function_keyword) @keyword.function
4+
5+(function_definition
6+function_name: (identifier) @function
7+(end) @function)
8+
9+(parameter_list (identifier) @variable.parameter)
10+
11+[
12+ "if"
13+ "elseif"
14+ "else"
15+ "switch"
16+ "case"
17+ "otherwise"
18+] @keyword.control.conditional
19+
20+(if_statement (end) @keyword.control.conditional)
21+(switch_statement (end) @keyword.control.conditional)
22+
23+["for" "while"] @keyword.control.repeat
24+(for_statement (end) @keyword.control.repeat)
25+(while_statement (end) @keyword.control.repeat)
26+
27+["try" "catch"] @keyword.control.exception
28+(try_statement (end) @keyword.control.exception)
29+
30+(function_definition end: (end) @keyword)
31+
32+["return" "break" "continue"] @keyword.return
33+
34+(
35+(identifier) @constant.builtin
36+(#any-of? @constant.builtin "true" "false")
37+)
38+
39+(
40+ (identifier) @constant.builtin
41+ (#eq? @constant.builtin "end")
42+)
43+
44+;; Punctuations
45+
46+[";" ","] @punctuation.special
47+(argument_list "," @punctuation.delimiter)
48+(vector_definition ["," ";"] @punctuation.delimiter)
49+(cell_definition ["," ";"] @punctuation.delimiter)
50+":" @punctuation.delimiter
51+(parameter_list "," @punctuation.delimiter)
52+(return_value "," @punctuation.delimiter)
53+
54+; ;; Brackets
55+
56+[
57+ "("
58+ ")"
59+ "["
60+ "]"
61+ "{"
62+ "}"
63+] @punctuation.bracket
64+
65+;; Operators
66+"=" @operator
67+(operation [ ">"
68+ "<"
69+ "=="
70+ "<="
71+ ">="
72+ "=<"
73+ "=>"
74+ "~="
75+ "*"
76+ ".*"
77+ "/"
78+ "\\"
79+ "./"
80+ "^"
81+ ".^"
82+ "+"] @operator)
83+
84+;; boolean operator
85+[
86+ "&&"
87+ "||"
88+] @operator
89+
90+;; Number
91+(number) @constant.numeric
92+
93+;; String
94+(string) @string
95+
96+;; Comment
97+(comment) @comment