Fix #241 - Add support for import package
This commit is contained in:
parent
d03e2a0016
commit
25cdfa6bb1
@ -49,6 +49,9 @@ disabled if desired.
|
||||
- Support for `listings` package
|
||||
- Support for `minted` package
|
||||
- Support for `dot2tex` with nested syntax highlighting
|
||||
- Support for multi-file project packages
|
||||
- [import](http://ctan.uib.no/macros/latex/contrib/import/import.pdf)
|
||||
- [subfiles](http://ctan.uib.no/macros/latex/contrib/import/import.pdf) (partly)
|
||||
|
||||
See the documentation for a more thorough introduction of the plugin (e.g. `:h
|
||||
vimtex`).
|
||||
|
@ -468,7 +468,7 @@ function! s:get_main() " {{{1
|
||||
endif
|
||||
|
||||
"
|
||||
" Search for main file recursively through \input and \include specifiers
|
||||
" Search for main file recursively through include specifiers
|
||||
"
|
||||
let main = s:get_main_recurse(expand('%:p'))
|
||||
if filereadable(main)
|
||||
@ -528,15 +528,20 @@ function! s:get_main_recurse(file) " {{{1
|
||||
let l:candidates = split(globpath(fnameescape(l:dirs), '*.tex'), '\n')
|
||||
|
||||
"
|
||||
" Search through candidates for \include{current file}
|
||||
" Search through candidates
|
||||
"
|
||||
for l:file in l:candidates
|
||||
" Avoid infinite recursion (checking the same file repeatedly)
|
||||
if l:file == a:file | continue | endif
|
||||
|
||||
if len(filter(readfile(l:file), 'v:val =~ ''\v\\(input|include)\{'
|
||||
\ . '\s*((.*)\/)?'
|
||||
\ . fnamemodify(a:file, ':t:r') . '(\.tex)?\s*''')) > 0
|
||||
let l:file_re = '\s*((.*)\/)?' . fnamemodify(a:file, ':t:r')
|
||||
|
||||
let l:filter = 'v:val =~# ''\v'
|
||||
let l:filter .= '\\%(input|include)\{' . l:file_re
|
||||
let l:filter .= '|\\subimport\{[^\}]*\}\{' . l:file_re
|
||||
let l:filter .= ''''
|
||||
|
||||
if len(filter(readfile(l:file), l:filter)) > 0
|
||||
return s:get_main_recurse(l:file)
|
||||
endif
|
||||
endfor
|
||||
|
@ -9,7 +9,7 @@ endfunction
|
||||
|
||||
" }}}1
|
||||
function! vimtex#parser#init_script() " {{{1
|
||||
let s:input_line_tex = '\v^\s*\\%(input|include)\s*\{'
|
||||
let s:input_line_tex = '\v^\s*\\%(input|include|subimport)\s*\{'
|
||||
let s:input_line_aux = '\\@input{'
|
||||
endfunction
|
||||
|
||||
@ -83,7 +83,15 @@ endfunction
|
||||
" Input line parsers
|
||||
"
|
||||
function! s:input_line_parser_tex(line, file) " {{{1
|
||||
" Handle \space commands
|
||||
let l:file = substitute(a:line, '\\space\s*', ' ', 'g')
|
||||
|
||||
" Hande subimport commands
|
||||
if a:line =~# '\\subimport'
|
||||
let l:file = substitute(l:file, '}\s*{', '', 'g')
|
||||
endif
|
||||
|
||||
" Parse file name
|
||||
let l:file = matchstr(l:file, s:input_line_tex . '\zs[^\}]+\ze}')
|
||||
|
||||
" Trim whitespaces and quotes from beginning/end of string
|
||||
|
@ -112,6 +112,9 @@ Feature overview~
|
||||
- Support for `listings` package
|
||||
- Support for `minted` package
|
||||
- Support for `dot2tex` with nested syntax highlighting
|
||||
- Support for multi-file project packages
|
||||
- `import`
|
||||
- `subfiles` (partly)
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
Requirements~
|
||||
@ -201,6 +204,17 @@ Subfiles~
|
||||
Note that this is a special case in that it is only relevant for users who
|
||||
use the `subfiles` package.
|
||||
|
||||
*vimtex-import*
|
||||
Import~
|
||||
|vimtex| also supports the `import` package, in that it should correctly
|
||||
recognize the main file from sub files that are included through the
|
||||
`subimport` command, e.g. >
|
||||
|
||||
\subimport{chapters/}{chapter1.tex}
|
||||
<
|
||||
The support also extends into correctly parsing the project for table of
|
||||
contents.
|
||||
|
||||
*b:vimtex_main*
|
||||
Buffer variable~
|
||||
Finally, the main file may be specified through the buffer variable
|
||||
|
Binary file not shown.
@ -4,5 +4,5 @@
|
||||
\begin{document}
|
||||
\subimport{preamble/}{preamble.tex}
|
||||
\cleardoublepage
|
||||
\subimport{chapter/}{chapter.tex}
|
||||
\subimport{parts/}{chapter.tex}
|
||||
\end{document}
|
||||
|
Loading…
Reference in New Issue
Block a user