Skip to content

Commit c125db3

Browse files
committed
Merge remote-tracking branch 'refs/remotes/pangloss/develop' into develop
# Conflicts: # indent/javascript.vim
2 parents b246a50 + 55da36b commit c125db3

File tree

3 files changed

+49
-37
lines changed

3 files changed

+49
-37
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,16 @@ Default Value: 0
6767
You can customize concealing characters by defining one or more of the following
6868
variables:
6969

70-
let g:javascript_conceal_function = "ƒ"
71-
let g:javascript_conceal_null = "ø"
72-
let g:javascript_conceal_this = "@"
73-
let g:javascript_conceal_return = "⇚"
74-
let g:javascript_conceal_undefined = "¿"
75-
let g:javascript_conceal_NaN = "ℕ"
76-
let g:javascript_conceal_prototype = "¶"
77-
let g:javascript_conceal_static = "•"
78-
let g:javascript_conceal_super = "Ω"
70+
let g:javascript_conceal_function = "ƒ"
71+
let g:javascript_conceal_null = "ø"
72+
let g:javascript_conceal_this = "@"
73+
let g:javascript_conceal_return = "⇚"
74+
let g:javascript_conceal_undefined = "¿"
75+
let g:javascript_conceal_NaN = "ℕ"
76+
let g:javascript_conceal_prototype = "¶"
77+
let g:javascript_conceal_static = "•"
78+
let g:javascript_conceal_super = "Ω"
79+
let g:javascript_conceal_arrow_function = "⇒"
7980

8081
## Contributing
8182

indent/javascript.vim

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ endif
2626
let s:cpo_save = &cpo
2727
set cpo&vim
2828

29+
" Get shiftwidth value
30+
if exists('*shiftwidth')
31+
func s:sw()
32+
return shiftwidth()
33+
endfunc
34+
else
35+
func s:sw()
36+
return &sw
37+
endfunc
38+
endif
39+
2940
" 1. Variables {{{1
3041
" ============
3142

@@ -68,15 +79,15 @@ let s:comma_last = ',\s*$'
6879
let s:ternary = '^\s\+[?|:]'
6980
let s:ternary_q = '^\s\+?'
7081

71-
let s:case_indent = &sw
72-
let s:case_indent_after = &sw
73-
let m = matchlist(&cinoptions, ':\(.\)')
74-
if (len(m) > 2)
75-
let s:case_indent = m[1]
82+
let s:case_indent = s:sw()
83+
let s:case_indent_after = s:sw()
84+
let s:m = matchlist(&cinoptions, ':\(.\)')
85+
if (len(s:m) > 2)
86+
let s:case_indent = s:m[1]
7687
endif
77-
let m = matchlist(&cinoptions, '=\(.\)')
78-
if (len(m) > 2)
79-
let s:case_indent_after = m[1]
88+
let s:m = matchlist(&cinoptions, '=\(.\)')
89+
if (len(s:m) > 2)
90+
let s:case_indent_after = s:m[1]
8091
endif
8192
" 2. Auxiliary Functions {{{1
8293
" ======================
@@ -201,9 +212,9 @@ function s:GetVarIndent(lnum)
201212

202213
" if the previous line doesn't end in a comma, return to regular indent
203214
if (line !~ s:comma_last)
204-
return indent(prev_lnum) - &sw
215+
return indent(prev_lnum) - s:sw()
205216
else
206-
return indent(lvar) + &sw
217+
return indent(lvar) + s:sw()
207218
endif
208219
endif
209220

@@ -342,7 +353,7 @@ function GetJavascriptIndent()
342353
return indent(prevline)
343354
" otherwise we indent 1 level
344355
else
345-
return indent(lvar) + &sw
356+
return indent(lvar) + s:sw()
346357
endif
347358
endif
348359
endif
@@ -361,7 +372,7 @@ function GetJavascriptIndent()
361372

