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
endif
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 CursorMoved <buffer> call vimtex#fold#refresh('zx')
autocmd CursorMoved <buffer> autocmd! vimtex_fold_manual
autocmd CursorMoved <buffer> call s:fold_manual_refresh()
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
endfunction

View File

@ -497,7 +497,7 @@ function! s:buffer_left() " {{{1
endfunction
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

View File

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