Mercurial > vim
annotate runtime/syntax/javascript.vim @ 19470:ddc2e7caff46
Added tag v8.2.0292 for changeset 55656a51d2af1ff933d100af21206204f1bb0938
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 20 Feb 2020 23:15:04 +0100 |
parents | 03b854983b14 |
children | 74e3316c1d5a |
rev | line source |
---|---|
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 | |
18186 | 10 " Last Change: 2019 Sep 27 |
4869 | 11 " 2013 Jun 12: adjusted javaScriptRegexpString (Kevin Locke) |
13735 | 12 " 2018 Apr 14: adjusted javaScriptRegexpString (LongJohnCoder) |
7 | 13 |
14 " tuning parameters: | |
15 " unlet javaScript_fold | |
16 | |
17 if !exists("main_syntax") | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
5239
diff
changeset
|
18 " quit when a syntax file was already loaded |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
5239
diff
changeset
|
19 if exists("b:current_syntax") |
7 | 20 finish |
21 endif | |
22 let main_syntax = 'javascript' | |
5239 | 23 elseif exists("b:current_syntax") && b:current_syntax == "javascript" |
24 finish | |
7 | 25 endif |
26 | |
3854 | 27 let s:cpo_save = &cpo |
28 set cpo&vim | |
29 | |
7 | 30 |
31 syn keyword javaScriptCommentTodo TODO FIXME XXX TBD contained | |
1121 | 32 syn match javaScriptLineComment "\/\/.*" contains=@Spell,javaScriptCommentTodo |
7 | 33 syn match javaScriptCommentSkip "^[ \t]*\*\($\|[ \t]\+\)" |
1121 | 34 syn region javaScriptComment start="/\*" end="\*/" contains=@Spell,javaScriptCommentTodo |
7 | 35 syn match javaScriptSpecial "\\\d\d\d\|\\." |
2152 | 36 syn region javaScriptStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=javaScriptSpecial,@htmlPreproc |
37 syn region javaScriptStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=javaScriptSpecial,@htmlPreproc | |
14421 | 38 syn region javaScriptStringT start=+`+ skip=+\\\\\|\\`+ end=+`+ contains=javaScriptSpecial,javaScriptEmbed,@htmlPreproc |
39 | |
40 syn region javaScriptEmbed start=+${+ end=+}+ contains=@javaScriptEmbededExpr | |
557 | 41 |
7 | 42 syn match javaScriptSpecialCharacter "'\\.'" |
43 syn match javaScriptNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>" | |
14421 | 44 syn region javaScriptRegexpString start=+[,(=+]\s*/[^/*]+ms=e-1,me=e-1 skip=+\\\\\|\\/+ end=+/[gimuys]\{0,2\}\s*$+ end=+/[gimuys]\{0,2\}\s*[+;.,)\]}]+me=e-1 end=+/[gimuys]\{0,2\}\s\+\/+me=e-1 contains=@htmlPreproc,javaScriptComment oneline |
557 | 45 |
46 syn keyword javaScriptConditional if else switch | |
47 syn keyword javaScriptRepeat while for do in | |
48 syn keyword javaScriptBranch break continue | |
49 syn keyword javaScriptOperator new delete instanceof typeof | |
50 syn keyword javaScriptType Array Boolean Date Function Number Object String RegExp | |
18186 | 51 syn keyword javaScriptStatement return with await |
36 | 52 syn keyword javaScriptBoolean true false |
557 | 53 syn keyword javaScriptNull null undefined |
2152 | 54 syn keyword javaScriptIdentifier arguments this var let |
557 | 55 syn keyword javaScriptLabel case default |
56 syn keyword javaScriptException try catch finally throw | |
57 syn keyword javaScriptMessage alert confirm prompt status | |
58 syn keyword javaScriptGlobal self window top parent | |
59 syn keyword javaScriptMember document event location | |
60 syn keyword javaScriptDeprecated escape unescape | |
18186 | 61 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 async |
7 | 62 |
14421 | 63 syn cluster javaScriptEmbededExpr contains=javaScriptBoolean,javaScriptNull,javaScriptIdentifier,javaScriptStringD,javaScriptStringS,javaScriptStringT |
64 | |
7 | 65 if exists("javaScript_fold") |
2152 | 66 syn match javaScriptFunction "\<function\>" |
7 | 67 syn region javaScriptFunctionFold start="\<function\>.*[^};]$" end="^\z1}.*$" transparent fold keepend |
68 | |
69 syn sync match javaScriptSync grouphere javaScriptFunctionFold "\<function\>" | |
70 syn sync match javaScriptSync grouphere NONE "^}" | |
71 | |
72 setlocal foldmethod=syntax | |
73 setlocal foldtext=getline(v:foldstart) | |
74 else | |
2152 | 75 syn keyword javaScriptFunction function |
557 | 76 syn match javaScriptBraces "[{}\[\]]" |
77 syn match javaScriptParens "[()]" | |
7 | 78 endif |
79 | |
80 syn sync fromstart | |
81 syn sync maxlines=100 | |
82 | |
83 if main_syntax == "javascript" | |
84 syn sync ccomment javaScriptComment | |
85 endif | |
86 | |
87 " Define the default highlighting. | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
5239
diff
changeset
|
88 " Only when an item doesn't have highlighting yet |
10051
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
89 hi def link javaScriptComment Comment |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
90 hi def link javaScriptLineComment Comment |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
91 hi def link javaScriptCommentTodo Todo |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
92 hi def link javaScriptSpecial Special |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
93 hi def link javaScriptStringS String |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
94 hi def link javaScriptStringD String |
14421 | 95 hi def link javaScriptStringT String |
10051
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
96 hi def link javaScriptCharacter Character |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
97 hi def link javaScriptSpecialCharacter javaScriptSpecial |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
98 hi def link javaScriptNumber javaScriptValue |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
99 hi def link javaScriptConditional Conditional |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
100 hi def link javaScriptRepeat Repeat |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
101 hi def link javaScriptBranch Conditional |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
102 hi def link javaScriptOperator Operator |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
103 hi def link javaScriptType Type |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
104 hi def link javaScriptStatement Statement |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
105 hi def link javaScriptFunction Function |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
106 hi def link javaScriptBraces Function |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
107 hi def link javaScriptError Error |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
108 hi def link javaScrParenError javaScriptError |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
109 hi def link javaScriptNull Keyword |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
110 hi def link javaScriptBoolean Boolean |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
111 hi def link javaScriptRegexpString String |
557 | 112 |
10051
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
113 hi def link javaScriptIdentifier Identifier |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
114 hi def link javaScriptLabel Label |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
115 hi def link javaScriptException Exception |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
116 hi def link javaScriptMessage Keyword |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
117 hi def link javaScriptGlobal Keyword |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
118 hi def link javaScriptMember Keyword |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
119 hi def link javaScriptDeprecated Exception |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
120 hi def link javaScriptReserved Keyword |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
121 hi def link javaScriptDebug Debug |
46763b01cd9a
commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents:
10048
diff
changeset
|
122 hi def link javaScriptConstant Label |
14421 | 123 hi def link javaScriptEmbed Special |
124 | |
557 | 125 |
7 | 126 |
127 let b:current_syntax = "javascript" | |
128 if main_syntax == 'javascript' | |
129 unlet main_syntax | |
130 endif | |
3854 | 131 let &cpo = s:cpo_save |
132 unlet s:cpo_save | |
7 | 133 |
134 " vim: ts=8 |