xref: /vim-8.2.3635/runtime/syntax/matlab.vim (revision 12ee7ff0)
1" Vim syntax file
2" Language:	Matlab
3" Maintainer:	Alex Burka <[email protected]>
4" Credits:	Preben 'Peppe' Guldberg <[email protected]>
5"		Maurizio Tranchero - maurizio(.)tranchero(@)gmail(.)com
6"		Original author: Mario Eusebio
7" Last Change:	June 10 2019
8" 		added highlight rule for double-quoted string literals
9" Change History:
10"               - double-quoted string literals added
11" 		- now highlights cell-mode separator comments
12" 		- 'global' and 'persistent' keyword are now recognized
13
14" quit when a syntax file was already loaded
15if exists("b:current_syntax")
16  finish
17endif
18
19syn keyword matlabStatement		return
20syn keyword matlabLabel			case switch
21syn keyword matlabConditional		else elseif end if otherwise
22syn keyword matlabRepeat		do for while
23" MT_ADDON - added exception-specific keywords
24syn keyword matlabExceptions		try catch
25syn keyword matlabOO			classdef properties events methods
26
27syn keyword matlabTodo			contained  TODO
28syn keyword matlabScope			global persistent
29
30" If you do not want these operators lit, uncommment them and the "hi link" below
31syn match matlabArithmeticOperator	"[-+]"
32syn match matlabArithmeticOperator	"\.\=[*/\\^]"
33syn match matlabRelationalOperator	"[=~]="
34syn match matlabRelationalOperator	"[<>]=\="
35syn match matlabLogicalOperator		"[&|~]"
36
37syn match matlabLineContinuation	"\.\{3}"
38
39"syn match matlabIdentifier		"\<\a\w*\>"
40
41" String
42" MT_ADDON - added 'skip' in order to deal with 'tic' escaping sequence
43syn region matlabString			start=+'+ end=+'+	oneline skip=+''+
44syn region matlabStringArray		start=+"+ end=+"+	oneline skip=+""+
45
46" If you don't like tabs
47syn match matlabTab			"\t"
48
49" Standard numbers
50syn match matlabNumber		"\<\d\+[ij]\=\>"
51" floating point number, with dot, optional exponent
52syn match matlabFloat		"\<\d\+\(\.\d*\)\=\([edED][-+]\=\d\+\)\=[ij]\=\>"
53" floating point number, starting with a dot, optional exponent
54syn match matlabFloat		"\.\d\+\([edED][-+]\=\d\+\)\=[ij]\=\>"
55
56" Transpose character and delimiters: Either use just [...] or (...) aswell
57syn match matlabDelimiter		"[][]"
58"syn match matlabDelimiter		"[][()]"
59syn match matlabTransposeOperator	"[])a-zA-Z0-9.]'"lc=1
60
61syn match matlabSemicolon		";"
62
63syn match matlabComment			"%.*$"	contains=matlabTodo,matlabTab
64" MT_ADDON - correctly highlights words after '...' as comments
65syn match matlabComment			"\.\.\..*$"	contains=matlabTodo,matlabTab
66syn region matlabMultilineComment	start=+%{+ end=+%}+ contains=matlabTodo,matlabTab
67syn match matlabCellComment     "^%%.*$"
68
69syn keyword matlabOperator		break zeros default margin round ones rand
70syn keyword matlabOperator		ceil floor size clear zeros eye mean std cov
71
72syn keyword matlabFunction		error eval function
73
74syn keyword matlabImplicit		abs acos atan asin cos cosh exp log prod sum
75syn keyword matlabImplicit		log10 max min sign sin sinh sqrt tan reshape
76
77syn match matlabError	"-\=\<\d\+\.\d\+\.[^*/\\^]"
78syn match matlabError	"-\=\<\d\+\.\d\+[eEdD][-+]\=\d\+\.\([^*/\\^]\)"
79
80" Define the default highlighting.
81" Only when an item doesn't have highlighting yet
82
83hi def link matlabTransposeOperator	matlabOperator
84hi def link matlabOperator			Operator
85hi def link matlabLineContinuation		Special
86hi def link matlabLabel			Label
87hi def link matlabConditional		Conditional
88hi def link matlabExceptions		Conditional
89hi def link matlabRepeat			Repeat
90hi def link matlabTodo			Todo
91hi def link matlabString			String
92hi def link matlabStringArray			String
93hi def link matlabDelimiter		Identifier
94hi def link matlabTransposeOther		Identifier
95hi def link matlabNumber			Number
96hi def link matlabFloat			Float
97hi def link matlabFunction			Function
98hi def link matlabError			Error
99hi def link matlabImplicit			matlabStatement
100hi def link matlabStatement		Statement
101hi def link matlabOO			Statement
102hi def link matlabSemicolon		SpecialChar
103hi def link matlabComment			Comment
104hi def link matlabMultilineComment		Comment
105hi def link matlabCellComment          Todo
106hi def link matlabScope			Type
107
108hi def link matlabArithmeticOperator	matlabOperator
109hi def link matlabRelationalOperator	matlabOperator
110hi def link matlabLogicalOperator		matlabOperator
111
112"optional highlighting
113"hi def link matlabIdentifier		Identifier
114"hi def link matlabTab			Error
115
116
117let b:current_syntax = "matlab"
118
119"EOF	vim: ts=8 noet tw=100 sw=8 sts=0
120