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