blob: 0e281c114d08dba400f0389056a44557c864ef17 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: Matlab
Bram Moolenaar5c736222010-01-06 20:54:52 +01003" Maintainer: Maurizio Tranchero - maurizio.tranchero@gmail.com
4" Credits: Preben 'Peppe' Guldberg <peppe-vim@wielders.org>
Bram Moolenaar071d4272004-06-13 20:20:40 +00005" Original author: Mario Eusebio
Bram Moolenaar5c736222010-01-06 20:54:52 +01006" Change History:
7" Sat Jul 25 16:14:55 CEST 2009
8" - spell check enabled only for comments (thanks to James Vega)
9"
10" Tue Apr 21 10:03:31 CEST 2009
11" - added object oriented support
12" - added multi-line comments %{ ...\n... %}
Bram Moolenaar071d4272004-06-13 20:20:40 +000013
14" For version 5.x: Clear all syntax items
15" For version 6.x: Quit when a syntax file was already loaded
16if version < 600
17 syntax clear
18elseif exists("b:current_syntax")
19 finish
20endif
21
22syn keyword matlabStatement return
23syn keyword matlabLabel case switch
24syn keyword matlabConditional else elseif end if otherwise
25syn keyword matlabRepeat do for while
Bram Moolenaar5c736222010-01-06 20:54:52 +010026" MT_ADDON - added exception-specific keywords
27syn keyword matlabExceptions try catch
28syn keyword matlabOO classdef properties events methods
Bram Moolenaar071d4272004-06-13 20:20:40 +000029
30syn keyword matlabTodo contained TODO
31
32" If you do not want these operators lit, uncommment them and the "hi link" below
33syn match matlabArithmeticOperator "[-+]"
34syn match matlabArithmeticOperator "\.\=[*/\\^]"
35syn match matlabRelationalOperator "[=~]="
36syn match matlabRelationalOperator "[<>]=\="
37syn match matlabLogicalOperator "[&|~]"
38
39syn match matlabLineContinuation "\.\{3}"
40
41"syn match matlabIdentifier "\<\a\w*\>"
42
43" String
Bram Moolenaar5c736222010-01-06 20:54:52 +010044" MT_ADDON - added 'skip' in order to deal with 'tic' escaping sequence
45syn region matlabString start=+'+ end=+'+ oneline skip=+''+ contains=@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +000046
47" If you don't like tabs
48syn match matlabTab "\t"
49
50" Standard numbers
51syn match matlabNumber "\<\d\+[ij]\=\>"
52" floating point number, with dot, optional exponent
53syn match matlabFloat "\<\d\+\(\.\d*\)\=\([edED][-+]\=\d\+\)\=[ij]\=\>"
54" floating point number, starting with a dot, optional exponent
55syn match matlabFloat "\.\d\+\([edED][-+]\=\d\+\)\=[ij]\=\>"
56
57" Transpose character and delimiters: Either use just [...] or (...) aswell
58syn match matlabDelimiter "[][]"
59"syn match matlabDelimiter "[][()]"
60syn match matlabTransposeOperator "[])a-zA-Z0-9.]'"lc=1
61
62syn match matlabSemicolon ";"
63
Bram Moolenaar5c736222010-01-06 20:54:52 +010064syn match matlabComment "%.*$" contains=matlabTodo,matlabTab,@Spell
65" MT_ADDON - correctly highlights words after '...' as comments
66syn match matlabComment "\.\.\..*$" contains=matlabTodo,matlabTab,@Spell
67syn region matlabMultilineComment start=+%{+ end=+%}+ contains=matlabTodo,matlabTab,@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +000068
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 sqrt tan reshape
76
77syn match matlabError "-\=\<\d\+\.\d\+\.[^*/\\^]"
78syn match matlabError "-\=\<\d\+\.\d\+[eEdD][-+]\=\d\+\.\([^*/\\^]\)"
79
80" Define the default highlighting.
81" For version 5.7 and earlier: only when not done already
82" For version 5.8 and later: only when an item doesn't have highlighting yet
83if version >= 508 || !exists("did_matlab_syntax_inits")
84 if version < 508
85 let did_matlab_syntax_inits = 1
86 command -nargs=+ HiLink hi link <args>
87 else
88 command -nargs=+ HiLink hi def link <args>
89 endif
90
91 HiLink matlabTransposeOperator matlabOperator
Bram Moolenaar5c736222010-01-06 20:54:52 +010092 HiLink matlabOperator Operator
93 HiLink matlabLineContinuation Special
Bram Moolenaar071d4272004-06-13 20:20:40 +000094 HiLink matlabLabel Label
95 HiLink matlabConditional Conditional
Bram Moolenaar5c736222010-01-06 20:54:52 +010096 HiLink matlabExceptions Conditional
Bram Moolenaar071d4272004-06-13 20:20:40 +000097 HiLink matlabRepeat Repeat
98 HiLink matlabTodo Todo
99 HiLink matlabString String
100 HiLink matlabDelimiter Identifier
101 HiLink matlabTransposeOther Identifier
102 HiLink matlabNumber Number
103 HiLink matlabFloat Float
Bram Moolenaar5c736222010-01-06 20:54:52 +0100104 HiLink matlabFunction Function
Bram Moolenaar071d4272004-06-13 20:20:40 +0000105 HiLink matlabError Error
Bram Moolenaar5c736222010-01-06 20:54:52 +0100106 HiLink matlabImplicit matlabStatement
Bram Moolenaar071d4272004-06-13 20:20:40 +0000107 HiLink matlabStatement Statement
Bram Moolenaar5c736222010-01-06 20:54:52 +0100108 HiLink matlabOO Statement
Bram Moolenaar071d4272004-06-13 20:20:40 +0000109 HiLink matlabSemicolon SpecialChar
110 HiLink matlabComment Comment
Bram Moolenaar5c736222010-01-06 20:54:52 +0100111 HiLink matlabMultilineComment Comment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000112
113 HiLink matlabArithmeticOperator matlabOperator
114 HiLink matlabRelationalOperator matlabOperator
115 HiLink matlabLogicalOperator matlabOperator
116
117"optional highlighting
118 "HiLink matlabIdentifier Identifier
119 "HiLink matlabTab Error
120
121 delcommand HiLink
122endif
123
124let b:current_syntax = "matlab"
125
126"EOF vim: ts=8 noet tw=100 sw=8 sts=0