362373
" If the line is comma first, dedent 1 level
363374
if (getline(prevline) =~ s:comma_first)
364-
return indent(prevline) - &sw
375+
return indent(prevline) - s:sw()
365376
endif
366377
if (getline(prevline) =~ s:expr_case)
367378
return indent(prevline) + s:case_indent_after
@@ -371,7 +382,7 @@ function GetJavascriptIndent()
371382
if (getline(prevline) =~ s:ternary_q)
372383
return indent(prevline)
373384
else
374-
return indent(prevline) + &sw
385+
return indent(prevline) + s:sw()
375386
endif
376387
endif
377388

@@ -413,9 +424,9 @@ function GetJavascriptIndent()
413424
" If the previous line ended with a block opening, add a level of indent.
414425
if s:Match(lnum, s:block_regex)
415426
if (line =~ s:expr_case)
416-
return indent(s:GetMSL(lnum, 0)) + &sw/2
427+
return indent(s:GetMSL(lnum, 0)) + s:sw()/2
417428
else
418-
return indent(s:GetMSL(lnum, 0)) + &sw
429+
return indent(s:GetMSL(lnum, 0)) + s:sw()
419430
endif
420431
endif
421432

@@ -428,12 +439,12 @@ function GetJavascriptIndent()
428439
let counts = s:LineHasOpeningBrackets(lnum)
429440
if counts[0] == '1' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0
430441
if col('.') + 1 == col('$')
431-
return ind + &sw
442+
return ind + s:sw()
432443
else
433444
return virtcol('.')
434445
endif
435446
elseif counts[1] == '1' || counts[2] == '1'
436-
return ind + &sw
447+
return ind + s:sw()
437448
else
438449
call cursor(v:lnum, vcol)
439450
end
@@ -443,18 +454,18 @@ function GetJavascriptIndent()
443454
" --------------------------
444455

445456
let ind_con = ind
446-
let ind = s:IndentWithContinuation(lnum, ind_con, &sw)
457+
let ind = s:IndentWithContinuation(lnum, ind_con, s:sw())
447458

448459
" }}}2
449460
"
450461
"
451462
let ols = s:InOneLineScope(lnum)
452463
if ols > 0
453-
let ind = ind + &sw
464+
let ind = ind + s:sw()
454465
else
455466
let ols = s:ExitingOneLineScope(lnum)
456467
while ols > 0 && ind > 0
457-
let ind = ind - &sw
468+
let ind = ind - s:sw()
458469
let ols = s:InOneLineScope(ols - 1)
459470
endwhile
460471
endif

syntax/javascript.vim

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ if !exists("javascript_ignore_javaScriptdoc")
6565
" tags containing a param
6666
syntax match jsDocTags contained "@\(alias\|api\|augments\|borrows\|class\|constructs\|default\|defaultvalue\|emits\|exception\|exports\|extends\|file\|fires\|kind\|listens\|member\|member[oO]f\|mixes\|module\|name\|namespace\|requires\|template\|throws\|var\|variation\|version\)\>" nextgroup=jsDocParam skipwhite
6767
" tags containing type and param
68-
syntax match jsDocTags contained "@\(arg\|argument\|param\|property\)\>" nextgroup=jsDocType skipwhite
68+
syntax match jsDocTags contained "@\(arg\|argument\|param\|property\|prop\)\>" nextgroup=jsDocType skipwhite
6969
" tags containing type but no param
7070
syntax match jsDocTags contained "@\(callback\|define\|enum\|external\|implements\|this\|type\|typedef\|return\|returns\)\>" nextgroup=jsDocTypeNoParam skipwhite
7171
" tags containing references
@@ -77,7 +77,7 @@ if !exists("javascript_ignore_javaScriptdoc")
7777
syntax match jsDocType contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" nextgroup=jsDocParam skipwhite
7878
syntax region jsDocTypeNoParam start="{" end="}" oneline contained
7979
syntax match jsDocTypeNoParam contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+"
80-
syntax match jsDocParam contained "\%(#\|\"\|{\|}\|\w\|\.\|:\|\/\|\[\|]\|=\)\+"
80+
syntax match jsDocParam contained "\%(#\|\$\|\"\|{\|}\|\w\|\.\|:\|\/\|\[\|]\|=\)\+"
8181
syntax region jsDocSeeTag contained matchgroup=jsDocSeeTag start="{" end="}" contains=jsDocTags
8282

