Cf. #532: Improved vimtex-include system
This commit is contained in:
parent
1fa42b7f64
commit
7e2793d4e3
@ -62,6 +62,7 @@ function! vimtex#index#create(index) " {{{1
|
|||||||
unlet FnVal
|
unlet FnVal
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
let l:vimtex = b:vimtex
|
||||||
if g:vimtex_index_split_pos ==# 'full'
|
if g:vimtex_index_split_pos ==# 'full'
|
||||||
silent execute 'edit' escape(a:index.name, ' ')
|
silent execute 'edit' escape(a:index.name, ' ')
|
||||||
else
|
else
|
||||||
@ -72,6 +73,7 @@ function! vimtex#index#create(index) " {{{1
|
|||||||
\ g:vimtex_index_split_pos g:vimtex_index_split_width
|
\ g:vimtex_index_split_pos g:vimtex_index_split_width
|
||||||
\ 'new' escape(a:index.name, ' ')
|
\ 'new' escape(a:index.name, ' ')
|
||||||
endif
|
endif
|
||||||
|
let b:vimtex = l:vimtex
|
||||||
let b:index = a:index
|
let b:index = a:index
|
||||||
|
|
||||||
setlocal bufhidden=wipe
|
setlocal bufhidden=wipe
|
||||||
@ -134,6 +136,7 @@ function! s:actions_activate(close) dict "{{{1
|
|||||||
let n = getpos('.')[1] - 1
|
let n = getpos('.')[1] - 1
|
||||||
if n < self.help_nlines | return | endif
|
if n < self.help_nlines | return | endif
|
||||||
let entry = self.entries[n - self.help_nlines]
|
let entry = self.entries[n - self.help_nlines]
|
||||||
|
let l:vimtex_main = b:vimtex.tex
|
||||||
|
|
||||||
" Save index buffer info for later use
|
" Save index buffer info for later use
|
||||||
let toc_bnr = bufnr('%')
|
let toc_bnr = bufnr('%')
|
||||||
@ -174,6 +177,12 @@ function! s:actions_activate(close) dict "{{{1
|
|||||||
call setpos('.', [0, entry.line, 0, 0])
|
call setpos('.', [0, entry.line, 0, 0])
|
||||||
endif
|
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
|
" Ensure folds are opened
|
||||||
normal! zv
|
normal! zv
|
||||||
|
|
||||||
|
@ -157,6 +157,7 @@ function! vimtex#toc#get_entries() " {{{1
|
|||||||
if l:fname[0] !=# '/'
|
if l:fname[0] !=# '/'
|
||||||
let l:fname = b:vimtex.root . '/' . l:fname
|
let l:fname = b:vimtex.root . '/' . l:fname
|
||||||
endif
|
endif
|
||||||
|
let l:fname = fnamemodify(l:fname, ':~:.')
|
||||||
call add(l:toc, {
|
call add(l:toc, {
|
||||||
\ 'title' : 'Vimtex include: '
|
\ 'title' : 'Vimtex include: '
|
||||||
\ . (strlen(l:fname) < 54
|
\ . (strlen(l:fname) < 54
|
||||||
@ -165,6 +166,7 @@ function! vimtex#toc#get_entries() " {{{1
|
|||||||
\ 'number' : '',
|
\ 'number' : '',
|
||||||
\ 'file' : l:fname,
|
\ 'file' : l:fname,
|
||||||
\ 'level' : s:number.current_level,
|
\ 'level' : s:number.current_level,
|
||||||
|
\ 'link' : 1,
|
||||||
\ })
|
\ })
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
|
@ -1717,8 +1717,10 @@ following syntax: >
|
|||||||
|
|
||||||
The path may be absolute or relative. In the latter case, it will be relative
|
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
|
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
|
the ToC which makes it easy to open any file. Any file opened through the ToC
|
||||||
vimtex key mappings may not be available in the target file.
|
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:
|
Associated settings:
|
||||||
|g:vimtex_toc_enabled|
|
|g:vimtex_toc_enabled|
|
||||||
|
Loading…
Reference in New Issue
Block a user