Merge branch 'master' of github:lervag/vimtex

This commit is contained in:
Camil Staps 2015-08-26 10:22:21 +02:00
commit 8e3cefbe94
3 changed files with 40 additions and 16 deletions

View File

@ -73,11 +73,19 @@ function! vimtex#fold#init_buffer() " {{{1
augroup END augroup END
endif endif
else else
augroup vimtex_fold_manual let s:fold_manual_id = get(s:, 'fold_manual_id', 0) + 1
let b:fold_manual_augroup = 'vimtex_fold_' . s:fold_manual_id
execute 'augroup' b:fold_manual_augroup
autocmd! autocmd!
autocmd CursorMoved <buffer> call vimtex#fold#refresh('zx') autocmd CursorMoved <buffer> call s:fold_manual_refresh()
autocmd CursorMoved <buffer> autocmd! vimtex_fold_manual
augroup END augroup END
function! s:fold_manual_refresh()
call vimtex#fold#refresh('zx')
execute 'autocmd!' b:fold_manual_augroup
execute 'augroup!' b:fold_manual_augroup
unlet b:fold_manual_augroup
endfunction
endif endif
endfunction endfunction

View File

@ -497,7 +497,7 @@ function! s:buffer_left() " {{{1
endfunction endfunction
function! s:buffer_deleted() " {{{1 function! s:buffer_deleted() " {{{1
if s:vimtex.pid == 0 | return | endif if get(get(s:, 'vimtex', {}), 'pid', 0) == 0 | return | endif
" "
" The buffer is deleted, so we must kill the remaining latexmk process if the " The buffer is deleted, so we must kill the remaining latexmk process if the

View File

@ -89,12 +89,22 @@ function! VimtexIndent() " {{{1
endif endif
" Indent opening and closing delimiters " Indent opening and closing delimiters
let popen = s:count_delimiters(pline, s:delimiters_open) let popen = s:count_delimiters(pline, s:tex_delimiters_open)
let copen = s:count_delimiters(cline, s:delimiters_open) let copen = s:count_delimiters(cline, s:tex_delimiters_open)
let pclose = s:count_delimiters(pline, s:delimiters_close) let pclose = s:count_delimiters(pline, s:tex_delimiters_close)
let cclose = s:count_delimiters(cline, s:delimiters_close) let cclose = s:count_delimiters(cline, s:tex_delimiters_close)
let ind += &sw*(max([popen - pclose, 0]) - max([cclose - copen, 0])) let ind += &sw*(max([popen - pclose, 0]) - max([cclose - copen, 0]))
" Indent opening and closing delimiters for math mode
if match(map(synstack(v:lnum, max([col('.') - 1, 1])),
\ 'synIDattr(v:val, ''name'')'), '^texMathZone') >= 0
let popen = s:count_delimiters(pline, s:math_delimiters_open)
let copen = s:count_delimiters(cline, s:math_delimiters_open)
let pclose = s:count_delimiters(pline, s:math_delimiters_close)
let cclose = s:count_delimiters(cline, s:math_delimiters_close)
let ind += &sw*(max([popen - pclose, 0]) - max([cclose - copen, 0]))
endif
" Indent list items " Indent list items
if pline =~# '^\s*\\\(bib\)\?item' if pline =~# '^\s*\\\(bib\)\?item'
let ind += &sw let ind += &sw
@ -136,25 +146,31 @@ let s:tikz_indented = 0
" Define some common patterns " Define some common patterns
let s:envs_lists = 'itemize\|description\|enumerate\|thebibliography' let s:envs_lists = 'itemize\|description\|enumerate\|thebibliography'
let s:envs_noindent = 'document\|verbatim\|lstlisting' let s:envs_noindent = 'document\|verbatim\|lstlisting'
let s:delimiters_open = '\(' . join([ let s:tex_delimiters_open = '\(' . join([
\ '{', \ '{',
\ '(',
\ '\[', \ '\[',
\ '\\{',
\ '\\(', \ '\\(',
\ '\\\[', \ '\\\[',
\ '\\\Cbegin\s*{.\{-}}', \ '\\\Cbegin\s*{.\{-}}',
\ '\\\Cleft\s*\%([^\\]\|\\.\|\\\a*\)',
\ '\\\cbigg\?\((\|\[\|\\{\)',
\ ], '\|') . '\)' \ ], '\|') . '\)'
let s:delimiters_close = '\(' . join([ let s:tex_delimiters_close = '\(' . join([
\ '}', \ '}',
\ ')',
\ '\]', \ '\]',
\ '\\}',
\ '\\)', \ '\\)',
\ '\\\]', \ '\\\]',
\ '\\\Cend\s*{.\{-}}', \ '\\\Cend\s*{.\{-}}',
\ ], '\|') . '\)'
let s:math_delimiters_open = '\(' . join([
\ '(',
\ '\[',
\ '\\{',
\ '\\\Cleft\s*\%([^\\]\|\\.\|\\\a*\)',
\ '\\\cbigg\?\((\|\[\|\\{\)',
\ ], '\|') . '\)'
let s:math_delimiters_close = '\(' . join([
\ ')',
\ '\]',
\ '\\}',
\ '\\\Cright\s*\%([^\\]\|\\.\|\\\a*\)', \ '\\\Cright\s*\%([^\\]\|\\.\|\\\a*\)',
\ '\\\cbigg\?\()\|\]\|\\}\)', \ '\\\cbigg\?\()\|\]\|\\}\)',
\ ], '\|') . '\)' \ ], '\|') . '\)'