Merge pull request #625 from DelusionalLogic/master

Better handling of relative subimports
This commit is contained in:
Karl Yngve Lervåg 2016-11-25 08:13:55 +01:00 committed by GitHub
commit 0ccb84fb27

View File

@ -122,6 +122,7 @@ function! s:input_line_parser_tex(line, file, re) " {{{1
let l:file = substitute(a:line, '\\space\s*', ' ', 'g')
" Handle import package commands
let l:subimport = 0
if l:file =~# '\v\\%(sub)?%(import|%(input|include)from)'
let l:candidate = s:input_line_parser_tex(
\ substitute(l:file, '\\\w*\s*{[^{}]*}\s*', '', ''),
@ -129,6 +130,9 @@ function! s:input_line_parser_tex(line, file, re) " {{{1
\ '\v^\s*\{')
if !empty(l:candidate) | return l:candidate | endif
" Handle relative paths
let l:subimport = l:file =~# '\v\\sub%(import|%(input|include)from)'
let l:file = substitute(l:file, '}\s*{', '', 'g')
endif
@ -146,7 +150,7 @@ function! s:input_line_parser_tex(line, file, re) " {{{1
" Use absolute paths
if l:file !~# '\v^(\/|[A-Z]:)'
let l:file = b:vimtex.root . '/' . l:file
let l:file = (l:subimport ? fnamemodify(a:file, ':h') : b:vimtex.root) . '/' . l:file
endif
" Only return filename if it is readable