7
|
1 " Vim syntax file
|
|
2 " Language: JavaScript
|
|
3 " Maintainer: Claudio Fleiner <claudio@fleiner.com>
|
557
|
4 " Updaters: Scott Shattuck (ss) <ss@technicalpursuit.com>
|
7
|
5 " URL: http://www.fleiner.com/vim/syntax/javascript.vim
|
557
|
6 " Changes: (ss) added keywords, reserved words, and other identifiers
|
|
7 " (ss) repaired several quoting and grouping glitches
|
|
8 " (ss) fixed regex parsing issue with multiple qualifiers [gi]
|
|
9 " (ss) additional factoring of keywords, globals, and members
|
3854
|
10 " Last Change: 2012 Oct 05
|
4869
|
11 " 2013 Jun 12: adjusted javaScriptRegexpString (Kevin Locke)
|
7
|
12
|
|
13 " For version 5.x: Clear all syntax items
|
|
14 " For version 6.x: Quit when a syntax file was already loaded
|
|
15 " tuning parameters:
|
|
16 " unlet javaScript_fold
|
|
17
|
|
18 if !exists("main_syntax")
|
|
19 if version < 600
|
|
20 syntax clear
|
|
21 elseif exists("b:current_syntax")
|
|
22 finish
|
|
23 endif
|
|
24 let main_syntax = 'javascript'
|
5239
|
25 elseif exists("b:current_syntax") && b:current_syntax == "javascript"
|
|
26 finish
|
7
|
27 endif
|
|
28
|
3854
|
29 let s:cpo_save = &cpo
|
|
30 set cpo&vim
|
|
31
|
7
|
32 " Drop fold if it set but vim doesn't support it.
|
|
33 if version < 600 && exists("javaScript_fold")
|
|
34 unlet javaScript_fold
|
|
35 endif
|
|
36
|
|
37
|
|
38 syn keyword javaScriptCommentTodo TODO FIXME XXX TBD contained
|
1121
|
39 syn match javaScriptLineComment "\/\/.*" contains=@Spell,javaScriptCommentTodo
|
7
|
40 syn match javaScriptCommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
|
1121
|
41 syn region javaScriptComment start="/\*" end="\*/" contains=@Spell,javaScriptCommentTodo
|
7
|
42 syn match javaScriptSpecial "\\\d\d\d\|\\."
|
2152
|
43 syn region javaScriptStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=javaScriptSpecial,@htmlPreproc
|
|
44 syn region javaScriptStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=javaScriptSpecial,@htmlPreproc
|
557
|
45
|
7
|
46 syn match javaScriptSpecialCharacter "'\\.'"
|
|
47 syn match javaScriptNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
|
4869
|
48 syn region javaScriptRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gim]\{0,2\}\s*$+ end=+/[gim]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline
|
557
|
49
|
|
50 syn keyword javaScriptConditional if else switch
|
|
51 syn keyword javaScriptRepeat while for do in
|
|
52 syn keyword javaScriptBranch break continue
|
|
53 syn keyword javaScriptOperator new delete instanceof typeof
|
|
54 syn keyword javaScriptType Array Boolean Date Function Number Object String RegExp
|
36
|
55 syn keyword javaScriptStatement return with
|
|
56 syn keyword javaScriptBoolean true false
|
557
|
57 syn keyword javaScriptNull null undefined
|
2152
|
58 syn keyword javaScriptIdentifier arguments this var let
|
557
|
59 syn keyword javaScriptLabel case default
|
|
60 syn keyword javaScriptException try catch finally throw
|
|
61 syn keyword javaScriptMessage alert confirm prompt status
|
|
62 syn keyword javaScriptGlobal self window top parent
|
|
63 syn keyword javaScriptMember document event location
|
|
64 syn keyword javaScriptDeprecated escape unescape
|
|
65 syn keyword javaScriptReserved abstract boolean byte char class const debugger double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile
|
7
|
66
|
|
67 if exists("javaScript_fold")
|
2152
|
68 syn match javaScriptFunction "\<function\>"
|
7
|
69 syn region javaScriptFunctionFold start="\<function\>.*[^};]$" end="^\z1}.*$" transparent fold keepend
|
|
70
|
|
71 syn sync match javaScriptSync grouphere javaScriptFunctionFold "\<function\>"
|
|
72 syn sync match javaScriptSync grouphere NONE "^}"
|
|
73
|
|
74 setlocal foldmethod=syntax
|
|
75 setlocal foldtext=getline(v:foldstart)
|
|
76 else
|
2152
|
77 syn keyword javaScriptFunction function
|
557
|
78 syn match javaScriptBraces "[{}\[\]]"
|
|
79 syn match javaScriptParens "[()]"
|
7
|
80 endif
|
|
81
|
|
82 syn sync fromstart
|
|
83 syn sync maxlines=100
|
|
84
|
|
85 if main_syntax == "javascript"
|
|
86 syn sync ccomment javaScriptComment
|
|
87 endif
|
|
88
|
|
89 " Define the default highlighting.
|
|
90 " For version 5.7 and earlier: only when not done already
|
|
91 " For version 5.8 and later: only when an item doesn't have highlighting yet
|
|
92 if version >= 508 || !exists("did_javascript_syn_inits")
|
|
93 if version < 508
|
|
94 let did_javascript_syn_inits = 1
|
|
95 command -nargs=+ HiLink hi link <args>
|
|
96 else
|
|
97 command -nargs=+ HiLink hi def link <args>
|
|
98 endif
|
36
|
99 HiLink javaScriptComment Comment
|
|
100 HiLink javaScriptLineComment Comment
|
|
101 HiLink javaScriptCommentTodo Todo
|
|
102 HiLink javaScriptSpecial Special
|
|
103 HiLink javaScriptStringS String
|
|
104 HiLink javaScriptStringD String
|
|
105 HiLink javaScriptCharacter Character
|
|
106 HiLink javaScriptSpecialCharacter javaScriptSpecial
|
|
107 HiLink javaScriptNumber javaScriptValue
|
|
108 HiLink javaScriptConditional Conditional
|
|
109 HiLink javaScriptRepeat Repeat
|
|
110 HiLink javaScriptBranch Conditional
|
|
111 HiLink javaScriptOperator Operator
|
|
112 HiLink javaScriptType Type
|
|
113 HiLink javaScriptStatement Statement
|
|
114 HiLink javaScriptFunction Function
|
|
115 HiLink javaScriptBraces Function
|
|
116 HiLink javaScriptError Error
|
|
117 HiLink javaScrParenError javaScriptError
|
|
118 HiLink javaScriptNull Keyword
|
|
119 HiLink javaScriptBoolean Boolean
|
|
120 HiLink javaScriptRegexpString String
|
557
|
121
|
|
122 HiLink javaScriptIdentifier Identifier
|
|
123 HiLink javaScriptLabel Label
|
|
124 HiLink javaScriptException Exception
|
|
125 HiLink javaScriptMessage Keyword
|
|
126 HiLink javaScriptGlobal Keyword
|
|
127 HiLink javaScriptMember Keyword
|
|
128 HiLink javaScriptDeprecated Exception
|
|
129 HiLink javaScriptReserved Keyword
|
|
130 HiLink javaScriptDebug Debug
|
|
131 HiLink javaScriptConstant Label
|
|
132
|
7
|
133 delcommand HiLink
|
|
134 endif
|
|
135
|
|
136 let b:current_syntax = "javascript"
|
|
137 if main_syntax == 'javascript'
|
|
138 unlet main_syntax
|
|
139 endif
|
3854
|
140 let &cpo = s:cpo_save
|
|
141 unlet s:cpo_save
|
7
|
142
|
|
143 " vim: ts=8
|