mirror of
https://github.com/chenasraf/vim-matchup.git
synced 2026-05-18 01:38:57 +00:00
Add in_comment_or_string for better performance
(used in default skip). Also, fix cursor position for in_syntax.
This commit is contained in:
@@ -1154,8 +1154,7 @@ function! matchup#delim#skip(...) " {{{1
|
||||
endif
|
||||
|
||||
if empty(get(b:, 'matchup_delim_skip', ''))
|
||||
return matchup#util#in_comment(l:lnum, l:cnum)
|
||||
\ || matchup#util#in_string(l:lnum, l:cnum)
|
||||
return matchup#util#in_comment_or_string(l:lnum, l:cnum)
|
||||
endif
|
||||
|
||||
let s:eff_curpos = [l:lnum, l:cnum]
|
||||
|
||||
@@ -20,29 +20,29 @@ endfunction
|
||||
|
||||
" }}}1
|
||||
function! matchup#util#in_comment(...) " {{{1
|
||||
return call('matchup#util#in_syntax', ['Comment'] + a:000)
|
||||
return call('matchup#util#in_syntax', ['^Comment$'] + a:000)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
function! matchup#util#in_string(...) " {{{1
|
||||
return call('matchup#util#in_syntax', ['String'] + a:000)
|
||||
return call('matchup#util#in_syntax', ['^String$'] + a:000)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
function! matchup#util#in_comment_or_string(...) " {{{1
|
||||
return call('matchup#util#in_syntax',
|
||||
\ ['^\%(String\|Comment\)$'] + a:000)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
function! matchup#util#in_syntax(name, ...) " {{{1
|
||||
" usage: matchup#util#in_syntax(name, [line, col])
|
||||
|
||||
" get position and correct it if necessary
|
||||
let l:pos = a:0 > 0 ? [a:1, a:2] : [line('.'), col('.')]
|
||||
if mode() ==# 'i'
|
||||
let l:pos[1] -= 1
|
||||
endif
|
||||
call map(l:pos, 'max([v:val, 1])')
|
||||
|
||||
" check syntax at position
|
||||
let l:syn = map(synstack(l:pos[0], l:pos[1]),
|
||||
\ "synIDattr(synIDtrans(v:val), 'name')")
|
||||
return match(l:syn, '^' . a:name) >= 0
|
||||
return match(l:syn, a:name) >= 0
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
|
||||
Reference in New Issue
Block a user