annotate runtime/syntax/javascript.vim @ 216:da182deebec7

updated for version 7.0061
author vimboss
date Fri, 18 Mar 2005 20:25:31 +0000
parents 125e80798a85
children 8f41fe56e2fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim syntax file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: JavaScript
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Maintainer: Claudio Fleiner <claudio@fleiner.com>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 " URL: http://www.fleiner.com/vim/syntax/javascript.vim
36
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
5 " Last Change: 2004 Nov 20
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " For version 5.x: Clear all syntax items
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " For version 6.x: Quit when a syntax file was already loaded
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 " tuning parameters:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 " unlet javaScript_fold
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 if !exists("main_syntax")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 if version < 600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 syntax clear
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 elseif exists("b:current_syntax")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 let main_syntax = 'javascript'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 " Drop fold if it set but vim doesn't support it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 if version < 600 && exists("javaScript_fold")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 unlet javaScript_fold
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 syn case ignore
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 syn keyword javaScriptCommentTodo TODO FIXME XXX TBD contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 syn match javaScriptLineComment "\/\/.*$" contains=javaScriptCommentTodo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 syn match javaScriptCommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 syn region javaScriptComment start="/\*" end="\*/" contains=javaScriptCommentTodo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 syn match javaScriptSpecial "\\\d\d\d\|\\."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 syn region javaScriptStringD start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=javaScriptSpecial,@htmlPreproc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 syn region javaScriptStringS start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=javaScriptSpecial,@htmlPreproc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 syn match javaScriptSpecialCharacter "'\\.'"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 syn match javaScriptNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
36
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
38 syn region javaScriptRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gi]\?\s*$+ end=+/[gi]\?\s*[;.,)]+me=e-1 contains=@htmlPreproc oneline
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
39 syn keyword javaScriptConditional if else
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
40 syn keyword javaScriptRepeat while for
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
41 syn keyword javaScriptBranch break continue switch case default
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
42 syn keyword javaScriptOperator new in
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
43 syn keyword javaScriptType this var const
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
44 syn keyword javaScriptStatement return with
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
45 syn keyword javaScriptBoolean true false
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
46 syn keyword javaScriptNull null
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 if exists("javaScript_fold")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 syn match javaScriptFunction "\<function\>"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 syn region javaScriptFunctionFold start="\<function\>.*[^};]$" end="^\z1}.*$" transparent fold keepend
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 syn sync match javaScriptSync grouphere javaScriptFunctionFold "\<function\>"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 syn sync match javaScriptSync grouphere NONE "^}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 setlocal foldmethod=syntax
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 setlocal foldtext=getline(v:foldstart)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 syn keyword javaScriptFunction function
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 syn match javaScriptBraces "[{}]"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 syn sync fromstart
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 syn sync maxlines=100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 " catch errors caused by wrong parenthesis
36
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
66 syn region javaScriptParen transparent start="(" end=")" contains=javaScriptParen,javaScriptComment,javaScriptSpecial,javaScriptStringD,javaScriptStringS,javaScriptSpecialCharacter,javaScriptNumber,javaScriptRegexpString,javaScriptBoolean,javaScriptBraces,javaScriptFunction,javaScriptFunctionFold,javaScriptConditional,javaScriptRepeat,javaScriptBranch,javaScriptOperator,javaScriptType,javaScriptStatement,javaScriptBoolean,javaScriptConstant
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
67 syn region javaScriptParen transparent start="(" end=")" contains=javaScriptParen,javaScriptComment,javaScriptSpecial,javaScriptStringD,javaScriptStringS,javaScriptSpecialCharacter,javaScriptNumber,javaScriptRegexpString,javaScriptBoolean,javaScriptBraces
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 syn match javaScrParenError ")"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 if main_syntax == "javascript"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 syn sync ccomment javaScriptComment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 " Define the default highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 " For version 5.7 and earlier: only when not done already
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 " For version 5.8 and later: only when an item doesn't have highlighting yet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 if version >= 508 || !exists("did_javascript_syn_inits")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 if version < 508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 let did_javascript_syn_inits = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 command -nargs=+ HiLink hi link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 command -nargs=+ HiLink hi def link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 endif
36
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
84 HiLink javaScriptComment Comment
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
85 HiLink javaScriptLineComment Comment
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
86 HiLink javaScriptCommentTodo Todo
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
87 HiLink javaScriptSpecial Special
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
88 HiLink javaScriptStringS String
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
89 HiLink javaScriptStringD String
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
90 HiLink javaScriptCharacter Character
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
91 HiLink javaScriptSpecialCharacter javaScriptSpecial
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
92 HiLink javaScriptNumber javaScriptValue
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
93 HiLink javaScriptConditional Conditional
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
94 HiLink javaScriptRepeat Repeat
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
95 HiLink javaScriptBranch Conditional
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
96 HiLink javaScriptOperator Operator
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
97 HiLink javaScriptType Type
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
98 HiLink javaScriptStatement Statement
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
99 HiLink javaScriptFunction Function
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
100 HiLink javaScriptBraces Function
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
101 HiLink javaScriptError Error
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
102 HiLink javaScrParenError javaScriptError
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
103 HiLink javaScriptNull Keyword
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
104 HiLink javaScriptBoolean Boolean
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
105 HiLink javaScriptRegexpString String
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 delcommand HiLink
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 let b:current_syntax = "javascript"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 if main_syntax == 'javascript'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 unlet main_syntax
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 " vim: ts=8