diff --git a/autoload/vimtex.vim b/autoload/vimtex.vim index bb3b18b..10585ab 100644 --- a/autoload/vimtex.vim +++ b/autoload/vimtex.vim @@ -168,6 +168,13 @@ function! s:get_id(main) " {{{1 endfunction function! s:get_main() " {{{1 + " + " Use buffer variable if it exists + " + if exists('b:vimtex_main') && filereadable(b:vimtex_main) + return fnamemodify(b:vimtex_main, ':p') + endif + " " Search for main file specifier at the beginning of file. This is similar " to the method used by several other plugins and editors, such as vim with diff --git a/doc/vimtex.txt b/doc/vimtex.txt index 659d4f0..86f8ee0 100644 --- a/doc/vimtex.txt +++ b/doc/vimtex.txt @@ -150,6 +150,13 @@ first five lines of the current file similar to this: > %! TEX root = my-main.tex +< *b:vimtex_main* +Finally, the main file may be specified through the buffer variable +`b:vimtex_main`. If one uses project specific |vimrc| files, one may then use +an |autocmd| to specify the main file through this buffer variable with > + + autocmd FileType tex let b:vimtex_main = 'main.tex' + ------------------------------------------------------------------------------ Comment on internal tex plugin~ *vimtex-comment-internal*