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