From 4e7fd6e04b89223baafecd11856ea23930ad2702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Fri, 5 Aug 2016 11:12:37 +0200 Subject: [PATCH] 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. --- autoload/vimtex.vim | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/autoload/vimtex.vim b/autoload/vimtex.vim index c6015db..b60edf2 100644 --- a/autoload/vimtex.vim +++ b/autoload/vimtex.vim @@ -37,7 +37,11 @@ function! vimtex#init() " {{{1 " First initialize buffer options and construct (if necessary) the vimtex " 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: @@ -469,7 +473,7 @@ endfunction function! s:get_id(main) " {{{1 for [id, data] in items(g:vimtex_data) if data.tex == a:main - return id + return str2nr(id) endif endfor @@ -511,6 +515,18 @@ function! s:get_main() " {{{1 return l:candidate 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 "