Improved support for subfiles package (#155)
Added parsing of main file from `\documentclass[main.tex]{subfiles}`.
This commit is contained in:
parent
566463fbf8
commit
e74fc287ed
@ -176,15 +176,21 @@ function! s:get_main() " {{{1
|
||||
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
|
||||
" LaTeX-Box, TextMate, TexWorks, and texmaker.
|
||||
" Search for main file specifier at the beginning of file. Recognized
|
||||
" specifiers are:
|
||||
"
|
||||
" 1. The TEX root specifier, which is used by by several other plugins and
|
||||
" editors.
|
||||
" 2. Subfiles package specifier. This parses the main tex file option in the
|
||||
" \documentclass line for the subfiles package.
|
||||
"
|
||||
for regexp in [
|
||||
\ '^\c\s*%\s*!\?\s*tex\s\+root\s*=\s*\zs.*\ze\s*$',
|
||||
\ '^\C\s*\\documentclass\[\zs.*\ze\]{subfiles}',
|
||||
\ ]
|
||||
for line in getline(1, 5)
|
||||
let candidate = matchstr(line,
|
||||
\ '^\s*%\s*!\s*[tT][eE][xX]\s\+root\s*=\s*\zs.*\ze\s*$')
|
||||
let candidate = matchstr(line, regexp)
|
||||
if len(candidate) > 0
|
||||
" If candidate is a relative path, then prepend root of current file
|
||||
if candidate[0] !=# '/'
|
||||
let candidate = expand('%:h') . '/' . candidate
|
||||
endif
|
||||
@ -194,6 +200,7 @@ function! s:get_main() " {{{1
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
"
|
||||
" Search for main file recursively through \input and \include specifiers
|
||||
|
@ -150,6 +150,12 @@ first five lines of the current file similar to this: >
|
||||
|
||||
%! TEX root = my-main.tex
|
||||
|
||||
< *vimtex-subfiles*
|
||||
Further, |vimtex| supports the `subfiles` package. That is, the main file is
|
||||
parsed from the `\documentclass` line whenever it has the following format: >
|
||||
|
||||
\documentclass[main.tex]{subfiles}
|
||||
|
||||
< *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
|
||||
|
Loading…
Reference in New Issue
Block a user