diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2013-11-02 23:27:57 +0100 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2013-11-02 23:27:57 +0100 |
commit | 30c1920e4fa4e612238e1f435907c40ecfa47f33 (patch) | |
tree | f88ffb408895a5baf93fe81fdd12acba17f32d44 /ftplugin/latextoc.vim | |
parent | 57cfac7ae384466c3ff2543a9200319dc1d459a0 (diff) | |
download | vim-polyglot-1.4.1.tar.gz vim-polyglot-1.4.1.zip |
Massive update :)v1.4.1
Diffstat (limited to 'ftplugin/latextoc.vim')
-rw-r--r-- | ftplugin/latextoc.vim | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/ftplugin/latextoc.vim b/ftplugin/latextoc.vim index f753cea8..48f20e3b 100644 --- a/ftplugin/latextoc.vim +++ b/ftplugin/latextoc.vim @@ -80,24 +80,14 @@ function! s:TOCActivate(close) execute b:calling_win . 'wincmd w' - let bnr = bufnr(entry['file']) - if bnr == -1 - execute 'badd ' . entry['file'] - let bnr = bufnr(entry['file']) - endif - - execute 'buffer! ' . bnr - - " skip duplicates - while duplicates > 0 - if search('\\' . entry['level'] . '\_\s*{' . titlestr . '}', 'ws') - let duplicates -= 1 - endif - endwhile + let files = [entry['file']] + for line in filter(readfile(entry['file']), 'v:val =~ ''\\input{''') + call add(files, matchstr(line, '{\zs.*\ze\(\.tex\)\?}') . '.tex') + endfor - if search('\\' . entry['level'] . '\_\s*{' . titlestr . '}', 'ws') - normal zv - endif + " Find section in buffer (or inputted files) + call s:TOCFindMatch('\\' . entry['level'] . '\_\s*{' . titlestr . '}', + \ duplicates, files) if a:close if g:LatexBox_split_resize @@ -109,6 +99,30 @@ function! s:TOCActivate(close) endif endfunction +" {{{2 TOCFindMatch +function! s:TOCFindMatch(strsearch,duplicates,files) + + call s:TOCOpenBuf(a:files[0]) + let dups = a:duplicates + + " Skip duplicates + while dups > 0 + if search(a:strsearch, 'w') + let dups -= 1 + else + break + endif + endwhile + + if search(a:strsearch, 'w') + normal! zv + return + endif + + call s:TOCFindMatch(a:strsearch,dups,a:files[1:]) + +endfunction + " {{{2 TOCFoldLevel function! TOCFoldLevel(lnum) let line = getline(a:lnum) @@ -140,12 +154,25 @@ function! TOCFoldLevel(lnum) " Return previous fold level return "=" endfunction + " {{{2 TOCFoldText function! TOCFoldText() let parts = matchlist(getline(v:foldstart), '^\(.*\)\t\(.*\)$') return printf('%-8s%-72s', parts[1], parts[2]) endfunction +" {{{2 TOCOpenBuf +function! s:TOCOpenBuf(file) + + let bnr = bufnr(a:file) + if bnr == -1 + execute 'badd ' . a:file + let bnr = bufnr(a:file) + endif + execute 'buffer! ' . bnr + +endfunction + " }}}1 " {{{1 Mappings |