@@ -129,13 +129,31 @@ endfunction
129129
130130" https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader
131131function s: IsBlock ()
132- return getline (line (' .' ))[col (' .' )-1 ] == ' {' && ! search (' \C\<return\s*\%#' ,' nbW' ) &&
133- \ (! search (' \*\/\_s*\%#' ,' bW' ) || synIDattr (synID (line (' .' ),col (' .' ),0 ),' name' ) = ~? ' comment' &&
134- \ searchpair (' \/\*' ,' ' ,' \*\/' ,' bW' )) && (search (' \l\_s*\%#' ,' bW' ) ? expand (' <cword>' ) !~#
135- \ ' \<\%(var\|const\|let\|\%(im\|ex\)port\|yield\|de\%(fault\|lete\)\|void\|t\%(ypeof\|hrow\)\|new\|in\%(stanceof\)\=\)\>'
136- \ : ! search (' [-=~!<*+,./?^%|&\[(]\_s*\%#' ,' nbW' ) && (search (' >\_s*\%#' ,' bW' ) ? search (' =\%#' ,' bW' ) ||
137- \ synIDattr (synID (line (' .' ),col (' .' ),0 ),' name' ) = ~? ' flownoise' :
138- \ search (s: expr_case . ' \_s*\%#' ,' nbW' ) || ! search (' [{:]\_s*\%#' ,' bW' ) || s: IsBlock ()))
132+ if getline (line (' .' ))[col (' .' )-1 ] == ' {'
133+ if search (' \C\<return\s*\%#' ,' nbW' )
134+ return 0
135+ endif
136+ if search (' \*\/\_s*\%#' ,' bW' ) && synIDattr (synID (line (' .' ),col (' .' ),0 ),' name' ) = ~? ' comment'
137+ call searchpair (' \/\*' ,' ' ,' \*\/' ,' bW' )
138+ endif
139+ if search (' \S' ,' bW' )
140+ let char = getline (line (' .' ))[col (' .' )-1 ]
141+ if char = ~# ' \l'
142+ return expand (' <cword>' ) !~#
143+ \ ' \<\%(var\|const\|let\|\%(im\|ex\)port\|yield\|de\%(fault\|lete\)\|void\|t\%(ypeof\|hrow\)\|new\|in\%(stanceof\)\=\)\>'
144+ elseif char == ' >'
145+ return search (' =\%#' ,' bW' ) || synIDattr (synID (line (' .' ),col (' .' ),0 ),' name' ) = ~? ' flownoise'
146+ elseif char == ' :'
147+ return strpart (getline (line (' .' )),0 ,col (' .' )) = ~# s: expr_case . ' $'
148+ elseif char == ' {'
149+ return s: IsBlock ()
150+ else
151+ return char !~# ' [-=~!<*+,./?^%|&\[(]'
152+ endif
153+ else
154+ return 1
155+ endif
156+ endif
139157endfunction
140158
141159" Find line above 'lnum' that isn't empty, in a comment, or in a string.
0 commit comments