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
|
endif
|
||||||
|
|
||||||
"
|
"
|
||||||
" Search for main file specifier at the beginning of file. This is similar
|
" Search for main file specifier at the beginning of file. Recognized
|
||||||
" to the method used by several other plugins and editors, such as vim with
|
" specifiers are:
|
||||||
" LaTeX-Box, TextMate, TexWorks, and texmaker.
|
|
||||||
"
|
"
|
||||||
|
" 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)
|
for line in getline(1, 5)
|
||||||
let candidate = matchstr(line,
|
let candidate = matchstr(line, regexp)
|
||||||
\ '^\s*%\s*!\s*[tT][eE][xX]\s\+root\s*=\s*\zs.*\ze\s*$')
|
|
||||||
if len(candidate) > 0
|
if len(candidate) > 0
|
||||||
" If candidate is a relative path, then prepend root of current file
|
|
||||||
if candidate[0] !=# '/'
|
if candidate[0] !=# '/'
|
||||||
let candidate = expand('%:h') . '/' . candidate
|
let candidate = expand('%:h') . '/' . candidate
|
||||||
endif
|
endif
|
||||||
@ -194,6 +200,7 @@ function! s:get_main() " {{{1
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
endfor
|
||||||
|
|
||||||
"
|
"
|
||||||
" Search for main file recursively through \input and \include specifiers
|
" 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
|
%! 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*
|
< *b:vimtex_main*
|
||||||
Finally, the main file may be specified through the buffer variable
|
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
|
`b:vimtex_main`. If one uses project specific |vimrc| files, one may then use
|
||||||
|
Loading…
Reference in New Issue
Block a user