blob: 92ffbbc1ed36b531abe8e66c95c46ff27bf4212b [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: Matlab
Bram Moolenaar9db9d9c2010-01-16 14:29:14 +01003" Maintainer: Maurizio Tranchero - maurizio(.)tranchero(@)gmail(.)com
Bram Moolenaar5c736222010-01-06 20:54:52 +01004" Credits: Preben 'Peppe' Guldberg <peppe-vim@wielders.org>
Bram Moolenaar071d4272004-06-13 20:20:40 +00005" Original author: Mario Eusebio
Bram Moolenaar9db9d9c2010-01-16 14:29:14 +01006" Last Change: Wed Jan 13 11:12:34 CET 2010
Bram Moolenaar251e1912011-06-19 05:09:16 +02007" sinh added to matlab implicit commands
8" Change History:
Bram Moolenaar9db9d9c2010-01-16 14:29:14 +01009" - 'global' and 'persistent' keyword are now recognized
Bram Moolenaar071d4272004-06-13 20:20:40 +000010
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020011" quit when a syntax file was already loaded
12if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000013 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
Bram Moolenaar5c736222010-01-06 20:54:52 +010020" MT_ADDON - added exception-specific keywords
21syn keyword matlabExceptions try catch
22syn keyword matlabOO classdef properties events methods
Bram Moolenaar071d4272004-06-13 20:20:40 +000023
24syn keyword matlabTodo contained TODO
Bram Moolenaar9db9d9c2010-01-16 14:29:14 +010025syn keyword matlabScope global persistent
Bram Moolenaar071d4272004-06-13 20:20:40 +000026
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
Bram Moolenaar5c736222010-01-06 20:54:52 +010039" MT_ADDON - added 'skip' in order to deal with 'tic' escaping sequence
Bram Moolenaar9db9d9c2010-01-16 14:29:14 +010040syn region matlabString start=+'+ end=+'+ oneline skip=+''+
Bram Moolenaar071d4272004-06-13 20:20:40 +000041
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
Bram Moolenaar9db9d9c2010-01-16 14:29:14 +010059syn match matlabComment "%.*$" contains=matlabTodo,matlabTab
Bram Moolenaar5c736222010-01-06 20:54:52 +010060" MT_ADDON - correctly highlights words after '...' as comments
Bram Moolenaar9db9d9c2010-01-16 14:29:14 +010061syn match matlabComment "\.\.\..*$" contains=matlabTodo,matlabTab
62syn region matlabMultilineComment start=+%{+ end=+%}+ contains=matlabTodo,matlabTab
Bram Moolenaar071d4272004-06-13 20:20:40 +000063
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
Bram Moolenaar251e1912011-06-19 05:09:16 +020070syn keyword matlabImplicit log10 max min sign sin sinh sqrt tan reshape
Bram Moolenaar071d4272004-06-13 20:20:40 +000071
72syn match matlabError "-\=\<\d\+\.\d\+\.[^*/\\^]"
73syn match matlabError "-\=\<\d\+\.\d\+[eEdD][-+]\=\d\+\.\([^*/\\^]\)"
74
75" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020076" Only when an item doesn't have highlighting yet
Bram Moolenaar071d4272004-06-13 20:20:40 +000077
Bram Moolenaarf37506f2016-08-31 22:22:10 +020078hi def link matlabTransposeOperator matlabOperator
79hi def link matlabOperator Operator
80hi def link matlabLineContinuation Special
81hi def link matlabLabel Label
82hi def link matlabConditional Conditional
83hi def link matlabExceptions Conditional
84hi def link matlabRepeat Repeat
85hi def link matlabTodo Todo
86hi def link matlabString String
87hi def link matlabDelimiter Identifier
88hi def link matlabTransposeOther Identifier
89hi def link matlabNumber Number
90hi def link matlabFloat Float
91hi def link matlabFunction Function
92hi def link matlabError Error
93hi def link matlabImplicit matlabStatement
94hi def link matlabStatement Statement
95hi def link matlabOO Statement
96hi def link matlabSemicolon SpecialChar
97hi def link matlabComment Comment
98hi def link matlabMultilineComment Comment
99hi def link matlabScope Type
Bram Moolenaar071d4272004-06-13 20:20:40 +0000100
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200101hi def link matlabArithmeticOperator matlabOperator
102hi def link matlabRelationalOperator matlabOperator
103hi def link matlabLogicalOperator matlabOperator
Bram Moolenaar071d4272004-06-13 20:20:40 +0000104
105"optional highlighting
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200106"hi def link matlabIdentifier Identifier
107"hi def link matlabTab Error
Bram Moolenaar071d4272004-06-13 20:20:40 +0000108
Bram Moolenaar071d4272004-06-13 20:20:40 +0000109
110let b:current_syntax = "matlab"
111
112"EOF vim: ts=8 noet tw=100 sw=8 sts=0