Fix #532: Add support for vimtex-includes in ToC
This commit is contained in:
parent
e687d39281
commit
2559a85105
@ -170,7 +170,9 @@ function! s:actions_activate(close) dict "{{{1
|
|||||||
execute 'keepalt' cmd bnr
|
execute 'keepalt' cmd bnr
|
||||||
|
|
||||||
" Go to entry line
|
" Go to entry line
|
||||||
|
if has_key(entry, 'line')
|
||||||
call setpos('.', [0, entry.line, 0, 0])
|
call setpos('.', [0, entry.line, 0, 0])
|
||||||
|
endif
|
||||||
|
|
||||||
" Ensure folds are opened
|
" Ensure folds are opened
|
||||||
normal! zv
|
normal! zv
|
||||||
|
@ -151,6 +151,24 @@ function! vimtex#toc#get_entries() " {{{1
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Convenience includes
|
||||||
|
let l:fname = matchstr(l:line, s:re_vimtex_include)
|
||||||
|
if !empty(l:fname)
|
||||||
|
if l:fname[0] !=# '/'
|
||||||
|
let l:fname = b:vimtex.root . '/' . l:fname
|
||||||
|
endif
|
||||||
|
call add(l:toc, {
|
||||||
|
\ 'title' : 'Vimtex include: '
|
||||||
|
\ . (strlen(l:fname) < 54
|
||||||
|
\ ? l:fname
|
||||||
|
\ : l:fname[0:20] . '...' . l:fname[-30:]),
|
||||||
|
\ 'number' : '',
|
||||||
|
\ 'file' : l:fname,
|
||||||
|
\ 'level' : s:number.current_level,
|
||||||
|
\ })
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
" Bibliography files
|
" Bibliography files
|
||||||
if l:line =~# s:re_bibs
|
if l:line =~# s:re_bibs
|
||||||
call add(l:toc, s:parse_bib_input(l:line))
|
call add(l:toc, s:parse_bib_input(l:line))
|
||||||
@ -488,6 +506,7 @@ let s:re_sec = '\v^\s*\\%(part|chapter|%(sub)*section)\*?\s*%(\[.{-}\])?\{'
|
|||||||
let s:re_sec_starred = '\v^\s*\\%(part|chapter|%(sub)*section)\*'
|
let s:re_sec_starred = '\v^\s*\\%(part|chapter|%(sub)*section)\*'
|
||||||
let s:re_sec_level = '\v^\s*\\\zs%(part|chapter|%(sub)*section)'
|
let s:re_sec_level = '\v^\s*\\\zs%(part|chapter|%(sub)*section)'
|
||||||
let s:re_sec_title = s:re_sec . '\zs.{-}\ze\}?\%?\s*$'
|
let s:re_sec_title = s:re_sec . '\zs.{-}\ze\}?\%?\s*$'
|
||||||
|
let s:re_vimtex_include = '%\s*vimtex-include:\?\s\+\zs\f\+'
|
||||||
let s:re_matters = '\v^\s*\\%(front|main|back)matter>'
|
let s:re_matters = '\v^\s*\\%(front|main|back)matter>'
|
||||||
let s:re_structure = '\v^\s*\\((front|main|back)matter|appendix)>'
|
let s:re_structure = '\v^\s*\\((front|main|back)matter|appendix)>'
|
||||||
let s:re_structure_match = '\v((front|main|back)matter|appendix)'
|
let s:re_structure_match = '\v((front|main|back)matter|appendix)'
|
||||||
|
@ -1710,6 +1710,16 @@ Table of contents~
|
|||||||
The ToC entries may be activated/jumped to with <cr> or <space>. The local
|
The ToC entries may be activated/jumped to with <cr> or <space>. The local
|
||||||
keybindings are described if |g:vimtex_index_show_help| is enabled.
|
keybindings are described if |g:vimtex_index_show_help| is enabled.
|
||||||
|
|
||||||
|
One may force entries into the ToC through designated comments with the
|
||||||
|
following syntax: >
|
||||||
|
|
||||||
|
% vimtex-include: /path/to/file
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
Associated settings:
|
Associated settings:
|
||||||
|g:vimtex_toc_enabled|
|
|g:vimtex_toc_enabled|
|
||||||
|g:vimtex_toc_fold|
|
|g:vimtex_toc_fold|
|
||||||
|
Loading…
Reference in New Issue
Block a user