Support opening style and class files

This will use the alternate buffer's vimtex data if it exists, else it will
ignore the vimtex initialization.
This commit is contained in:
Karl Yngve Lervåg 2016-08-05 11:12:37 +02:00
parent c05bf59a0c
commit 4e7fd6e04b

View File

@ -37,7 +37,11 @@ function! vimtex#init() " {{{1
" First initialize buffer options and construct (if necessary) the vimtex " First initialize buffer options and construct (if necessary) the vimtex
" data blob. " data blob.
" "
call s:init_buffer() try
call s:init_buffer()
catch '^vimtex'
return
endtry
" "
" Then we initialize the modules. This is done in three steps: " Then we initialize the modules. This is done in three steps:
@ -469,7 +473,7 @@ endfunction
function! s:get_id(main) " {{{1 function! s:get_id(main) " {{{1
for [id, data] in items(g:vimtex_data) for [id, data] in items(g:vimtex_data)
if data.tex == a:main if data.tex == a:main
return id return str2nr(id)
endif endif
endfor endfor
@ -511,6 +515,18 @@ function! s:get_main() " {{{1
return l:candidate return l:candidate
endif endif
"
" Check if we are class or style file
"
if index(['cls', 'sty'], expand('%:e')) >= 0
let id = getbufvar('#', 'vimtex_id', -1)
if id >= 0
return g:vimtex_data[id].tex
else
throw 'vimtex: not valid tex file'
endif
endif
" "
" Search for main file recursively through include specifiers " Search for main file recursively through include specifiers
" "