Mercurial > vim
comparison runtime/syntax/mma.vim @ 3312:b7811ab264bf v7.3.423
updated for version 7.3.423
Problem: Small mistakes in comments, proto and indent.
Solution: Fix the mistakes.
Also update runtime files
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sat, 04 Feb 2012 21:59:01 +0100 |
parents | 7bc41231fbc7 |
children | 43efa4f5a8ea |
comparison
equal
deleted
inserted
replaced
3311:54d1536a1c8b | 3312:b7811ab264bf |
---|---|
1 " Vim syntax file | 1 " Vim syntax file |
2 " Language: Mathematica | 2 " Language: Mathematica |
3 " Maintainer: steve layland <layland@wolfram.com> | 3 " Maintainer: steve layland <layland@wolfram.com> |
4 " Last Change: Thu May 19 21:36:04 CDT 2005 | 4 " Last Change: 2012 Feb 03 by Thilo Six |
5 " Source: http://members.wri.com/layland/vim/syntax/mma.vim | 5 " Source: http://members.wri.com/layland/vim/syntax/mma.vim |
6 " http://vim.sourceforge.net/scripts/script.php?script_id=1273 | 6 " http://vim.sourceforge.net/scripts/script.php?script_id=1273 |
7 " Id: $Id: mma.vim,v 1.4 2006/04/14 20:40:38 vimboss Exp $ | 7 " Id: $Id: mma.vim,v 1.4 2006/04/14 20:40:38 vimboss Exp $ |
8 " NOTE: | 8 " NOTE: |
9 " | 9 " |
10 " Empty .m files will automatically be presumed as Matlab files | 10 " Empty .m files will automatically be presumed as Matlab files |
11 " unless you have the following in your .vimrc: | 11 " unless you have the following in your .vimrc: |
12 " | 12 " |
13 " let filetype_m="mma" | 13 " let filetype_m="mma" |
14 " | 14 " |
15 " I also recommend setting the default 'Comment' hilighting to something | 15 " I also recommend setting the default 'Comment' hilighting to something |
16 " other than the color used for 'Function', since both are plentiful in | 16 " other than the color used for 'Function', since both are plentiful in |
17 " most mathematica files, and they are often the same color (when using | 17 " most mathematica files, and they are often the same color (when using |
18 " background=dark). | 18 " background=dark). |
19 " | 19 " |
20 " Credits: | 20 " Credits: |
21 " o Original Mathematica syntax version written by | 21 " o Original Mathematica syntax version written by |
22 " Wolfgang Waltenberger <wwalten@ben.tuwien.ac.at> | 22 " Wolfgang Waltenberger <wwalten@ben.tuwien.ac.at> |
23 " o Some ideas like the CommentStar,CommentTitle were adapted | 23 " o Some ideas like the CommentStar,CommentTitle were adapted |
24 " from the Java vim syntax file by Claudio Fleiner. Thanks! | 24 " from the Java vim syntax file by Claudio Fleiner. Thanks! |
25 " o Everything else written by steve <layland@wolfram.com> | 25 " o Everything else written by steve <layland@wolfram.com> |
26 " | 26 " |
27 " Bugs: | 27 " Bugs: |
28 " o Vim 6.1 didn't really have support for character classes | 28 " o Vim 6.1 didn't really have support for character classes |
29 " of other named character classes. For example, [\a\d] | 29 " of other named character classes. For example, [\a\d] |
30 " didn't work. Therefore, a lot of this code uses explicit | 30 " didn't work. Therefore, a lot of this code uses explicit |
31 " character classes instead: [0-9a-zA-Z] | 31 " character classes instead: [0-9a-zA-Z] |
32 " | 32 " |
33 " TODO: | 33 " TODO: |
34 " folding | 34 " folding |
35 " fix nesting | 35 " fix nesting |
36 " finish populating popular symbols | 36 " finish populating popular symbols |
38 if version < 600 | 38 if version < 600 |
39 syntax clear | 39 syntax clear |
40 elseif exists("b:current_syntax") | 40 elseif exists("b:current_syntax") |
41 finish | 41 finish |
42 endif | 42 endif |
43 | |
44 let s:cpo_save = &cpo | |
45 set cpo&vim | |
43 | 46 |
44 " Group Definitions: | 47 " Group Definitions: |
45 syntax cluster mmaNotes contains=mmaTodo,mmaFixme | 48 syntax cluster mmaNotes contains=mmaTodo,mmaFixme |
46 syntax cluster mmaComments contains=mmaComment,mmaFunctionComment,mmaItem,mmaFunctionTitle,mmaCommentStar | 49 syntax cluster mmaComments contains=mmaComment,mmaFunctionComment,mmaItem,mmaFunctionTitle,mmaCommentStar |
47 syntax cluster mmaCommentStrings contains=mmaLooseQuote,mmaCommentString,mmaUnicode | 50 syntax cluster mmaCommentStrings contains=mmaLooseQuote,mmaCommentString,mmaUnicode |
56 | 59 |
57 " standard fixed symbols: | 60 " standard fixed symbols: |
58 syntax keyword mmaVariable True False None Automatic All Null C General | 61 syntax keyword mmaVariable True False None Automatic All Null C General |
59 | 62 |
60 " mathematical constants: | 63 " mathematical constants: |
61 syntax keyword mmaVariable Pi I E Infinity ComplexInfinity Indeterminate GoldenRatio EulerGamma Degree Catalan Khinchin Glaisher | 64 syntax keyword mmaVariable Pi I E Infinity ComplexInfinity Indeterminate GoldenRatio EulerGamma Degree Catalan Khinchin Glaisher |
62 | 65 |
63 " stream data / atomic heads: | 66 " stream data / atomic heads: |
64 syntax keyword mmaVariable Byte Character Expression Number Real String Word EndOfFile Integer Symbol | 67 syntax keyword mmaVariable Byte Character Expression Number Real String Word EndOfFile Integer Symbol |
65 | 68 |
66 " sets: | 69 " sets: |
78 | 81 |
79 " colors: | 82 " colors: |
80 syntax keyword mmaVariable Black Blue Brown Cyan Gray Green Magenta Orange Pink Purple Red White Yellow | 83 syntax keyword mmaVariable Black Blue Brown Cyan Gray Green Magenta Orange Pink Purple Red White Yellow |
81 | 84 |
82 " function attributes | 85 " function attributes |
83 syntax keyword mmaVariable Protected Listable OneIdentity Orderless Flat Constant NumericFunction Locked ReadProtected HoldFirst HoldRest HoldAll HoldAllComplete SequenceHold NHoldFirst NHoldRest NHoldAll Temporary Stub | 86 syntax keyword mmaVariable Protected Listable OneIdentity Orderless Flat Constant NumericFunction Locked ReadProtected HoldFirst HoldRest HoldAll HoldAllComplete SequenceHold NHoldFirst NHoldRest NHoldAll Temporary Stub |
84 | 87 |
85 " Comment Sections: | 88 " Comment Sections: |
86 " this: | 89 " this: |
87 " :that: | 90 " :that: |
88 syntax match mmaItem "\%(^[( |*\t]*\)\@<=\%(:\+\|\w\)\w\+\%( \w\+\)\{0,3}:" contained contains=@mmaNotes | 91 syntax match mmaItem "\%(^[( |*\t]*\)\@<=\%(:\+\|\w\)\w\+\%( \w\+\)\{0,3}:" contained contains=@mmaNotes |
133 syntax region mmaCommentString oneline start=+\\\@<!"+ skip=+\\\@<!\\\%(\\\\\)*"+ end=+"+ contained | 136 syntax region mmaCommentString oneline start=+\\\@<!"+ skip=+\\\@<!\\\%(\\\\\)*"+ end=+"+ contained |
134 | 137 |
135 | 138 |
136 " Patterns: | 139 " Patterns: |
137 " Each pattern marker below can be Blank[] (_), BlankSequence[] (__) | 140 " Each pattern marker below can be Blank[] (_), BlankSequence[] (__) |
138 " or BlankNullSequence[] (___). Most examples below can also be | 141 " or BlankNullSequence[] (___). Most examples below can also be |
139 " combined, for example Pattern tests with Default values. | 142 " combined, for example Pattern tests with Default values. |
140 " | 143 " |
141 " _Head Anonymous patterns | 144 " _Head Anonymous patterns |
142 " name_Head | 145 " name_Head |
143 " name:(_Head|_Head2) Named patterns | 146 " name:(_Head|_Head2) Named patterns |
144 " | 147 " |
145 " _Head : val | 148 " _Head : val |
146 " name:_Head:val Default values | 149 " name:_Head:val Default values |
147 " | 150 " |
148 " _Head?testQ, | 151 " _Head?testQ, |
149 " _Head?(test[#]&) Pattern tests | 152 " _Head?(test[#]&) Pattern tests |
150 " | 153 " |
151 " name_Head/;test[name] Conditionals | 154 " name_Head/;test[name] Conditionals |
152 " | 155 " |
153 " _Head:. Predefined Default | 156 " _Head:. Predefined Default |
154 " | 157 " |
155 " .. ... Pattern Repeat | 158 " .. ... Pattern Repeat |
156 | 159 |
157 syntax match mmaPatternError "\%(_\{4,}\|)\s*&\s*)\@!\)" contained | 160 syntax match mmaPatternError "\%(_\{4,}\|)\s*&\s*)\@!\)" contained |
158 | 161 |
159 "pattern name: | 162 "pattern name: |
160 syntax match mmaPattern "[A-Za-z0-9`]\+\s*:\+[=>]\@!" contains=mmaOperator | 163 syntax match mmaPattern "[A-Za-z0-9`]\+\s*:\+[=>]\@!" contains=mmaOperator |
161 "pattern default: | 164 "pattern default: |
170 " == === || | 173 " == === || |
171 " != =!= && Logic | 174 " != =!= && Logic |
172 " >= <= < > | 175 " >= <= < > |
173 " += -= *= | 176 " += -= *= |
174 " /= ++ -- Math | 177 " /= ++ -- Math |
175 " ^* | 178 " ^* |
176 " -> :> Rules | 179 " -> :> Rules |
177 " @@ @@@ Apply | 180 " @@ @@@ Apply |
178 " /@ //@ Map | 181 " /@ //@ Map |
179 " /. //. Replace | 182 " /. //. Replace |
180 " // @ Function application | 183 " // @ Function application |
198 " Pure Functions: | 201 " Pure Functions: |
199 syntax match mmaPureFunction "#\%(#\|\d\+\)\=" | 202 syntax match mmaPureFunction "#\%(#\|\d\+\)\=" |
200 syntax match mmaPureFunction "&" | 203 syntax match mmaPureFunction "&" |
201 | 204 |
202 " Named Functions: | 205 " Named Functions: |
203 " Since everything is pretty much a function, get this straight | 206 " Since everything is pretty much a function, get this straight |
204 " from context | 207 " from context |
205 syntax match mmaGenericFunction "[A-Za-z0-9`]\+\s*\%([@[]\|/:\|/\=/@\)\@=" contains=mmaOperator | 208 syntax match mmaGenericFunction "[A-Za-z0-9`]\+\s*\%([@[]\|/:\|/\=/@\)\@=" contains=mmaOperator |
206 syntax match mmaGenericFunction "\~\s*[^~]\+\s*\~"hs=s+1,he=e-1 contains=mmaOperator,mmaBoring | 209 syntax match mmaGenericFunction "\~\s*[^~]\+\s*\~"hs=s+1,he=e-1 contains=mmaOperator,mmaBoring |
207 syntax match mmaGenericFunction "//\s*[A-Za-z0-9`]\+"hs=s+2 contains=mmaOperator | 210 syntax match mmaGenericFunction "//\s*[A-Za-z0-9`]\+"hs=s+2 contains=mmaOperator |
208 | 211 |
221 " Syntax Errors: | 224 " Syntax Errors: |
222 syntax match mmaError "\*)" containedin=ALLBUT,@mmaComments,@mmaStrings | 225 syntax match mmaError "\*)" containedin=ALLBUT,@mmaComments,@mmaStrings |
223 syntax match mmaError "\%([/]{3,}\|[&:|+*?~-]\{3,}\|[.=]\{4,}\|_\@<=\.\{2,}\|`\{2,}\)" containedin=ALLBUT,@mmaComments,@mmaStrings | 226 syntax match mmaError "\%([/]{3,}\|[&:|+*?~-]\{3,}\|[.=]\{4,}\|_\@<=\.\{2,}\|`\{2,}\)" containedin=ALLBUT,@mmaComments,@mmaStrings |
224 | 227 |
225 " Punctuation: | 228 " Punctuation: |
226 " things that shouldn't really be highlighted, or highlighted | 229 " things that shouldn't really be highlighted, or highlighted |
227 " in they're own group if you _really_ want. :) | 230 " in they're own group if you _really_ want. :) |
228 " ( ) { } | 231 " ( ) { } |
229 " TODO - use Delimiter group? | 232 " TODO - use Delimiter group? |
230 syntax match mmaBoring "[(){}]" contained | 233 syntax match mmaBoring "[(){}]" contained |
231 | 234 |
249 set commentstring='(*%s*)' | 252 set commentstring='(*%s*)' |
250 "set foldtext=MmaFoldText() | 253 "set foldtext=MmaFoldText() |
251 | 254 |
252 "function MmaFoldText() | 255 "function MmaFoldText() |
253 " let line = getline(v:foldstart) | 256 " let line = getline(v:foldstart) |
254 " | 257 " |
255 " let lines = v:foldend-v:foldstart+1 | 258 " let lines = v:foldend-v:foldstart+1 |
256 " | 259 " |
257 " let sub = substitute(line, '(\*\+|\*\+)|[-*_]\+', '', 'g') | 260 " let sub = substitute(line, '(\*\+|\*\+)|[-*_]\+', '', 'g') |
258 " | 261 " |
259 " if match(line, '(\*') != -1 | 262 " if match(line, '(\*') != -1 |
260 " let lines = lines.' line comment' | 263 " let lines = lines.' line comment' |
261 " else | 264 " else |
262 " let lines = lines.' lines' | 265 " let lines = lines.' lines' |
263 " endif | 266 " endif |
264 " | 267 " |
265 " return v:folddashes.' '.lines.' '.sub | 268 " return v:folddashes.' '.lines.' '.sub |
266 "endf | 269 "endf |
267 | 270 |
268 "this is slow for computing folds, but it does so accurately | 271 "this is slow for computing folds, but it does so accurately |
269 syntax sync fromstart | 272 syntax sync fromstart |
270 | 273 |
271 " but this seems to do alright for non fold syntax coloring. | 274 " but this seems to do alright for non fold syntax coloring. |
272 " for folding, however, it doesn't get the nesting right. | 275 " for folding, however, it doesn't get the nesting right. |
286 command -nargs=+ HiLink hi link <args> | 289 command -nargs=+ HiLink hi link <args> |
287 else | 290 else |
288 command -nargs=+ HiLink hi def link <args> | 291 command -nargs=+ HiLink hi def link <args> |
289 endif | 292 endif |
290 | 293 |
291 " NOTE - the following links are not guaranteed to | 294 " NOTE - the following links are not guaranteed to |
292 " look good under all colorschemes. You might need to | 295 " look good under all colorschemes. You might need to |
293 " :so $VIMRUNTIME/syntax/hitest.vim and tweak these to | 296 " :so $VIMRUNTIME/syntax/hitest.vim and tweak these to |
294 " look good in yours | 297 " look good in yours |
295 | 298 |
296 | 299 |
297 HiLink mmaComment Comment | 300 HiLink mmaComment Comment |
321 | 324 |
322 delcommand HiLink | 325 delcommand HiLink |
323 endif | 326 endif |
324 | 327 |
325 let b:current_syntax = "mma" | 328 let b:current_syntax = "mma" |
329 | |
330 let &cpo = s:cpo_save | |
331 unlet s:cpo_save |