From 5f7ced0b2860af3ee98a7a336ff91eb3e76b4295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Tue, 11 Aug 2015 23:31:02 +0200 Subject: [PATCH 1/5] Fix issue #52 with files opened in tabs When opening several files in different tabs, e.g. with `vim -p *.tex`, then the buffers are opened simultaneously. This commit fixes an issue where the autogroup would be reset on each new buffer, meaning that the first n-1 files (or something similar) would have `&foldmethod == expr`. --- autoload/vimtex/fold.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/autoload/vimtex/fold.vim b/autoload/vimtex/fold.vim index 9466bdc..e14ed37 100644 --- a/autoload/vimtex/fold.vim +++ b/autoload/vimtex/fold.vim @@ -74,7 +74,6 @@ function! vimtex#fold#init_buffer() " {{{1 endif else augroup vimtex_fold_manual - autocmd! autocmd CursorMoved call vimtex#fold#refresh('zx') autocmd CursorMoved autocmd! vimtex_fold_manual augroup END From c50e1cefaa7dc8a43d2b32c2a3821160a79832d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Wed, 12 Aug 2015 11:04:45 +0200 Subject: [PATCH 2/5] Fix issue #52 (again) This time ensure that there is no conflict between the various buffers by using unique autocommand groups. --- autoload/vimtex/fold.vim | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/autoload/vimtex/fold.vim b/autoload/vimtex/fold.vim index e14ed37..edc5d1f 100644 --- a/autoload/vimtex/fold.vim +++ b/autoload/vimtex/fold.vim @@ -73,10 +73,20 @@ function! vimtex#fold#init_buffer() " {{{1 augroup END endif else - augroup vimtex_fold_manual - autocmd CursorMoved call vimtex#fold#refresh('zx') - autocmd CursorMoved autocmd! 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 call s:fold_manual_refresh() augroup END + + function! s:fold_manual_refresh() + echom 'refreshed ' . b:fold_manual_augroup + 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 From 0a5ce0a915850e69db4c83f395939ca81a4e8fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Wed, 12 Aug 2015 11:05:20 +0200 Subject: [PATCH 3/5] Remove echo --- autoload/vimtex/fold.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/autoload/vimtex/fold.vim b/autoload/vimtex/fold.vim index edc5d1f..b72e354 100644 --- a/autoload/vimtex/fold.vim +++ b/autoload/vimtex/fold.vim @@ -81,7 +81,6 @@ function! vimtex#fold#init_buffer() " {{{1 augroup END function! s:fold_manual_refresh() - echom 'refreshed ' . b:fold_manual_augroup call vimtex#fold#refresh('zx') execute 'autocmd!' b:fold_manual_augroup execute 'augroup!' b:fold_manual_augroup From 610bfaff0ebc2367c8d1f15c2caa4f3d72cb22c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Tue, 25 Aug 2015 21:38:05 +0200 Subject: [PATCH 4/5] Isolate indentation of math delimiters (fixes #210) --- indent/tex.vim | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/indent/tex.vim b/indent/tex.vim index d3a62de..ed79cbf 100644 --- a/indent/tex.vim +++ b/indent/tex.vim @@ -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\?\()\|\]\|\\}\)', \ ], '\|') . '\)' From 824444ef7095a4a5d5ce52df959d14e7c77e9177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Thu, 20 Aug 2015 07:50:05 +0200 Subject: [PATCH 5/5] Fix minor problem in s:buffer_deleted In some cases the BufDelete autocommand may be called without BufLeave having been called first. --- autoload/vimtex/latexmk.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/vimtex/latexmk.vim b/autoload/vimtex/latexmk.vim index 66f925d..a802b70 100644 --- a/autoload/vimtex/latexmk.vim +++ b/autoload/vimtex/latexmk.vim @@ -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