Install vim73
[git/jnareb-git.git] / share / vim / vim73 / syntax / javascript.vim
blobb293eb8069ef05b6ebb37006ba1212d7676abe45
1 " Vim syntax file
2 " Language:     JavaScript
3 " Maintainer:   Claudio Fleiner <claudio@fleiner.com>
4 " Updaters:     Scott Shattuck (ss) <ss@technicalpursuit.com>
5 " URL:          http://www.fleiner.com/vim/syntax/javascript.vim
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
10 " Last Change:  2010 Mar 25
12 " For version 5.x: Clear all syntax items
13 " For version 6.x: Quit when a syntax file was already loaded
14 " tuning parameters:
15 " unlet javaScript_fold
17 if !exists("main_syntax")
18   if version < 600
19     syntax clear
20   elseif exists("b:current_syntax")
21     finish
22   endif
23   let main_syntax = 'javascript'
24 endif
26 " Drop fold if it set but vim doesn't support it.
27 if version < 600 && exists("javaScript_fold")
28   unlet javaScript_fold
29 endif
32 syn keyword javaScriptCommentTodo      TODO FIXME XXX TBD contained
33 syn match   javaScriptLineComment      "\/\/.*" contains=@Spell,javaScriptCommentTodo
34 syn match   javaScriptCommentSkip      "^[ \t]*\*\($\|[ \t]\+\)"
35 syn region  javaScriptComment          start="/\*"  end="\*/" contains=@Spell,javaScriptCommentTodo
36 syn match   javaScriptSpecial          "\\\d\d\d\|\\."
37 syn region  javaScriptStringD          start=+"+  skip=+\\\\\|\\"+  end=+"\|$+  contains=javaScriptSpecial,@htmlPreproc
38 syn region  javaScriptStringS          start=+'+  skip=+\\\\\|\\'+  end=+'\|$+  contains=javaScriptSpecial,@htmlPreproc
40 syn match   javaScriptSpecialCharacter "'\\.'"
41 syn match   javaScriptNumber           "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
42 syn region  javaScriptRegexpString     start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gi]\{0,2\}\s*$+ end=+/[gi]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline
44 syn keyword javaScriptConditional       if else switch
45 syn keyword javaScriptRepeat            while for do in
46 syn keyword javaScriptBranch            break continue
47 syn keyword javaScriptOperator          new delete instanceof typeof
48 syn keyword javaScriptType              Array Boolean Date Function Number Object String RegExp
49 syn keyword javaScriptStatement         return with
50 syn keyword javaScriptBoolean           true false
51 syn keyword javaScriptNull              null undefined
52 syn keyword javaScriptIdentifier        arguments this var let
53 syn keyword javaScriptLabel             case default
54 syn keyword javaScriptException         try catch finally throw
55 syn keyword javaScriptMessage           alert confirm prompt status
56 syn keyword javaScriptGlobal            self window top parent
57 syn keyword javaScriptMember            document event location 
58 syn keyword javaScriptDeprecated        escape unescape
59 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 
61 if exists("javaScript_fold")
62     syn match   javaScriptFunction      "\<function\>"
63     syn region  javaScriptFunctionFold  start="\<function\>.*[^};]$" end="^\z1}.*$" transparent fold keepend
65     syn sync match javaScriptSync       grouphere javaScriptFunctionFold "\<function\>"
66     syn sync match javaScriptSync       grouphere NONE "^}"
68     setlocal foldmethod=syntax
69     setlocal foldtext=getline(v:foldstart)
70 else
71     syn keyword javaScriptFunction      function
72     syn match   javaScriptBraces           "[{}\[\]]"
73     syn match   javaScriptParens           "[()]"
74 endif
76 syn sync fromstart
77 syn sync maxlines=100
79 if main_syntax == "javascript"
80   syn sync ccomment javaScriptComment
81 endif
83 " Define the default highlighting.
84 " For version 5.7 and earlier: only when not done already
85 " For version 5.8 and later: only when an item doesn't have highlighting yet
86 if version >= 508 || !exists("did_javascript_syn_inits")
87   if version < 508
88     let did_javascript_syn_inits = 1
89     command -nargs=+ HiLink hi link <args>
90   else
91     command -nargs=+ HiLink hi def link <args>
92   endif
93   HiLink javaScriptComment              Comment
94   HiLink javaScriptLineComment          Comment
95   HiLink javaScriptCommentTodo          Todo
96   HiLink javaScriptSpecial              Special
97   HiLink javaScriptStringS              String
98   HiLink javaScriptStringD              String
99   HiLink javaScriptCharacter            Character
100   HiLink javaScriptSpecialCharacter     javaScriptSpecial
101   HiLink javaScriptNumber               javaScriptValue
102   HiLink javaScriptConditional          Conditional
103   HiLink javaScriptRepeat               Repeat
104   HiLink javaScriptBranch               Conditional
105   HiLink javaScriptOperator             Operator
106   HiLink javaScriptType                 Type
107   HiLink javaScriptStatement            Statement
108   HiLink javaScriptFunction             Function
109   HiLink javaScriptBraces               Function
110   HiLink javaScriptError                Error
111   HiLink javaScrParenError              javaScriptError
112   HiLink javaScriptNull                 Keyword
113   HiLink javaScriptBoolean              Boolean
114   HiLink javaScriptRegexpString         String
116   HiLink javaScriptIdentifier           Identifier
117   HiLink javaScriptLabel                Label
118   HiLink javaScriptException            Exception
119   HiLink javaScriptMessage              Keyword
120   HiLink javaScriptGlobal               Keyword
121   HiLink javaScriptMember               Keyword
122   HiLink javaScriptDeprecated           Exception 
123   HiLink javaScriptReserved             Keyword
124   HiLink javaScriptDebug                Debug
125   HiLink javaScriptConstant             Label
127   delcommand HiLink
128 endif
130 let b:current_syntax = "javascript"
131 if main_syntax == 'javascript'
132   unlet main_syntax
133 endif
135 " vim: ts=8