Better latex info

This commit is contained in:
Karl Yngve Lervåg 2014-08-03 09:14:05 +02:00
parent 7eff78977f
commit 49a100cafd
2 changed files with 37 additions and 46 deletions

View File

@ -32,34 +32,43 @@ function! latex#info() " {{{1
return return
endif endif
echo "b:latex" " Print buffer data
echo ' id: ' . b:latex.id echo printf('%-19s%-s', 'b:latex.id', b:latex.id)
if has_key(b:latex, 'fold_parts') && !empty(b:latex.fold_parts) if has_key(b:latex, 'fold_parts') && !empty(b:latex.fold_parts)
echo ' fold parts:' echo 'b:latex.fold_parts'
for entry in reverse(copy(b:latex.fold_parts)) for entry in reverse(copy(b:latex.fold_parts))
echo ' fold level ' . entry[1] . ': ' . entry[0] echo printf(' %s %s', entry[1], entry[0])
endfor endfor
endif endif
echo "\n"
echo "g:latex#data" " Print global data
let n = -1 let n = 0
for data in g:latex#data for d in g:latex#data
let n += 1
if n > 0
echo "\n" echo "\n"
echo "g:latex#data[" . n . "]"
if d.pid
echo printf(' %-6s%-s', 'pid', d.pid)
endif endif
let d = copy(data) echo printf(' %-6s%-s', 'name', s:truncate(d.name))
let d.aux = d.aux() echo printf(' %-6s%-s', 'base', s:truncate(d.base))
let d.out = d.out() echo printf(' %-6s%-s', 'root', s:truncate(d.root))
let d.log = d.log() echo printf(' %-6s%-s', 'tex', s:truncate(d.tex))
echo printf(' %4s: %-s', 'id', n)
for [key, val] in sort(items(d), "s:info_sort_func") for f in ['aux', 'out', 'log']
if key =~ '\vaux|out|root|log|tex' silent execute 'let l:tmp = d.' . f . '()'
let val = s:truncate(val) if l:tmp != ''
echo printf(' %-6s%-s', f, s:truncate(l:tmp))
endif endif
echo printf(' %4s: %-s', key, val)
endfor endfor
let cmds = items(d.cmds)
if len(cmds) > 0
for [key, val] in cmds
echo printf(' command: %-9s', key)
echo printf(' %-s', val)
endfor
endif
let n += 1
endfor endfor
endfunction endfunction
@ -110,6 +119,8 @@ function! latex#view(...) " {{{1
let exe.cmd = g:latex_viewer . ' ' . args . shellescape(outfile) let exe.cmd = g:latex_viewer . ' ' . args . shellescape(outfile)
call latex#util#execute(exe) call latex#util#execute(exe)
let g:latex#data[b:latex.id].cmds.view = exe.cmd
endfunction endfunction
" }}}1 " }}}1
@ -126,7 +137,7 @@ function! s:init_environment() " {{{1
setlocal commentstring=\%\ %s setlocal commentstring=\%\ %s
" "
" Create new or link to old blob " Create new or link to existing blob
" "
let main = s:get_main() let main = s:get_main()
let id = s:get_id(main) let id = s:get_id(main)
@ -134,6 +145,7 @@ function! s:init_environment() " {{{1
let b:latex.id = id let b:latex.id = id
else else
let data = {} let data = {}
let data.cmds = {}
let data.tex = main let data.tex = main
let data.root = fnamemodify(data.tex, ':h') let data.root = fnamemodify(data.tex, ':h')
let data.base = fnamemodify(data.tex, ':t') let data.base = fnamemodify(data.tex, ':t')
@ -378,27 +390,6 @@ function! s:get_main_ext(texdata, ext) " {{{1
return '' return ''
endfunction endfunction
function! s:info_sort_func(a, b) " {{{1
if a:a[1][0] == "!"
" Put cmd's way behind
return 1
elseif a:b[1][0] == "!"
" Put cmd's way behind
return -1
elseif a:a[1][0] == "/" && a:b[1][0] != "/"
" Put full paths behind
return 1
elseif a:a[1][0] != "/" && a:b[1][0] == "/"
" Put full paths behind
return -1
elseif a:a[1][0] == "/" && a:b[1][0] == "/"
" Put full paths behind
return -1
else
return a:a[1] > a:b[1] ? 1 : -1
endif
endfunction
function! s:truncate(string) " {{{1 function! s:truncate(string) " {{{1
if len(a:string) >= winwidth('.') - 9 if len(a:string) >= winwidth('.') - 9
return a:string[0:10] . "..." . a:string[-winwidth('.')+23:] return a:string[0:10] . "..." . a:string[-winwidth('.')+23:]

View File

@ -88,7 +88,7 @@ function! latex#latexmk#clean(full) " {{{1
let cmd .= 'latexmk -c ' let cmd .= 'latexmk -c '
endif endif
let cmd .= shellescape(data.base) let cmd .= shellescape(data.base)
let g:latex#data[b:latex.id].clean_cmd = cmd let g:latex#data[b:latex.id].cmds.clean = cmd
let exe = { let exe = {
\ 'cmd' : cmd, \ 'cmd' : cmd,
\ 'bg' : 0, \ 'bg' : 0,
@ -116,7 +116,7 @@ function! latex#latexmk#compile() " {{{1
" Define execute dictionary and latexmk command " Define execute dictionary and latexmk command
let exe = {} let exe = {}
let exe.null = 0 let exe.null = 0
let exe.cmd = data.cmd let exe.cmd = data.cmds.compile
call latex#util#execute(exe) call latex#util#execute(exe)
" Save PID " Save PID
@ -292,7 +292,7 @@ function! s:latexmk_set_cmd(data) " {{{1
let cmd .= ' &>' . tmp let cmd .= ' &>' . tmp
endif endif
let a:data.cmd = cmd let a:data.cmds.compile = cmd
let a:data.tmp = tmp let a:data.tmp = tmp
endfunction endfunction