Add option for stopline tolerance (#386)
This commit is contained in:
parent
e3972d8aad
commit
2fd3a4ba96
@ -7,10 +7,13 @@
|
|||||||
function! vimtex#delim#init_options() " {{{1
|
function! vimtex#delim#init_options() " {{{1
|
||||||
call vimtex#util#set_default('g:vimtex_delim_toggle_mod_list',
|
call vimtex#util#set_default('g:vimtex_delim_toggle_mod_list',
|
||||||
\ [['\left', '\right']])
|
\ [['\left', '\right']])
|
||||||
|
call vimtex#util#set_default('g:vimtex_delim_stopline', 500)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
function! vimtex#delim#init_script() " {{{1
|
function! vimtex#delim#init_script() " {{{1
|
||||||
|
let s:stopline = g:vimtex_delim_stopline
|
||||||
|
|
||||||
let s:delims = {}
|
let s:delims = {}
|
||||||
let s:re = {}
|
let s:re = {}
|
||||||
|
|
||||||
@ -407,9 +410,9 @@ function! s:get_delim(direction, type, side) " {{{1
|
|||||||
"
|
"
|
||||||
let l:re = s:re[a:type][a:side]
|
let l:re = s:re[a:type][a:side]
|
||||||
let [l:lnum, l:cnum] = a:direction ==# 'next'
|
let [l:lnum, l:cnum] = a:direction ==# 'next'
|
||||||
\ ? searchpos(l:re, 'cnW', line('w$') + 200)
|
\ ? searchpos(l:re, 'cnW', line('w$') + s:stopline)
|
||||||
\ : a:direction ==# 'prev'
|
\ : a:direction ==# 'prev'
|
||||||
\ ? searchpos(l:re, 'bcnW', max([line('w0') - 200, 1]))
|
\ ? searchpos(l:re, 'bcnW', max([line('w0') - s:stopline, 1]))
|
||||||
\ : searchpos(l:re, 'bcnW', line('.'))
|
\ : searchpos(l:re, 'bcnW', line('.'))
|
||||||
let l:match = matchstr(getline(l:lnum), '^' . l:re, l:cnum-1)
|
let l:match = matchstr(getline(l:lnum), '^' . l:re, l:cnum-1)
|
||||||
|
|
||||||
@ -625,8 +628,8 @@ endfunction
|
|||||||
|
|
||||||
function! s:get_matching_env() dict " {{{1
|
function! s:get_matching_env() dict " {{{1
|
||||||
let [re, flags, stopline] = self.is_open
|
let [re, flags, stopline] = self.is_open
|
||||||
\ ? [self.re.close, 'nW', line('w$') + 200]
|
\ ? [self.re.close, 'nW', line('w$') + s:stopline]
|
||||||
\ : [self.re.open, 'bnW', max([line('w0') - 200, 1])]
|
\ : [self.re.open, 'bnW', max([line('w0') - s:stopline, 1])]
|
||||||
|
|
||||||
let [lnum, cnum] = searchpairpos(self.re.open, '', self.re.close,
|
let [lnum, cnum] = searchpairpos(self.re.open, '', self.re.close,
|
||||||
\ flags, '', stopline)
|
\ flags, '', stopline)
|
||||||
@ -638,8 +641,8 @@ endfunction
|
|||||||
" }}}1
|
" }}}1
|
||||||
function! s:get_matching_tex() dict " {{{1
|
function! s:get_matching_tex() dict " {{{1
|
||||||
let [re, flags, stopline] = self.is_open
|
let [re, flags, stopline] = self.is_open
|
||||||
\ ? [self.re.open, 'nW', line('w$') + 200]
|
\ ? [self.re.open, 'nW', line('w$') + s:stopline]
|
||||||
\ : [self.re.open, 'bnW', max([line('w0') - 200, 1])]
|
\ : [self.re.open, 'bnW', max([line('w0') - s:stopline, 1])]
|
||||||
|
|
||||||
let [lnum, cnum] = searchpos(re, flags, stopline)
|
let [lnum, cnum] = searchpos(re, flags, stopline)
|
||||||
let match = matchstr(getline(lnum), '^' . re, cnum-1)
|
let match = matchstr(getline(lnum), '^' . re, cnum-1)
|
||||||
@ -650,8 +653,8 @@ endfunction
|
|||||||
" }}}1
|
" }}}1
|
||||||
function! s:get_matching_latex() dict " {{{1
|
function! s:get_matching_latex() dict " {{{1
|
||||||
let [re, flags, stopline] = self.is_open
|
let [re, flags, stopline] = self.is_open
|
||||||
\ ? [self.re.close, 'nW', line('w$') + 200]
|
\ ? [self.re.close, 'nW', line('w$') + s:stopline]
|
||||||
\ : [self.re.open, 'bnW', max([line('w0') - 200, 1])]
|
\ : [self.re.open, 'bnW', max([line('w0') - s:stopline, 1])]
|
||||||
|
|
||||||
let [lnum, cnum] = searchpos(re, flags, stopline)
|
let [lnum, cnum] = searchpos(re, flags, stopline)
|
||||||
let match = matchstr(getline(lnum), '^' . re, cnum-1)
|
let match = matchstr(getline(lnum), '^' . re, cnum-1)
|
||||||
@ -662,8 +665,8 @@ endfunction
|
|||||||
" }}}1
|
" }}}1
|
||||||
function! s:get_matching_delim() dict " {{{1
|
function! s:get_matching_delim() dict " {{{1
|
||||||
let [re, flags, stopline] = self.is_open
|
let [re, flags, stopline] = self.is_open
|
||||||
\ ? [self.re.close, 'nW', line('w$') + 200]
|
\ ? [self.re.close, 'nW', line('w$') + s:stopline]
|
||||||
\ : [self.re.open, 'bnW', max([line('w0') - 200, 1])]
|
\ : [self.re.open, 'bnW', max([line('w0') - s:stopline, 1])]
|
||||||
|
|
||||||
let [lnum, cnum] = searchpairpos(self.re.open, '', self.re.close,
|
let [lnum, cnum] = searchpairpos(self.re.open, '', self.re.close,
|
||||||
\ flags, '', stopline)
|
\ flags, '', stopline)
|
||||||
|
@ -403,6 +403,15 @@ Options~
|
|||||||
<
|
<
|
||||||
Default value: [['\left', '\right']]
|
Default value: [['\left', '\right']]
|
||||||
|
|
||||||
|
*g:vimtex_delim_stopline*
|
||||||
|
A tolerance for the number of lines to search for matching delimiters in
|
||||||
|
each direction. It is used in an expression for the {stopline} argument of
|
||||||
|
|search()| function calls. If the option is increased it will make the
|
||||||
|
matching more accurate, at the expense of potential lags. The default value
|
||||||
|
should work well for most people.
|
||||||
|
|
||||||
|
Default value: 500
|
||||||
|
|
||||||
*g:vimtex_format_enabled*
|
*g:vimtex_format_enabled*
|
||||||
If enabled, |vimtex| uses a custom |formatexpr| that should handle inline
|
If enabled, |vimtex| uses a custom |formatexpr| that should handle inline
|
||||||
comments. That is, if it is enabled, then comments at end of lines will not
|
comments. That is, if it is enabled, then comments at end of lines will not
|
||||||
|
Loading…
x
Reference in New Issue
Block a user