8383
syntax case match
@@ -88,7 +88,7 @@ syntax case match
8888
"" Syntax in the JavaScript code
8989
syntax match jsFuncCall /\k\+\%(\s*(\)\@=/
9090
syntax match jsSpecial "\v\\%(0|\\x\x\{2\}\|\\u\x\{4\}\|\c[A-Z]|.)" contained
91-
syntax match jsTemplateVar "\${.\{-}}" contained
91+
syntax region jsTemplateVar matchgroup=jsBraces start=+${+ end=+}+ contained contains=@jsExpression
9292
syntax region jsStringD start=+"+ skip=+\\\("\|$\)+ end=+"\|$+ contains=jsSpecial,@htmlPreproc,@Spell
9393
syntax region jsStringS start=+'+ skip=+\\\('\|$\)+ end=+'\|$+ contains=jsSpecial,@htmlPreproc,@Spell
9494
syntax region jsTemplateString start=+`+ skip=+\\\(`\|$\)+ end=+`+ contains=jsTemplateVar,jsSpecial,@htmlPreproc
@@ -110,7 +110,7 @@ syntax match jsFunctionKey /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\(\s*:\s*function
110110
syntax match jsDecorator "@" display contains=jsDecoratorFunction nextgroup=jsDecoratorFunction skipwhite
111111
syntax match jsDecoratorFunction "[a-zA-Z_][a-zA-Z0-9_.]*" display contained nextgroup=jsFunc skipwhite
112112

113-
syntax match jsAssignmentExpr /\v%([a-zA-Z_$]\k*\.)*[a-zA-Z_$]\k*\s*\=\(>\)\@!/ contains=jsFuncAssignExpr,jsAssignExpIdent,jsPrototype,jsOperator,jsThis,jsNoise,jsArgsObj
113+
syntax match jsAssignmentExpr /\v%([a-zA-Z_$]\k*\.)*[a-zA-Z_$]\k*\s*\=\>@!/ contains=jsFuncAssignExpr,jsAssignExpIdent,jsPrototype,jsOperator,jsThis,jsNoise,jsArgsObj
114114
syntax match jsAssignExpIdent /\v[a-zA-Z_$]\k*\ze%(\s*\=)/ contained
115115
syntax match jsFuncAssignExpr /\v%(%([a-zA-Z_$]\k*\.)*[a-zA-Z_$]\k*\s*\=\s*){-1,}\ze%(function\s*\*?\s*\()/ contains=jsFuncAssignObjChain,jsFuncAssignIdent,jsFunction,jsPrototype,jsOperator,jsThis,jsArgsObj contained
116116
syntax match jsFuncAssignObjChain /\v%([a-zA-Z_$]\k*\.)+/ contains=jsPrototype,jsNoise contained
@@ -135,7 +135,7 @@ syntax keyword jsClass extends class
135135
syntax keyword jsException try catch throw finally
136136
syntax keyword jsAsyncKeyword async await
137137

138-
syntax keyword jsGlobalObjects Array Boolean Date Function Iterator Number Object Symbol Map WeakMap Set RegExp String Proxy Promise ParallelArray ArrayBuffer DataView Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray Intl JSON Math console document window
138+
syntax keyword jsGlobalObjects Array Boolean Date Function Iterator Number Object Symbol Map WeakMap Set RegExp String Proxy Promise Buffer ParallelArray ArrayBuffer DataView Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray Intl JSON Math console document window
139139
syntax match jsGlobalObjects /\%(Intl\.\)\@<=\(Collator\|DateTimeFormat\|NumberFormat\)/
140140

141141
syntax keyword jsExceptions Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError
@@ -166,7 +166,7 @@ if exists("javascript_enable_domhtmlcss")
166166

167167
" DOM2 things
168168
syntax match jsDomElemAttrs contained /\%(nodeName\|nodeValue\|nodeType\|parentNode\|childNodes\|firstChild\|lastChild\|previousSibling\|nextSibling\|attributes\|ownerDocument\|namespaceURI\|prefix\|localName\|tagName\)\>/
169-
syntax match jsDomElemFuncs contained /\%(insertBefore\|replaceChild\|removeChild\|appendChild\|hasChildNodes\|cloneNode\|normalize\|isSupported\|hasAttributes\|getAttribute\|setAttribute\|removeAttribute\|getAttributeNode\|setAttributeNode\|removeAttributeNode\|getElementsByTagName\|getAttributeNS\|setAttributeNS\|removeAttributeNS\|getAttributeNodeNS\|setAttributeNodeNS\|getElementsByTagNameNS\|hasAttribute\|hasAttributeNS\)\>/ nextgroup=jsParen skipwhite
169+
syntax match jsDomElemFuncs contained /\%(insertBefore\|replaceChild\|removeChild\|appendChild\|hasChildNodes\|cloneNode\|normalize\|isSupported\|hasAttributes\|getAttribute\|setAttribute\|removeAttribute\|getAttributeNode\|setAttributeNode\|removeAttributeNode\|getElementById\|getElementsByClassName\|getElementsByTagName\|querySelector\|querySelectorAll\|getAttributeNS\|setAttributeNS\|removeAttributeNS\|getAttributeNodeNS\|setAttributeNodeNS\|getElementsByTagNameNS\|hasAttribute\|hasAttributeNS\)\>/ nextgroup=jsParen skipwhite
170170
" HTML things
171171
syntax match jsHtmlElemAttrs contained /\%(className\|clientHeight\|clientLeft\|clientTop\|clientWidth\|dir\|id\|innerHTML\|lang\|length\|offsetHeight\|offsetLeft\|offsetParent\|offsetTop\|offsetWidth\|scrollHeight\|scrollLeft\|scrollTop\|scrollWidth\|style\|tabIndex\|title\)\>/
172172
syntax match jsHtmlElemFuncs contained /\%(blur\|click\|focus\|scrollIntoView\|addEventListener\|dispatchEvent\|removeEventListener\|item\)\>/ nextgroup=jsParen skipwhite
@@ -217,11 +217,11 @@ exe 'syntax match jsFunction /\<function\>/ nextgroup=jsGenerator,jsFuncName,jsF
217217

218218
syntax match jsGenerator contained '\*' nextgroup=jsFuncName skipwhite
219219
syntax match jsFuncName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*/ nextgroup=jsFuncArgs skipwhite
220-
syntax region jsFuncArgs contained matchgroup=jsFuncParens start='(' end=')' contains=jsFuncArgCommas,jsFuncArgRest,jsAssignmentExpr nextgroup=jsFuncBlock keepend skipwhite skipempty
220+
syntax region jsFuncArgs contained matchgroup=jsFuncParens start='(' end=')' contains=jsFuncArgCommas,jsFuncArgRest,jsAssignmentExpr,jsComment,jsLineComment nextgroup=jsFuncBlock keepend skipwhite skipempty
221221
syntax match jsFuncArgCommas contained ','
222222
syntax match jsFuncArgRest contained /\%(\.\.\.[a-zA-Z_$][0-9a-zA-Z_$]*\))/
223223

224-
syntax match jsArrowFunction /=>/
224+
exe 'syntax match jsArrowFunction /=>/ '.(exists('g:javascript_conceal_arrow_function') ? 'conceal cchar='.g:javascript_conceal_arrow_function : '')
225225

226226
" Define the default highlighting.
227227
" For version 5.7 and earlier: only when not done already

0 commit comments

Comments
 (0)