Add support for MATLAB/Octave files (#5192)

This commit is contained in:
g-s-k 2022-12-17 20:44:08 +01:00 committed by GitHub
parent aecb524e50
commit 042d03269e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 111 additions and 0 deletions

View File

@ -78,6 +78,7 @@
| make | ✓ | | | | | make | ✓ | | | |
| markdown | ✓ | | | `marksman` | | markdown | ✓ | | | `marksman` |
| markdown.inline | ✓ | | | | | markdown.inline | ✓ | | | |
| matlab | ✓ | | | |
| mermaid | ✓ | | | | | mermaid | ✓ | | | |
| meson | ✓ | | ✓ | | | meson | ✓ | | ✓ | |
| mint | | | | `mint` | | mint | | | | `mint` |

View File

@ -2068,3 +2068,16 @@ indent = { tab-width = 4, unit = " " }
[[grammar]] [[grammar]]
name = "mermaid" name = "mermaid"
source = { git = "https://github.com/monaqa/tree-sitter-mermaid", rev = "d787c66276e7e95899230539f556e8b83ee16f6d" } source = { git = "https://github.com/monaqa/tree-sitter-mermaid", rev = "d787c66276e7e95899230539f556e8b83ee16f6d" }
[[language]]
name = "matlab"
scope = "source.m"
file-types = ["m"]
comment-token = "%"
shebangs = ["octave-cli", "matlab"]
roots = []
indent = { tab-width = 2, unit = " " }
[[grammar]]
name = "matlab"
source = { git = "https://github.com/mstanciu552/tree-sitter-matlab", rev = "2d5d3d5193718a86477d4335aba5b34e79147326" }

View File

@ -0,0 +1,97 @@
; highlights.scm
function_keyword: (function_keyword) @keyword.function
(function_definition
function_name: (identifier) @function
(end) @function)
(parameter_list (identifier) @variable.parameter)
[
"if"
"elseif"
"else"
"switch"
"case"
"otherwise"
] @keyword.control.conditional
(if_statement (end) @keyword.control.conditional)
(switch_statement (end) @keyword.control.conditional)
["for" "while"] @keyword.control.repeat
(for_statement (end) @keyword.control.repeat)
(while_statement (end) @keyword.control.repeat)
["try" "catch"] @keyword.control.exception
(try_statement (end) @keyword.control.exception)
(function_definition end: (end) @keyword)
["return" "break" "continue"] @keyword.return
(
(identifier) @constant.builtin
(#any-of? @constant.builtin "true" "false")
)
(
(identifier) @constant.builtin
(#eq? @constant.builtin "end")
)
;; Punctuations
[";" ","] @punctuation.special
(argument_list "," @punctuation.delimiter)
(vector_definition ["," ";"] @punctuation.delimiter)
(cell_definition ["," ";"] @punctuation.delimiter)
":" @punctuation.delimiter
(parameter_list "," @punctuation.delimiter)
(return_value "," @punctuation.delimiter)
; ;; Brackets
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
;; Operators
"=" @operator
(operation [ ">"
"<"
"=="
"<="
">="
"=<"
"=>"
"~="
"*"
".*"
"/"
"\\"
"./"
"^"
".^"
"+"] @operator)
;; boolean operator
[
"&&"
"||"
] @operator
;; Number
(number) @constant.numeric
;; String
(string) @string
;; Comment
(comment) @comment