Edited fix used for bug #191
The previous method used to determine if the foldmethod option was set from a modeline wasn't working for me. The function vimtex#fold#s:check_modeline was always returning false. I changed the function to use a simple regex search on the actual file itself searching for a modeline in the proper line ranges.
This commit is contained in:
parent
778eb53961
commit
88a06f759a
@ -42,8 +42,7 @@ function! vimtex#fold#init_buffer() " {{{1
|
|||||||
if !g:vimtex_fold_enabled | return | endif
|
if !g:vimtex_fold_enabled | return | endif
|
||||||
|
|
||||||
" Don't override modeline settings
|
" Don't override modeline settings
|
||||||
silent let l:fdm_set_in_modeline = s:check_modeline()
|
if s:check_modeline() | return | endif
|
||||||
if !l:fdm_set_in_modeline | return | endif
|
|
||||||
|
|
||||||
" Set fold options
|
" Set fold options
|
||||||
setlocal foldmethod=expr
|
setlocal foldmethod=expr
|
||||||
@ -353,12 +352,25 @@ endfunction
|
|||||||
" }}}1
|
" }}}1
|
||||||
|
|
||||||
function! s:check_modeline() " {{{1
|
function! s:check_modeline() " {{{1
|
||||||
redir => l:check_modeline
|
" Return 1 if foldmethod set in modeline
|
||||||
verbose setlocal foldmethod
|
" Return 0 otherwise
|
||||||
redir END
|
|
||||||
return l:check_modeline =~# 'Last set from modeline'
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
|
let l:search_string='vim:.*foldmethod'
|
||||||
|
|
||||||
|
" Preserve current cursor position
|
||||||
|
let l:save_cursor = getpos(".")
|
||||||
|
" Check for modeline at the top
|
||||||
|
call cursor(1, 1)
|
||||||
|
let l:check_modeline_top = search(l:search_string, 'n', &modelines)
|
||||||
|
|
||||||
|
" Check for modeline at bottom
|
||||||
|
normal G$
|
||||||
|
let l:check_modeline_bottom = search(l:search_string, 'b', line('.')-1-&modelines)
|
||||||
|
|
||||||
|
" Reset original cursor position
|
||||||
|
call setpos('.', l:save_cursor)
|
||||||
|
return l:check_modeline_top || l:check_modeline_bottom
|
||||||
|
endfunction
|
||||||
" }}}1
|
" }}}1
|
||||||
|
|
||||||
" vim: fdm=marker sw=2
|
" vim: fdm=marker sw=2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user