annotate runtime/syntax/javascript.vim @ 6691:c4cb95fb4c58 v7.4.670

updated for version 7.4.670 Problem: Using 'cindent' for Javascript is less than perfect. Solution: Improve indenting of continuation lines. (Hirohito Higashi)
author Bram Moolenaar <bram@vim.org>
date Fri, 20 Mar 2015 19:06:06 +0100
parents 11cd8d58372e
children 43efa4f5a8ea
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>
557
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
4 " Updaters: Scott Shattuck (ss) <ss@technicalpursuit.com>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 " URL: http://www.fleiner.com/vim/syntax/javascript.vim
557
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
6 " Changes: (ss) added keywords, reserved words, and other identifiers
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
7 " (ss) repaired several quoting and grouping glitches
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
8 " (ss) fixed regex parsing issue with multiple qualifiers [gi]
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
9 " (ss) additional factoring of keywords, globals, and members
3854
aa51675adf7e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
10 " Last Change: 2012 Oct 05
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3854
diff changeset
11 " 2013 Jun 12: adjusted javaScriptRegexpString (Kevin Locke)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 " For version 5.x: Clear all syntax items
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 " For version 6.x: Quit when a syntax file was already loaded
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 " tuning parameters:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 " unlet javaScript_fold
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 if !exists("main_syntax")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 if version < 600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 syntax clear
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 elseif exists("b:current_syntax")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 let main_syntax = 'javascript'
5239
11cd8d58372e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4869
diff changeset
25 elseif exists("b:current_syntax") && b:current_syntax == "javascript"
11cd8d58372e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 4869
diff changeset
26 finish
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28
3854
aa51675adf7e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
29 let s:cpo_save = &cpo
aa51675adf7e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
30 set cpo&vim
aa51675adf7e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
31
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 " Drop fold if it set but vim doesn't support it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 if version < 600 && exists("javaScript_fold")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 unlet javaScript_fold
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 syn keyword javaScriptCommentTodo TODO FIXME XXX TBD contained
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 829
diff changeset
39 syn match javaScriptLineComment "\/\/.*" contains=@Spell,javaScriptCommentTodo
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 syn match javaScriptCommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 829
diff changeset
41 syn region javaScriptComment start="/\*" end="\*/" contains=@Spell,javaScriptCommentTodo
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 syn match javaScriptSpecial "\\\d\d\d\|\\."
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1121
diff changeset
43 syn region javaScriptStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=javaScriptSpecial,@htmlPreproc
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1121
diff changeset
44 syn region javaScriptStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=javaScriptSpecial,@htmlPreproc
557
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
45
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 syn match javaScriptSpecialCharacter "'\\.'"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 syn match javaScriptNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
4869
a5352e73dc00 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3854
diff changeset
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
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
49
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
50 syn keyword javaScriptConditional if else switch
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
51 syn keyword javaScriptRepeat while for do in
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
52 syn keyword javaScriptBranch break continue
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
53 syn keyword javaScriptOperator new delete instanceof typeof
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
54 syn keyword javaScriptType Array Boolean Date Function Number Object String RegExp
36
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
55 syn keyword javaScriptStatement return with
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
56 syn keyword javaScriptBoolean true false
557
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
57 syn keyword javaScriptNull null undefined
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1121
diff changeset
58 syn keyword javaScriptIdentifier arguments this var let
557
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
59 syn keyword javaScriptLabel case default
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
60 syn keyword javaScriptException try catch finally throw
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
61 syn keyword javaScriptMessage alert confirm prompt status
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
62 syn keyword javaScriptGlobal self window top parent
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
63 syn keyword javaScriptMember document event location
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
64 syn keyword javaScriptDeprecated escape unescape
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 if exists("javaScript_fold")
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1121
diff changeset
68 syn match javaScriptFunction "\<function\>"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 syn region javaScriptFunctionFold start="\<function\>.*[^};]$" end="^\z1}.*$" transparent fold keepend
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 syn sync match javaScriptSync grouphere javaScriptFunctionFold "\<function\>"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 syn sync match javaScriptSync grouphere NONE "^}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 setlocal foldmethod=syntax
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 setlocal foldtext=getline(v:foldstart)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 else
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1121
diff changeset
77 syn keyword javaScriptFunction function
557
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
78 syn match javaScriptBraces "[{}\[\]]"
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
79 syn match javaScriptParens "[()]"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 syn sync fromstart
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 syn sync maxlines=100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 if main_syntax == "javascript"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 syn sync ccomment javaScriptComment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 " Define the default highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 " For version 5.7 and earlier: only when not done already
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 " 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
92 if version >= 508 || !exists("did_javascript_syn_inits")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 if version < 508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 let did_javascript_syn_inits = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 command -nargs=+ HiLink hi link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 command -nargs=+ HiLink hi def link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 endif
36
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
99 HiLink javaScriptComment Comment
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
100 HiLink javaScriptLineComment Comment
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
101 HiLink javaScriptCommentTodo Todo
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
102 HiLink javaScriptSpecial Special
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
103 HiLink javaScriptStringS String
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
104 HiLink javaScriptStringD String
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
105 HiLink javaScriptCharacter Character
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
106 HiLink javaScriptSpecialCharacter javaScriptSpecial
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
107 HiLink javaScriptNumber javaScriptValue
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
108 HiLink javaScriptConditional Conditional
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
109 HiLink javaScriptRepeat Repeat
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
110 HiLink javaScriptBranch Conditional
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
111 HiLink javaScriptOperator Operator
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
112 HiLink javaScriptType Type
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
113 HiLink javaScriptStatement Statement
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
114 HiLink javaScriptFunction Function
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
115 HiLink javaScriptBraces Function
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
116 HiLink javaScriptError Error
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
117 HiLink javaScrParenError javaScriptError
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
118 HiLink javaScriptNull Keyword
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
119 HiLink javaScriptBoolean Boolean
125e80798a85 updated for version 7.0021
vimboss
parents: 7
diff changeset
120 HiLink javaScriptRegexpString String
557
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
121
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
122 HiLink javaScriptIdentifier Identifier
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
123 HiLink javaScriptLabel Label
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
124 HiLink javaScriptException Exception
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
125 HiLink javaScriptMessage Keyword
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
126 HiLink javaScriptGlobal Keyword
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
127 HiLink javaScriptMember Keyword
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
128 HiLink javaScriptDeprecated Exception
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
129 HiLink javaScriptReserved Keyword
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
130 HiLink javaScriptDebug Debug
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
131 HiLink javaScriptConstant Label
862863033fdd updated for version 7.0158
vimboss
parents: 417
diff changeset
132
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 delcommand HiLink
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 let b:current_syntax = "javascript"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 if main_syntax == 'javascript'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 unlet main_syntax
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 endif
3854
aa51675adf7e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
140 let &cpo = s:cpo_save
aa51675adf7e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2152
diff changeset
141 unlet s:cpo_save
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 " vim: ts=8