Fixed #433: Enable vimtex-toc in bib files
This commit is contained in:
parent
1263f31879
commit
eb48452c79
@ -12,13 +12,18 @@ let s:source = {
|
||||
\ 'sorters' : 'sorter_nothing',
|
||||
\ 'default_kind' : 'jump_list',
|
||||
\ 'syntax' : 'uniteSource__vimtex',
|
||||
\ 'entries' : [],
|
||||
\ 'maxlevel' : 1,
|
||||
\ 'hooks' : {},
|
||||
\}
|
||||
|
||||
function! s:source.gather_candidates(args, context) " {{{1
|
||||
let entries = vimtex#toc#get_entries()
|
||||
let maxlevel = max(map(copy(entries), 'v:val.level'))
|
||||
return map(entries, 's:create_candidate(v:val, maxlevel)')
|
||||
if exists('b:vimtex')
|
||||
let s:source.entries = vimtex#toc#get_entries()
|
||||
let s:source.maxlevel = max(map(copy(s:source.entries), 'v:val.level'))
|
||||
endif
|
||||
return map(copy(s:source.entries),
|
||||
\ 's:create_candidate(v:val, s:source.maxlevel)')
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
|
@ -115,7 +115,14 @@ endfunction
|
||||
function! vimtex#toc#open() " {{{1
|
||||
if vimtex#index#open(s:name) | return | endif
|
||||
|
||||
let index = {
|
||||
if !exists('b:vimtex')
|
||||
if exists('s:index')
|
||||
call vimtex#index#create(s:index)
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
let s:index = {
|
||||
\ 'name' : s:name,
|
||||
\ 'calling_file' : expand('%:p'),
|
||||
\ 'calling_line' : line('.'),
|
||||
@ -139,7 +146,7 @@ function! vimtex#toc#open() " {{{1
|
||||
\ 'toggle_numbers' : function('s:index_toggle_numbers'),
|
||||
\ }
|
||||
|
||||
call vimtex#index#create(index)
|
||||
call vimtex#index#create(s:index)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
|
32
ftplugin/bib.vim
Normal file
32
ftplugin/bib.vim
Normal file
@ -0,0 +1,32 @@
|
||||
" vimtex - LaTeX plugin for Vim
|
||||
"
|
||||
" Maintainer: Karl Yngve Lervåg
|
||||
" Email: karl.yngve@gmail.com
|
||||
"
|
||||
|
||||
if !get(g:, 'vimtex_enabled', 1)
|
||||
finish
|
||||
endif
|
||||
|
||||
if exists('b:did_ftplugin')
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
function! s:map(mode, lhs, rhs, ...)
|
||||
if !hasmapto(a:rhs, a:mode)
|
||||
\ && (a:0 > 0 || maparg(a:lhs, a:mode) ==# '')
|
||||
silent execute a:mode . 'map <silent><buffer>' a:lhs a:rhs
|
||||
endif
|
||||
endfunction
|
||||
|
||||
if g:vimtex_toc_enabled
|
||||
command! -buffer VimtexTocOpen call vimtex#toc#open()
|
||||
command! -buffer VimtexTocToggle call vimtex#toc#toggle()
|
||||
nnoremap <buffer> <plug>(vimtex-toc-open) :call vimtex#toc#open()<cr>
|
||||
nnoremap <buffer> <plug>(vimtex-toc-toggle) :call vimtex#toc#toggle()<cr>
|
||||
call s:map('n', '<localleader>lt', '<plug>(vimtex-toc-open)')
|
||||
call s:map('n', '<localleader>lT', '<plug>(vimtex-toc-toggle)')
|
||||
endif
|
||||
|
||||
" vim: fdm=marker sw=2
|
Loading…
x
Reference in New Issue
Block a user