From d3e952cf8ddb556233638915c79be57c752cda7d Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Sun, 18 Sep 2016 01:41:39 -0700 Subject: [PATCH 01/34] multi-braceless statements (#636) * multi-braceless statements This changes: ``` if (1) for (;;) i += l ``` to: ``` if (1) for (;;) i += l ``` --- indent/javascript.vim | 60 +++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 16 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 1591dac0..b890a43a 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -75,15 +75,38 @@ if !exists('g:javascript_continuation') let g:javascript_continuation = '\%([<=,.?/*^%|&:]\|+\@\|\\)' . s:line_term ? 'no b' : + return cursor(a:lnum, match(' ' . a:text, '\%(\\)' . s:line_term)) > -1 || \ cursor(a:lnum, match(' ' . a:text, ')' . s:line_term)) > -1 && - \ s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0 && search('\C\l\+\_s*\%#','bW') && - \ (expand('') !=# 'while' || s:GetPair('\C\', '\C\','nbW',s:skip_expr,100) <= 0) && - \ (expand('') !=# 'each' || search('\C\') : '' + \ s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0 && + \ search('\C\<\%(for\%(\_s\+each\)\=\|if\|let\|w\%(hile\|ith\)\)\_s*\%#','bW') +endfunction + +function s:iscontOne(i,num,cont) + let [l:i, l:cont, l:num] = [a:i, a:cont, a:num > 0 ? a:num : 1] + let pind = a:num > 0 ? indent(l:num) : -s:sw() + let ind = indent(l:i) + (!l:cont ? s:sw() : 0) + let bL = 0 + while l:i >= l:num && (!l:cont || ind > pind + s:sw()) + if indent(l:i) < ind " first line always true for !cont, false for !!cont + if s:OneScope(l:i,substitute(getline(l:i),':\@') ==# 'while' && searchpair(s:line_pre . '\C\','','\C\','bW',s:skip_expr,l:num,100) > 0 + return 0 + endif + let bL += 1 + let l:cont = 0 + let l:i = line('.') + elseif !l:cont + break + endif + let ind = indent(l:i) + endif + let l:i = s:PrevCodeLine(l:i - 1) + endwhile + return bL * s:sw() endfunction " https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader @@ -138,8 +161,8 @@ function GetJavascriptIndent() let syns = synIDattr(synID(v:lnum, 1, 0), 'name') " start with strings,comments,etc.{{{2 - if (l:line !~ '^[''"]' && syns =~? '\%(string\|template\)') || - \ (l:line !~ '^\s*[/*]' && syns =~? s:syng_comment) + if l:line !~ '^[''"]' && syns =~? '\%(string\|template\)' || + \ l:line !~ '^\s*[/*]' && syns =~? s:syng_comment return -1 endif if l:line !~ '^\%(\/\*\|\s*\/\/\)' && syns =~? s:syng_comment @@ -150,7 +173,7 @@ function GetJavascriptIndent() return 0 endif - if (l:line =~# s:expr_case) + if l:line =~# s:expr_case let cpo_switch = &cpo set cpo+=% let ind = cindent(v:lnum) @@ -176,11 +199,16 @@ function GetJavascriptIndent() let b:js_cache = [v:lnum,num,line('.') == v:lnum ? b:js_cache[2] : col('.')] - if l:line =~ s:line_pre . '[])}]' + let l:line = substitute(l:line,s:line_pre,'','') + if l:line =~ '^[])}]' return indent(num) endif + call cursor(v:lnum,1) + if l:line =~# '^while\>' && searchpair(s:line_pre . '\C\','','\C\','bW',s:skip_expr,num,100) > 0 + return indent(line('.')) + endif - let pline = substitute(substitute(getline(l:lnum),s:expr_case,'\=repeat(" ",strlen(submatch(0)))',''), '\%(:\@ 0 && search('\C\' && - \ l:line !~ s:line_pre . '{' - return (num > 0 ? indent(num) : -s:sw()) + (s:sw() * 2) + switch_offset + let bL = s:iscontOne(l:lnum,num,isOp) + let bL = bL ? bL - (l:line =~ '^{') * s:sw() : bL + if isOp && (num <= 0 || cursor(b:js_cache[1],b:js_cache[2]) || s:IsBlock()) + return (num > 0 ? indent(num) : -s:sw()) + (s:sw() * 2) + switch_offset + bL elseif num > 0 - return indent(num) + s:sw() + switch_offset + return indent(num) + s:sw() + switch_offset + bL endif - + return bL endfunction From ebd222b3dfd05878145be3488573745aa160de70 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Sun, 18 Sep 2016 04:00:10 -0700 Subject: [PATCH 02/34] date,format --- indent/javascript.vim | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index b890a43a..42eb0882 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -2,7 +2,7 @@ " Language: Javascript " Maintainer: vim-javascript community " URL: https://github.com/pangloss/vim-javascript -" Last Change: September 4, 2016 +" Last Change: September 18, 2016 " Only load this indent file when no other was loaded. if exists('b:did_indent') @@ -112,12 +112,10 @@ endfunction " https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader function s:IsBlock() return getline(line('.'))[col('.')-1] == '{' && !search( - \ '\C\%(\\|\*\@\|\*\@ Date: Sun, 18 Sep 2016 04:06:48 -0700 Subject: [PATCH 03/34] Update javascript.vim --- indent/javascript.vim | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 42eb0882..836fc6d6 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -97,8 +97,7 @@ function s:iscontOne(i,num,cont) return 0 endif let bL += 1 - let l:cont = 0 - let l:i = line('.') + let [l:cont, l:i] = [0, line('.')] elseif !l:cont break endif @@ -148,7 +147,6 @@ function s:Balanced(lnum) endwhile return (!open_4 + !open_2 + !open_0) - 2 endfunction -" }}} function GetJavascriptIndent() if !exists('b:js_cache') From 6426110f831bd2ab6459e87c5bffad99d18697e1 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Sun, 18 Sep 2016 14:49:38 -0700 Subject: [PATCH 04/34] Update javascript.vim --- indent/javascript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 836fc6d6..646954f2 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -156,7 +156,7 @@ function GetJavascriptIndent() let l:line = getline(v:lnum) let syns = synIDattr(synID(v:lnum, 1, 0), 'name') - " start with strings,comments,etc.{{{2 + " start with strings,comments,etc. if l:line !~ '^[''"]' && syns =~? '\%(string\|template\)' || \ l:line !~ '^\s*[/*]' && syns =~? s:syng_comment return -1 From aa37199ecf040b7003f2d523b83f9ef0f04d25e3 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Sun, 18 Sep 2016 15:41:46 -0700 Subject: [PATCH 05/34] change to searchpair helper --- indent/javascript.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 646954f2..8d5ced26 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -93,7 +93,7 @@ function s:iscontOne(i,num,cont) while l:i >= l:num && (!l:cont || ind > pind + s:sw()) if indent(l:i) < ind " first line always true for !cont, false for !!cont if s:OneScope(l:i,substitute(getline(l:i),':\@') ==# 'while' && searchpair(s:line_pre . '\C\','','\C\','bW',s:skip_expr,l:num,100) > 0 + if expand('') ==# 'while' && s:GetPair(s:line_pre . '\C\\%>'.l:num-1.'l','\C\','bW',s:skip_expr,100) > 0 return 0 endif let bL += 1 @@ -199,7 +199,7 @@ function GetJavascriptIndent() return indent(num) endif call cursor(v:lnum,1) - if l:line =~# '^while\>' && searchpair(s:line_pre . '\C\','','\C\','bW',s:skip_expr,num,100) > 0 + if l:line =~# '^while\>' && s:GetPair(s:line_pre . '\C\\%>'.num-1.'l','\C\','bW',s:skip_expr,100) > 0 return indent(line('.')) endif From b2ded12588b35aa551240ec33e637f7ef04d52eb Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Sun, 18 Sep 2016 16:02:55 -0700 Subject: [PATCH 06/34] change num <= 0 to 0 --- indent/javascript.vim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 8d5ced26..83e889b6 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -192,6 +192,7 @@ function GetJavascriptIndent() let num = s:GetPair('[({[]','[])}]','bW','s:skip_func(s:looksyn)',2000) endif + let num = num > 0 ? num : 0 let b:js_cache = [v:lnum,num,line('.') == v:lnum ? b:js_cache[2] : col('.')] let l:line = substitute(l:line,s:line_pre,'','') @@ -199,13 +200,13 @@ function GetJavascriptIndent() return indent(num) endif call cursor(v:lnum,1) - if l:line =~# '^while\>' && s:GetPair(s:line_pre . '\C\\%>'.num-1.'l','\C\','bW',s:skip_expr,100) > 0 + if l:line =~# '^while\>' && s:GetPair(s:line_pre . '\C\\%>'.(num-!!num).'l','\C\','bW',s:skip_expr,100) > 0 return indent(line('.')) endif let pline = substitute(substitute(getline(l:lnum),s:expr_case,'\=repeat(" ",strlen(submatch(0)))',''), ':\@ 0 && search('\C\ 0 ? indent(num) : -s:sw()) + (s:sw() * 2) + switch_offset + bL - elseif num > 0 + if isOp && (!num || cursor(b:js_cache[1],b:js_cache[2]) || s:IsBlock()) + return (num ? indent(num) : -s:sw()) + (s:sw() * 2) + switch_offset + bL + elseif num return indent(num) + s:sw() + switch_offset + bL endif return bL From 5df8b344a49c54be1bfe133a62f4fc00fc313bd7 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Sun, 18 Sep 2016 16:15:26 -0700 Subject: [PATCH 07/34] more number conversion --- indent/javascript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 83e889b6..2f09133a 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -86,7 +86,7 @@ function s:OneScope(lnum,text) endfunction function s:iscontOne(i,num,cont) - let [l:i, l:cont, l:num] = [a:i, a:cont, a:num > 0 ? a:num : 1] + let [l:i, l:cont, l:num] = [a:i, a:cont, a:num ? a:num : 1] let pind = a:num > 0 ? indent(l:num) : -s:sw() let ind = indent(l:i) + (!l:cont ? s:sw() : 0) let bL = 0 From 3b38947f2f90d8bfa1522ecb67856238f305e606 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Sun, 18 Sep 2016 16:19:47 -0700 Subject: [PATCH 08/34] prev --- indent/javascript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 2f09133a..30e64eb1 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -87,7 +87,7 @@ endfunction function s:iscontOne(i,num,cont) let [l:i, l:cont, l:num] = [a:i, a:cont, a:num ? a:num : 1] - let pind = a:num > 0 ? indent(l:num) : -s:sw() + let pind = a:num ? indent(l:num) : -s:sw() let ind = indent(l:i) + (!l:cont ? s:sw() : 0) let bL = 0 while l:i >= l:num && (!l:cont || ind > pind + s:sw()) From ff5f3f14418765b487a9071db8f7ff72946f1fe1 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Mon, 19 Sep 2016 01:17:29 -0700 Subject: [PATCH 09/34] fix concat bug --- indent/javascript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 30e64eb1..aee8e2c3 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -93,7 +93,7 @@ function s:iscontOne(i,num,cont) while l:i >= l:num && (!l:cont || ind > pind + s:sw()) if indent(l:i) < ind " first line always true for !cont, false for !!cont if s:OneScope(l:i,substitute(getline(l:i),':\@') ==# 'while' && s:GetPair(s:line_pre . '\C\\%>'.l:num-1.'l','\C\','bW',s:skip_expr,100) > 0 + if expand('') ==# 'while' && s:GetPair(s:line_pre . '\C\\%>'.(l:num-1).'l','\C\','bW',s:skip_expr,100) > 0 return 0 endif let bL += 1 From 1219b150b063df8979ab48a4a2e6f3bb6e502840 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Tue, 20 Sep 2016 19:20:01 -0700 Subject: [PATCH 10/34] small skip_func improvements (#637) this will improve performance depending on the file. I will try and clean it a little --- indent/javascript.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index aee8e2c3..3ec4abe6 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -48,11 +48,13 @@ let s:syng_comment = '\%(comment\|doc\)' " Expression used to check whether we should skip a match with searchpair(). let s:skip_expr = "synIDattr(synID(line('.'),col('.'),0),'name') =~? '".s:syng_strcom."'" function s:skip_func(lnum) - if !s:free || getline(line('.')) =~ '[''/"\\]' || search('`','nW',a:lnum) || search('\*\/','nW',a:lnum) + if !s:free || search('`','nW',a:lnum) || search('\*\/','nW',a:lnum) let s:free = !eval(s:skip_expr) + let s:looksyn = s:free ? line('.') : s:looksyn + return !s:free endif - let s:looksyn = s:free ? line('.') : s:looksyn - return !s:free + let s:looksyn = line('.') + return getline(line('.')) =~ '[''/"\\]' && eval(s:skip_expr) endfunction if has('reltime') From afbe2844ee39d0c01a7b27214262d817550ea0c8 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Tue, 20 Sep 2016 22:41:36 -0700 Subject: [PATCH 11/34] more minor optimizations (#638) --- indent/javascript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 3ec4abe6..67006e35 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -54,7 +54,7 @@ function s:skip_func(lnum) return !s:free endif let s:looksyn = line('.') - return getline(line('.')) =~ '[''/"\\]' && eval(s:skip_expr) + return (search('\/','nbW',line('.')) || search('[''"\\]','nW',line('.'))) && eval(s:skip_expr) endfunction if has('reltime') From a7225e4bd1882236c5a7db10aadcdfca1de3b352 Mon Sep 17 00:00:00 2001 From: Amadeus Demarzi Date: Thu, 22 Sep 2016 02:07:40 -0700 Subject: [PATCH 12/34] Fix jsGlobalNodeObjects and jsFuncCall priority Give jsGlobalNodeObjects a higher priority that can therefore be targeted if desired. --- syntax/javascript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/javascript.vim b/syntax/javascript.vim index 56e7c6d3..20b131b2 100644 --- a/syntax/javascript.vim +++ b/syntax/javascript.vim @@ -114,7 +114,7 @@ syntax match jsSwitchColon contained /:/ skipwhite skipempty nextgro " Keywords 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 JSON Math console document window Intl Collator DateTimeFormat NumberFormat syntax keyword jsGlobalNodeObjects module exports global process -syntax match jsGlobalNodeObjects /require/ contains=jsFuncCall +syntax match jsGlobalNodeObjects /require/ containedin=jsFuncCall syntax keyword jsExceptions Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError syntax keyword jsBuiltins decodeURI decodeURIComponent encodeURI encodeURIComponent eval isFinite isNaN parseFloat parseInt uneval " DISCUSS: How imporant is this, really? Perhaps it should be linked to an error because I assume the keywords are reserved? From d94ab71e2230896f0d5a30c3c812dcd4058cef3d Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Thu, 22 Sep 2016 21:28:57 -0700 Subject: [PATCH 13/34] optimize top scope indentation speed (#640) makes a huge difference when not in a 'scope'. avoids checking the whole file * improve helper --- indent/javascript.vim | 61 +++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 67006e35..fb500d7d 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -58,12 +58,12 @@ function s:skip_func(lnum) endfunction if has('reltime') - function s:GetPair(start,end,flags,skip,time) - return searchpair(a:start,'',a:end,a:flags,a:skip,max([prevnonblank(v:lnum) - 2000,0]),a:time) + function s:GetPair(start,end,flags,skip,time,...) + return searchpair(a:start,'',a:end,a:flags,a:skip,max([prevnonblank(v:lnum) - 2000,0] + a:000),a:time) endfunction else function s:GetPair(start,end,flags,...) - return searchpair(a:start,'',a:end,a:flags,0,max([prevnonblank(v:lnum) - 2000,0])) + return searchpair(a:start,'',a:end,a:flags,"line('.') < prevnonblank(v:lnum) - 2000 ? dummy : 0") endfunction endif @@ -88,14 +88,14 @@ function s:OneScope(lnum,text) endfunction function s:iscontOne(i,num,cont) - let [l:i, l:cont, l:num] = [a:i, a:cont, a:num ? a:num : 1] - let pind = a:num ? indent(l:num) : -s:sw() - let ind = indent(l:i) + (!l:cont ? s:sw() : 0) + let [l:i, l:cont, l:num] = [a:i, a:cont, a:num + !a:num] + let pind = a:num ? indent(l:num) : -s:W + let ind = indent(l:i) + (!l:cont * s:W) let bL = 0 - while l:i >= l:num && (!l:cont || ind > pind + s:sw()) + while l:i >= l:num && (!l:cont || ind > pind + s:W) if indent(l:i) < ind " first line always true for !cont, false for !!cont if s:OneScope(l:i,substitute(getline(l:i),':\@') ==# 'while' && s:GetPair(s:line_pre . '\C\\%>'.(l:num-1).'l','\C\','bW',s:skip_expr,100) > 0 + if expand('') ==# 'while' && s:GetPair(s:line_pre . '\C\','\C\','bW',s:skip_expr,100,l:num) > 0 return 0 endif let bL += 1 @@ -107,7 +107,7 @@ function s:iscontOne(i,num,cont) endif let l:i = s:PrevCodeLine(l:i - 1) endwhile - return bL * s:sw() + return bL * s:W endfunction " https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader @@ -136,7 +136,7 @@ function s:Balanced(lnum) while pos != -1 if synIDattr(synID(a:lnum,pos + 1,0),'name') !~? s:syng_strcom let idx = stridx('(){}[]', l:line[pos]) - if idx % 2 == 0 + if !(idx % 2) let open_{idx} += 1 else let open_{idx - 1} -= 1 @@ -147,7 +147,7 @@ function s:Balanced(lnum) endif let pos = match(l:line, '[][(){}]', pos + 1) endwhile - return (!open_4 + !open_2 + !open_0) - 2 + return !(open_4 || open_2 || open_0) endfunction function GetJavascriptIndent() @@ -181,46 +181,51 @@ function GetJavascriptIndent() " the containing paren, bracket, curly. Memoize, last lineNr either has the " same scope or starts a new one, unless if it closed a scope. - let [s:looksyn,s:free] = [v:lnum - 1,1] call cursor(v:lnum,1) - if b:js_cache[0] < v:lnum && b:js_cache[0] >= l:lnum && - \ (b:js_cache[0] > l:lnum || s:Balanced(l:lnum) > 0) - let num = b:js_cache[1] - elseif syns != '' && l:line[0] =~ '\s' - let pattern = syns =~? 'block' ? ['{','}'] : syns =~? 'jsparen' ? ['(',')'] : - \ syns =~? 'jsbracket'? ['\[','\]'] : ['[({[]','[])}]'] - let num = s:GetPair(pattern[0],pattern[1],'bW','s:skip_func(s:looksyn)',2000) + if getline(l:lnum) !~ '^\S' + let [s:looksyn,s:free] = [v:lnum - 1,1] + if b:js_cache[0] < v:lnum && b:js_cache[0] >= l:lnum && + \ (b:js_cache[0] > l:lnum || s:Balanced(l:lnum)) + let num = b:js_cache[1] + elseif syns != '' && l:line[0] =~ '\s' + let pattern = syns =~? 'block' ? ['{','}'] : syns =~? 'jsparen' ? ['(',')'] : + \ syns =~? 'jsbracket'? ['\[','\]'] : ['[({[]','[])}]'] + let num = s:GetPair(pattern[0],pattern[1],'bW','s:skip_func(s:looksyn)',2000) + else + let num = s:GetPair('[({[]','[])}]','bW','s:skip_func(s:looksyn)',2000) + endif else - let num = s:GetPair('[({[]','[])}]','bW','s:skip_func(s:looksyn)',2000) + let num = s:GetPair('[({[]','[])}]','bW',s:skip_expr,200,l:lnum) endif - let num = num > 0 ? num : 0 + let num = (num > 0) * num let b:js_cache = [v:lnum,num,line('.') == v:lnum ? b:js_cache[2] : col('.')] let l:line = substitute(l:line,s:line_pre,'','') if l:line =~ '^[])}]' - return indent(num) + return !!num * indent(num) endif call cursor(v:lnum,1) - if l:line =~# '^while\>' && s:GetPair(s:line_pre . '\C\\%>'.(num-!!num).'l','\C\','bW',s:skip_expr,100) > 0 + if l:line =~# '^while\>' && s:GetPair(s:line_pre . '\C\','\C\','bW',s:skip_expr,100,num) > 0 return indent(line('.')) endif + let s:W = s:sw() let pline = substitute(substitute(getline(l:lnum),s:expr_case,'\=repeat(" ",strlen(submatch(0)))',''), ':\@ 0 && search('\C\ Date: Fri, 23 Sep 2016 20:03:19 -0700 Subject: [PATCH 14/34] normalize header in vim and current, date (#642) Any issues with this? It doesn't rlly mean anything, just something to satisfy vim/dev --- indent/javascript.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index fb500d7d..ff4851ab 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -1,8 +1,8 @@ " Vim indent file " Language: Javascript -" Maintainer: vim-javascript community +" Maintainer: Chris Paul ( https://github.com/bounceme ) " URL: https://github.com/pangloss/vim-javascript -" Last Change: September 18, 2016 +" Last Change: September 23, 2016 " Only load this indent file when no other was loaded. if exists('b:did_indent') From fcdc1dcdb5256932330eb7bae16febbd43fb88d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Pr=C3=A9vost?= Date: Sat, 24 Sep 2016 19:29:46 -0400 Subject: [PATCH 15/34] Fix jsFlowTypeCustom regex to allow dots --- extras/flow.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/flow.vim b/extras/flow.vim index a1848830..028ea3fc 100644 --- a/extras/flow.vim +++ b/extras/flow.vim @@ -6,7 +6,7 @@ syntax region jsFlowParens contained matchgroup=jsFlowNoise start=/(/ syntax match jsFlowNoise contained /[:;,<>]/ syntax keyword jsFlowType contained boolean number string null void any mixed JSON array function object array bool class syntax keyword jsFlowTypeof contained typeof skipempty skipempty nextgroup=jsFlowTypeCustom,jsFlowType -syntax match jsFlowTypeCustom contained /\k*/ skipwhite skipempty nextgroup=jsFlowGroup +syntax match jsFlowTypeCustom contained /[0-9a-zA-Z_.]*/ skipwhite skipempty nextgroup=jsFlowGroup syntax region jsFlowGroup contained matchgroup=jsFlowNoise start=// contains=@jsFlowCluster syntax region jsFlowArrowArguments contained matchgroup=jsFlowNoise start=/(/ end=/)\%(\s*=>\)\@=/ oneline skipwhite skipempty nextgroup=jsFlowArrow contains=@jsFlowCluster syntax match jsFlowArrow contained /=>/ skipwhite skipempty nextgroup=jsFlowType,jsFlowTypeCustom,jsFlowParens From ce7c06c390a1ec6b8b770d2813232b3fe41c02dd Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Sun, 25 Sep 2016 00:04:30 -0700 Subject: [PATCH 16/34] simplify comments --- indent/javascript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index ff4851ab..d649c087 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -163,7 +163,7 @@ function GetJavascriptIndent() \ l:line !~ '^\s*[/*]' && syns =~? s:syng_comment return -1 endif - if l:line !~ '^\%(\/\*\|\s*\/\/\)' && syns =~? s:syng_comment + if l:line =~ '^\s*\*' && syns =~? s:syng_comment return cindent(v:lnum) endif let l:lnum = s:PrevCodeLine(v:lnum - 1) From 5453eb09dc7f79ca1aa49fd8dc9451d068a7e345 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Sun, 25 Sep 2016 00:27:20 -0700 Subject: [PATCH 17/34] more string/comment cleaning --- indent/javascript.vim | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index d649c087..a092d9cf 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -159,13 +159,15 @@ function GetJavascriptIndent() let syns = synIDattr(synID(v:lnum, 1, 0), 'name') " start with strings,comments,etc. - if l:line !~ '^[''"]' && syns =~? '\%(string\|template\)' || - \ l:line !~ '^\s*[/*]' && syns =~? s:syng_comment + if syns =~? s:syng_comment + if l:line =~ '^\s*\*' + return cindent(v:lnum) + elseif l:line !~ '^\s*\/' + return -1 + endif + elseif syns =~? '\%(string\|template\)' && l:line !~ '^[''"]' return -1 endif - if l:line =~ '^\s*\*' && syns =~? s:syng_comment - return cindent(v:lnum) - endif let l:lnum = s:PrevCodeLine(v:lnum - 1) if l:lnum == 0 return 0 From 02c8c644c306eb3675fdf9d0b556babd39e84d65 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Sun, 25 Sep 2016 00:50:34 -0700 Subject: [PATCH 18/34] remove rar --- indent/javascript.vim | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index a092d9cf..665a558b 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -42,9 +42,6 @@ let s:expr_case = s:line_pre . '\%(\%(case\>.\+\)\|default\)\s*:\C' " Regex of syntax group names that are or delimit string or are comments. let s:syng_strcom = '\%(s\%(tring\|pecial\)\|comment\|regex\|doc\|template\)' -" Regex of syntax group names that are strings or documentation. -let s:syng_comment = '\%(comment\|doc\)' - " Expression used to check whether we should skip a match with searchpair(). let s:skip_expr = "synIDattr(synID(line('.'),col('.'),0),'name') =~? '".s:syng_strcom."'" function s:skip_func(lnum) @@ -159,7 +156,7 @@ function GetJavascriptIndent() let syns = synIDattr(synID(v:lnum, 1, 0), 'name') " start with strings,comments,etc. - if syns =~? s:syng_comment + if syns =~? '\%(comment\|doc\)' if l:line =~ '^\s*\*' return cindent(v:lnum) elseif l:line !~ '^\s*\/' From dc678406de4352fd03c49dfb2b0dc32733bd1ce9 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Sun, 25 Sep 2016 13:37:41 -0700 Subject: [PATCH 19/34] more optimization (#646) --- indent/javascript.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 665a558b..c6d5e110 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -178,6 +178,8 @@ function GetJavascriptIndent() return ind endif + let l:line = substitute(l:line,s:line_pre,'','') + " the containing paren, bracket, curly. Memoize, last lineNr either has the " same scope or starts a new one, unless if it closed a scope. call cursor(v:lnum,1) @@ -186,7 +188,10 @@ function GetJavascriptIndent() if b:js_cache[0] < v:lnum && b:js_cache[0] >= l:lnum && \ (b:js_cache[0] > l:lnum || s:Balanced(l:lnum)) let num = b:js_cache[1] - elseif syns != '' && l:line[0] =~ '\s' + elseif l:line =~ '^[])}]' + let id = stridx('])}',l:line[0]) + let num = s:GetPair(escape('[({'[id],'['), escape('])}'[id],']'),'bW','s:skip_func(s:looksyn)',2000) + elseif syns != '' && getline(v:lnum)[0] =~ '\s' let pattern = syns =~? 'block' ? ['{','}'] : syns =~? 'jsparen' ? ['(',')'] : \ syns =~? 'jsbracket'? ['\[','\]'] : ['[({[]','[])}]'] let num = s:GetPair(pattern[0],pattern[1],'bW','s:skip_func(s:looksyn)',2000) @@ -200,7 +205,6 @@ function GetJavascriptIndent() let num = (num > 0) * num let b:js_cache = [v:lnum,num,line('.') == v:lnum ? b:js_cache[2] : col('.')] - let l:line = substitute(l:line,s:line_pre,'','') if l:line =~ '^[])}]' return !!num * indent(num) endif From 92f1d98dbe740bdbb26b9595dab32b16320c641a Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Sun, 25 Sep 2016 20:09:43 -0700 Subject: [PATCH 20/34] switch accuracy and performance (#647) --- indent/javascript.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index c6d5e110..e89e493d 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -38,7 +38,7 @@ else endif let s:line_pre = '^\s*\%(\%(\%(\/\*.\{-}\)\=\*\+\/\s*\)\=\)\@>' -let s:expr_case = s:line_pre . '\%(\%(case\>.\+\)\|default\)\s*:\C' +let s:expr_case = '\<\%(\%(case\>.\+\)\|default\)\s*:\C' " Regex of syntax group names that are or delimit string or are comments. let s:syng_strcom = '\%(s\%(tring\|pecial\)\|comment\|regex\|doc\|template\)' @@ -170,7 +170,9 @@ function GetJavascriptIndent() return 0 endif - if l:line =~# s:expr_case + let l:line = substitute(l:line,s:line_pre,'','') + + if l:line =~# '^' . s:expr_case let cpo_switch = &cpo set cpo+=% let ind = cindent(v:lnum) @@ -178,8 +180,6 @@ function GetJavascriptIndent() return ind endif - let l:line = substitute(l:line,s:line_pre,'','') - " the containing paren, bracket, curly. Memoize, last lineNr either has the " same scope or starts a new one, unless if it closed a scope. call cursor(v:lnum,1) From 6ecbda3b318f1e7178a4a59f4702af1fa9ce05e4 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Mon, 26 Sep 2016 18:46:05 -0700 Subject: [PATCH 21/34] clean isBlock (#648) --- indent/javascript.vim | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index e89e493d..f38b7183 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -109,9 +109,10 @@ endfunction " https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader function s:IsBlock() - return getline(line('.'))[col('.')-1] == '{' && !search( - \ '\C\%(\\|\*\@') !~# + \ '\<\%(var\|const\|let\|import\|export\|yield\|de\%(fault\|lete\)\|void\|t\%(ypeof\|hrow\)\|new\|in\%(stanceof\)\=\)\>' + \ : !search('\C\%([-=~!<*+,./?^%|&\[(]\|=\@\)\_s*\%#','nbW') && + \ (search(s:expr_case . '\_s*\%#','nbW') || !search('[{:]\_s*\%#','bW') || s:IsBlock())) endfunction " Find line above 'lnum' that isn't empty, in a comment, or in a string. From d6b2fd599fd7e03952e854acfc1c4cee0c0b1da3 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Mon, 26 Sep 2016 19:20:31 -0700 Subject: [PATCH 22/34] change regex case --- indent/javascript.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index f38b7183..d3e17d10 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -2,7 +2,7 @@ " Language: Javascript " Maintainer: Chris Paul ( https://github.com/bounceme ) " URL: https://github.com/pangloss/vim-javascript -" Last Change: September 23, 2016 +" Last Change: September 26, 2016 " Only load this indent file when no other was loaded. if exists('b:did_indent') @@ -109,9 +109,9 @@ endfunction " https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader function s:IsBlock() - return getline(line('.'))[col('.')-1] == '{' && !search('\') !~# + return getline(line('.'))[col('.')-1] == '{' && !search('\C\') !~# \ '\<\%(var\|const\|let\|import\|export\|yield\|de\%(fault\|lete\)\|void\|t\%(ypeof\|hrow\)\|new\|in\%(stanceof\)\=\)\>' - \ : !search('\C\%([-=~!<*+,./?^%|&\[(]\|=\@\)\_s*\%#','nbW') && + \ : !search('\%([-=~!<*+,./?^%|&\[(]\|=\@\)\_s*\%#','nbW') && \ (search(s:expr_case . '\_s*\%#','nbW') || !search('[{:]\_s*\%#','bW') || s:IsBlock())) endfunction From 77c4ae620420a3e9f88667b7df334ebdde2485ea Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Tue, 27 Sep 2016 16:28:14 -0700 Subject: [PATCH 23/34] better line cleaning (#649) --- indent/javascript.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index d3e17d10..b8679f68 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -75,7 +75,7 @@ if !exists('g:javascript_continuation') endif let g:javascript_opfirst = '^' . g:javascript_opfirst -let g:javascript_continuation .= s:line_term +let g:javascript_continuation .= '$' function s:OneScope(lnum,text) return cursor(a:lnum, match(' ' . a:text, '\%(\\)' . s:line_term)) > -1 || @@ -215,7 +215,7 @@ function GetJavascriptIndent() endif let s:W = s:sw() - let pline = substitute(substitute(getline(l:lnum),s:expr_case,'\=repeat(" ",strlen(submatch(0)))',''), ':\@ 0 && search('\C\ Date: Tue, 27 Sep 2016 17:20:38 -0700 Subject: [PATCH 24/34] more regex line endings --- indent/javascript.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index b8679f68..cc084535 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -78,8 +78,8 @@ let g:javascript_opfirst = '^' . g:javascript_opfirst let g:javascript_continuation .= '$' function s:OneScope(lnum,text) - return cursor(a:lnum, match(' ' . a:text, '\%(\\)' . s:line_term)) > -1 || - \ cursor(a:lnum, match(' ' . a:text, ')' . s:line_term)) > -1 && + return cursor(a:lnum, match(' ' . a:text, '\%(\\)' . '$')) > -1 || + \ cursor(a:lnum, match(' ' . a:text, ')' . '$')) > -1 && \ s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0 && \ search('\C\<\%(for\%(\_s\+each\)\=\|if\|let\|w\%(hile\|ith\)\)\_s*\%#','bW') endfunction @@ -91,7 +91,7 @@ function s:iscontOne(i,num,cont) let bL = 0 while l:i >= l:num && (!l:cont || ind > pind + s:W) if indent(l:i) < ind " first line always true for !cont, false for !!cont - if s:OneScope(l:i,substitute(getline(l:i),':\@') ==# 'while' && s:GetPair(s:line_pre . '\C\','\C\','bW',s:skip_expr,100,l:num) > 0 return 0 endif From 88111be6a7c50c63b36e3dbe8c110df0951ec473 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Tue, 27 Sep 2016 17:30:28 -0700 Subject: [PATCH 25/34] factor out --- indent/javascript.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index cc084535..e9373299 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -66,6 +66,10 @@ endif let s:line_term = '\s*\%(\%(\/\%(\%(\*.\{-}\*\/\)\|\%(\*\+\)\)\)\s*\)\=$' +function s:Trimline(ln) + return substitute(substitute(getline(a:ln),':\@,?^%|*&]\|\/[^/*]\|\([-.:+]\)\1\@!\|=>\@!\|in\%(stanceof\)\=\>\)' @@ -91,7 +95,7 @@ function s:iscontOne(i,num,cont) let bL = 0 while l:i >= l:num && (!l:cont || ind > pind + s:W) if indent(l:i) < ind " first line always true for !cont, false for !!cont - if s:OneScope(l:i,substitute(substitute(getline(l:i),':\@') ==# 'while' && s:GetPair(s:line_pre . '\C\','\C\','bW',s:skip_expr,100,l:num) > 0 return 0 endif @@ -215,7 +219,7 @@ function GetJavascriptIndent() endif let s:W = s:sw() - let pline = substitute(substitute(getline(l:lnum),':\@ 0 && search('\C\ Date: Tue, 27 Sep 2016 19:29:41 -0700 Subject: [PATCH 26/34] small regex changes --- indent/javascript.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index e9373299..acecc6c6 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -82,8 +82,8 @@ let g:javascript_opfirst = '^' . g:javascript_opfirst let g:javascript_continuation .= '$' function s:OneScope(lnum,text) - return cursor(a:lnum, match(' ' . a:text, '\%(\\)' . '$')) > -1 || - \ cursor(a:lnum, match(' ' . a:text, ')' . '$')) > -1 && + return cursor(a:lnum, match(' ' . a:text, '\%(\\)$')) > -1 || + \ cursor(a:lnum, match(' ' . a:text, ')$')) > -1 && \ s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0 && \ search('\C\<\%(for\%(\_s\+each\)\=\|if\|let\|w\%(hile\|ith\)\)\_s*\%#','bW') endfunction @@ -114,7 +114,7 @@ endfunction " https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader function s:IsBlock() return getline(line('.'))[col('.')-1] == '{' && !search('\C\') !~# - \ '\<\%(var\|const\|let\|import\|export\|yield\|de\%(fault\|lete\)\|void\|t\%(ypeof\|hrow\)\|new\|in\%(stanceof\)\=\)\>' + \ '\<\%(var\|const\|let\|\%(im\|ex\)port\|yield\|de\%(fault\|lete\)\|void\|t\%(ypeof\|hrow\)\|new\|in\%(stanceof\)\=\)\>' \ : !search('\%([-=~!<*+,./?^%|&\[(]\|=\@\)\_s*\%#','nbW') && \ (search(s:expr_case . '\_s*\%#','nbW') || !search('[{:]\_s*\%#','bW') || s:IsBlock())) endfunction From 833d6ec12724633c323d5d1dab0a4a8fc2e25393 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Tue, 27 Sep 2016 21:42:04 -0700 Subject: [PATCH 27/34] short circuit cache check --- indent/javascript.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index acecc6c6..60f89efa 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -208,11 +208,11 @@ function GetJavascriptIndent() endif let num = (num > 0) * num - let b:js_cache = [v:lnum,num,line('.') == v:lnum ? b:js_cache[2] : col('.')] - if l:line =~ '^[])}]' return !!num * indent(num) endif + let b:js_cache = [v:lnum,num,line('.') == v:lnum ? b:js_cache[2] : col('.')] + call cursor(v:lnum,1) if l:line =~# '^while\>' && s:GetPair(s:line_pre . '\C\','\C\','bW',s:skip_expr,100,num) > 0 return indent(line('.')) From c76d65bd50907fe76a0008371792b821408c1bff Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Tue, 27 Sep 2016 22:41:07 -0700 Subject: [PATCH 28/34] fail earlier --- indent/javascript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 60f89efa..8da6c6a1 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -190,7 +190,7 @@ function GetJavascriptIndent() call cursor(v:lnum,1) if getline(l:lnum) !~ '^\S' let [s:looksyn,s:free] = [v:lnum - 1,1] - if b:js_cache[0] < v:lnum && b:js_cache[0] >= l:lnum && + if b:js_cache[0] >= l:lnum && b:js_cache[0] < v:lnum && \ (b:js_cache[0] > l:lnum || s:Balanced(l:lnum)) let num = b:js_cache[1] elseif l:line =~ '^[])}]' From cd4ace412688995e6c6eddc95c3ee3ed5b7dd495 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Wed, 28 Sep 2016 08:10:30 -0700 Subject: [PATCH 29/34] wrap for magic (#651) --- indent/javascript.vim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/indent/javascript.vim b/indent/javascript.vim index 8da6c6a1..7bbee713 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -153,6 +153,9 @@ function s:Balanced(lnum) endfunction function GetJavascriptIndent() + try + let save_magic = &magic + set magic if !exists('b:js_cache') let b:js_cache = [0,0,0] endif @@ -236,6 +239,9 @@ function GetJavascriptIndent() return indent(num) + s:W + switch_offset + bL endif return bL + finally + let &magic = save_magic + endtry endfunction From 572b98d12b97b126a739bac539f4ba4be3365578 Mon Sep 17 00:00:00 2001 From: Amadeus Demarzi Date: Wed, 28 Sep 2016 11:11:41 -0700 Subject: [PATCH 30/34] Fixing another funky comment situation --- syntax/javascript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/javascript.vim b/syntax/javascript.vim index 20b131b2..b4ce555b 100644 --- a/syntax/javascript.vim +++ b/syntax/javascript.vim @@ -171,7 +171,7 @@ syntax match jsArrowFuncArgs /\k\+\s*\%(=>\)\@=/ skipwhite contains=jsFuncArg syntax match jsArrowFuncArgs /([^()]*)\s*\(=>\)\@=/ contains=jsFuncArgs skipempty skipwhite nextgroup=jsArrowFunction extend exe 'syntax match jsFunction /\/ skipwhite skipempty nextgroup=jsGenerator,jsFuncName,jsFuncArgs skipwhite '.(exists('g:javascript_conceal_function') ? 'conceal cchar='.g:javascript_conceal_function : '') -exe 'syntax match jsArrowFunction /=>/ skipwhite skipempty nextgroup=jsFuncBlock contains=jsFuncBraces '.(exists('g:javascript_conceal_arrow_function') ? 'conceal cchar='.g:javascript_conceal_arrow_function : '') +exe 'syntax match jsArrowFunction /=>/ skipwhite skipempty nextgroup=jsFuncBlock,jsCommentFunction '.(exists('g:javascript_conceal_arrow_function') ? 'conceal cchar='.g:javascript_conceal_arrow_function : '') " Classes syntax keyword jsClassKeywords contained extends class From ecc674fc517e1286b023e2dad1112f37b0fcfb99 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Fri, 30 Sep 2016 21:59:19 -0700 Subject: [PATCH 31/34] flow generic classes (#652) --- indent/javascript.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 7bbee713..e64b454e 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -115,8 +115,9 @@ endfunction function s:IsBlock() return getline(line('.'))[col('.')-1] == '{' && !search('\C\') !~# \ '\<\%(var\|const\|let\|\%(im\|ex\)port\|yield\|de\%(fault\|lete\)\|void\|t\%(ypeof\|hrow\)\|new\|in\%(stanceof\)\=\)\>' - \ : !search('\%([-=~!<*+,./?^%|&\[(]\|=\@\)\_s*\%#','nbW') && - \ (search(s:expr_case . '\_s*\%#','nbW') || !search('[{:]\_s*\%#','bW') || s:IsBlock())) + \ : !search('[-=~!<*+,./?^%|&\[(]\_s*\%#','nbW') && (search('>\_s*\%#','bW') ? search('=\%#','bW') || + \ synIDattr(synID(line('.'),col('.'),0),'name') =~? 'flownoise' : + \ search(s:expr_case . '\_s*\%#','nbW') || !search('[{:]\_s*\%#','bW') || s:IsBlock())) endfunction " Find line above 'lnum' that isn't empty, in a comment, or in a string. From f64dae7106df808f4654c5f88ea019d274197b0e Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Mon, 3 Oct 2016 13:57:35 -0700 Subject: [PATCH 32/34] for await indent (#656) #654 --- indent/javascript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index e64b454e..984e8957 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -85,7 +85,7 @@ function s:OneScope(lnum,text) return cursor(a:lnum, match(' ' . a:text, '\%(\\)$')) > -1 || \ cursor(a:lnum, match(' ' . a:text, ')$')) > -1 && \ s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0 && - \ search('\C\<\%(for\%(\_s\+each\)\=\|if\|let\|w\%(hile\|ith\)\)\_s*\%#','bW') + \ search('\C\<\%(for\%(\_s\+\%(await\|each\)\)\=\|if\|let\|w\%(hile\|ith\)\)\_s*\%#','bW') endfunction function s:iscontOne(i,num,cont) From f674cbab548f1f8a05c1654f441b13fefc282d80 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Tue, 4 Oct 2016 21:04:00 -0700 Subject: [PATCH 33/34] case label needs non whitespace- (#658) can otherwise be a object key --- indent/javascript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 984e8957..1f1786c3 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -38,7 +38,7 @@ else endif let s:line_pre = '^\s*\%(\%(\%(\/\*.\{-}\)\=\*\+\/\s*\)\=\)\@>' -let s:expr_case = '\<\%(\%(case\>.\+\)\|default\)\s*:\C' +let s:expr_case = '\<\%(\%(case\>\s*\S.\{-}\)\|default\)\s*:\C' " Regex of syntax group names that are or delimit string or are comments. let s:syng_strcom = '\%(s\%(tring\|pecial\)\|comment\|regex\|doc\|template\)' From fbc82e169e3c7c3640acff3d6bfb6ef9aaceef85 Mon Sep 17 00:00:00 2001 From: "Tom X. Tobin" Date: Wed, 5 Oct 2016 16:44:55 -0400 Subject: [PATCH 34/34] Fix JSDoc highlighting for optional parameters Fixes #574. --- extras/jsdoc.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/jsdoc.vim b/extras/jsdoc.vim index fff64f89..645d55a3 100644 --- a/extras/jsdoc.vim +++ b/extras/jsdoc.vim @@ -18,7 +18,7 @@ syntax region jsDocTypeRecord contained start=/{/ end=/}/ contains=jsDocTypeRe syntax region jsDocTypeRecord contained start=/\[/ end=/\]/ contains=jsDocTypeRecord extend syntax region jsDocTypeNoParam contained start="{" end="}" oneline syntax match jsDocTypeNoParam contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" -syntax match jsDocParam contained "\%(#\|\$\|-\|'\|\"\|{.\{-}}\|\w\|\.\|:\|\/\|\[.{-}]\|=\)\+" +syntax match jsDocParam contained "\%(#\|\$\|-\|'\|\"\|{.\{-}}\|\w\|\.\|:\|\/\|\[.\{-}]\|=\)\+" syntax region jsDocSeeTag contained matchgroup=jsDocSeeTag start="{" end="}" contains=jsDocTags if version >= 508 || !exists("did_javascript_syn_inits")