Cf. #532: Improved vimtex-include system

This commit is contained in:
Karl Yngve Lervåg 2016-09-13 23:09:32 +02:00
parent 1fa42b7f64
commit 7e2793d4e3
3 changed files with 15 additions and 2 deletions

View File

@ -62,6 +62,7 @@ function! vimtex#index#create(index) " {{{1
unlet FnVal
endfor
let l:vimtex = b:vimtex
if g:vimtex_index_split_pos ==# 'full'
silent execute 'edit' escape(a:index.name, ' ')
else
@ -72,6 +73,7 @@ function! vimtex#index#create(index) " {{{1
\ g:vimtex_index_split_pos g:vimtex_index_split_width
\ 'new' escape(a:index.name, ' ')
endif
let b:vimtex = l:vimtex
let b:index = a:index
setlocal bufhidden=wipe
@ -134,6 +136,7 @@ function! s:actions_activate(close) dict "{{{1
let n = getpos('.')[1] - 1
if n < self.help_nlines | return | endif
let entry = self.entries[n - self.help_nlines]
let l:vimtex_main = b:vimtex.tex
" Save index buffer info for later use
let toc_bnr = bufnr('%')
@ -174,6 +177,12 @@ function! s:actions_activate(close) dict "{{{1
call setpos('.', [0, entry.line, 0, 0])
endif
" If relevant, enable vimtex stuff
if get(entry, 'link', 0)
let b:vimtex_main = l:vimtex_main
call vimtex#init()
endif
" Ensure folds are opened
normal! zv

View File

@ -157,6 +157,7 @@ function! vimtex#toc#get_entries() " {{{1
if l:fname[0] !=# '/'
let l:fname = b:vimtex.root . '/' . l:fname
endif
let l:fname = fnamemodify(l:fname, ':~:.')
call add(l:toc, {
\ 'title' : 'Vimtex include: '
\ . (strlen(l:fname) < 54
@ -165,6 +166,7 @@ function! vimtex#toc#get_entries() " {{{1
\ 'number' : '',
\ 'file' : l:fname,
\ 'level' : s:number.current_level,
\ 'link' : 1,
\ })
continue
endif

View File

@ -1717,8 +1717,10 @@ following syntax: >
The path may be absolute or relative. In the latter case, it will be relative
to the current root (as printed by |:VimtexInfo|). This will add an entry in
the ToC which makes it easy to open any file. Note, though, that the ToC and
vimtex key mappings may not be available in the target file.
the ToC which makes it easy to open any file. Any file opened through the ToC
that was included in this manner will be linked to the current vimtex project,
and thus the ToC and similar commands will be available, even if the file is
not a LaTeX file.
Associated settings:
|g:vimtex_toc_enabled|