From 19391bed6087584b26bc41f386c83beb0cab679f Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Wed, 12 Oct 2016 08:57:31 -0700 Subject: [PATCH 01/10] react/jsx interpolated expressions --- indent/javascript.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/indent/javascript.vim b/indent/javascript.vim index 9720c7f8..35853590 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -130,6 +130,9 @@ endfunction " https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader function s:IsBlock() if getline(line('.'))[col('.')-1] == '{' + if synIDattr(synID(line('.'),col('.')-1,0),'name') =~? '\%(xml\|jsx\)' + return 1 + endif if search('\C\ Date: Wed, 12 Oct 2016 10:04:19 -0700 Subject: [PATCH 02/10] refactor isBlock --- indent/javascript.vim | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 35853590..5cfc6b3f 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -130,22 +130,30 @@ endfunction " https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader function s:IsBlock() if getline(line('.'))[col('.')-1] == '{' - if synIDattr(synID(line('.'),col('.')-1,0),'name') =~? '\%(xml\|jsx\)' - return 1 - endif - if search('\C\') ==# 'return' + return 0 + endif return expand('') !~# \ '^\%(var\|const\|let\|\%(im\|ex\)port\|yield\|de\%(fault\|lete\)\|void\|t\%(ypeof\|hrow\)\|new\|in\%(stanceof\)\=\)$' elseif char == '>' - return search('=\%#','bW') || synIDattr(synID(line('.'),col('.'),0),'name') =~? 'flownoise' + return prechar == '=' || synIDattr(synID(line('.'),col('.'),0),'name') =~? 'flownoise' elseif char == ':' return strpart(getline(line('.')),0,col('.')) =~# s:expr_case . '$' elseif char == '{' From f4b6282d777dc3b2ce4fbb08c48f380c288a59ce Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Wed, 12 Oct 2016 14:43:57 -0700 Subject: [PATCH 03/10] Update javascript.vim --- indent/javascript.vim | 2 -- 1 file changed, 2 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 5cfc6b3f..0f2ba3f1 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -156,8 +156,6 @@ function s:IsBlock() return prechar == '=' || synIDattr(synID(line('.'),col('.'),0),'name') =~? 'flownoise' elseif char == ':' return strpart(getline(line('.')),0,col('.')) =~# s:expr_case . '$' - elseif char == '{' - return s:IsBlock() else return char !~# '[-=~!<*+,./?^%|&\[(]' endif From 6e232c6d24febd4fc7824d177585de9dec3547d1 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Wed, 12 Oct 2016 15:24:57 -0700 Subject: [PATCH 04/10] Update javascript.vim --- indent/javascript.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 0f2ba3f1..a9ba8dd2 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -139,8 +139,7 @@ function s:IsBlock() return char != '{' endif if char == '/' && prechar == '*' && syn =~? 'comment' - call searchpair('\/\*','','\*\/','bW') - if !search('\S','bW') + if !(search('\/\*','bW') && search('\S','bW')) return 1 endif let char = getline(line('.'))[col('.')-1] From 943c6f8421fcd3933aa37665d622fc943612c7da Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Wed, 12 Oct 2016 15:46:52 -0700 Subject: [PATCH 05/10] 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 a9ba8dd2..32a3e540 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -156,7 +156,7 @@ function s:IsBlock() elseif char == ':' return strpart(getline(line('.')),0,col('.')) =~# s:expr_case . '$' else - return char !~# '[-=~!<*+,./?^%|&\[(]' + return char !~# '[-=~!<*+,/?^%|&([]' endif else return 1 From b99623edcf79eb31b3e0372616c2a27ed8ae6fa3 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Wed, 12 Oct 2016 15:56:02 -0700 Subject: [PATCH 06/10] 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 32a3e540..ff09d459 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -150,7 +150,7 @@ function s:IsBlock() return 0 endif return expand('') !~# - \ '^\%(var\|const\|let\|\%(im\|ex\)port\|yield\|de\%(fault\|lete\)\|void\|t\%(ypeof\|hrow\)\|new\|in\%(stanceof\)\=\)$' + \ '^\%(var\|const\|let\|import\|export\|yield\|de\%(fault\|lete\)\|void\|t\%(ypeof\|hrow\)\|new\|in\%(stanceof\)\=\)$' elseif char == '>' return prechar == '=' || synIDattr(synID(line('.'),col('.'),0),'name') =~? 'flownoise' elseif char == ':' From 012b6d30a2c8a20559a73b5b11f5a6e6a058be57 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Wed, 12 Oct 2016 19:51:27 -0700 Subject: [PATCH 07/10] Update javascript.vim --- indent/javascript.vim | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index ff09d459..f5c263cd 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -132,27 +132,26 @@ function s:IsBlock() if getline(line('.'))[col('.')-1] == '{' let l:ln = line('.') if search('\S','bW') - let syn = synIDattr(synID(line('.'),col('.'),0),'name') let char = getline(line('.'))[col('.')-1] let prechar = getline(line('.'))[col('.')-2] - if syn =~? '\%(xml\|jsx\)' - return char != '{' - endif - if char == '/' && prechar == '*' && syn =~? 'comment' + if char == '/' && prechar == '*' && synIDattr(synID(line('.'),col('.'),0),'name') =~? 'comment' if !(search('\/\*','bW') && search('\S','bW')) return 1 endif let char = getline(line('.'))[col('.')-1] let prechar = getline(line('.'))[col('.')-2] endif - if char =~# '\l' + let syn = synIDattr(synID(line('.'),col('.')-1,0),'name') + if syn =~? '\%(xml\|jsx\)' + return char != '{' + elseif char =~# '\l' if line('.') == l:ln && expand('') ==# 'return' return 0 endif return expand('') !~# \ '^\%(var\|const\|let\|import\|export\|yield\|de\%(fault\|lete\)\|void\|t\%(ypeof\|hrow\)\|new\|in\%(stanceof\)\=\)$' elseif char == '>' - return prechar == '=' || synIDattr(synID(line('.'),col('.'),0),'name') =~? 'flownoise' + return prechar == '=' || syn =~? 'flow' elseif char == ':' return strpart(getline(line('.')),0,col('.')) =~# s:expr_case . '$' else From 8d7420b699e9478514cff09f1c14e6b159a5fa8a Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Wed, 12 Oct 2016 20:19:43 -0700 Subject: [PATCH 08/10] 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 f5c263cd..347d18f7 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -151,7 +151,7 @@ function s:IsBlock() return expand('') !~# \ '^\%(var\|const\|let\|import\|export\|yield\|de\%(fault\|lete\)\|void\|t\%(ypeof\|hrow\)\|new\|in\%(stanceof\)\=\)$' elseif char == '>' - return prechar == '=' || syn =~? 'flow' + return prechar == '=' || syn ==? 'jsflowclassgroup' elseif char == ':' return strpart(getline(line('.')),0,col('.')) =~# s:expr_case . '$' else From d88e05be64060c1215a9d6c723653b67a99683a2 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Wed, 12 Oct 2016 21:01:14 -0700 Subject: [PATCH 09/10] Update javascript.vim --- indent/javascript.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 347d18f7..ef307273 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -38,7 +38,6 @@ else endif let s:line_pre = '^\s*\%(\%(\%(\/\*.\{-}\)\=\*\+\/\s*\)\=\)\@>' -let s:line_term = '\s*\%(\%(\/\%(\%(\*.\{-}\*\/\)\|\%(\*\+\)\)\)\s*\)\=$' let s:expr_case = '\<\%(\%(case\>\s*\S.\{-}\)\|default\)\s*:\C' " Regex of syntax group names that are or delimit string or are comments. @@ -151,7 +150,7 @@ function s:IsBlock() return expand('') !~# \ '^\%(var\|const\|let\|import\|export\|yield\|de\%(fault\|lete\)\|void\|t\%(ypeof\|hrow\)\|new\|in\%(stanceof\)\=\)$' elseif char == '>' - return prechar == '=' || syn ==? 'jsflowclassgroup' + return prechar == '=' || syn =~? '^jsflow' elseif char == ':' return strpart(getline(line('.')),0,col('.')) =~# s:expr_case . '$' else From 20f274d0e87d6a8808816fbe90afecd91202c885 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Wed, 12 Oct 2016 21:11:35 -0700 Subject: [PATCH 10/10] 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 ef307273..446b4343 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: October 9, 2016 +" Last Change: October 12, 2016 " Only load this indent file when no other was loaded. if exists('b:did_indent')