Cf. #537: Improved updating of output buffer
This commit is contained in:
parent
5816eb882e
commit
f7e11c9770
@ -114,6 +114,10 @@ function! vimtex#latexmk#callback(status) " {{{1
|
|||||||
call vimtex#latexmk#errors_open(0)
|
call vimtex#latexmk#errors_open(0)
|
||||||
redraw
|
redraw
|
||||||
|
|
||||||
|
if exists('s:output')
|
||||||
|
call s:output.update()
|
||||||
|
endif
|
||||||
|
|
||||||
call vimtex#echo#status(['latexmk compile: ',
|
call vimtex#echo#status(['latexmk compile: ',
|
||||||
\ a:status ? ['VimtexSuccess', 'success'] : ['VimtexWarning', 'fail']])
|
\ a:status ? ['VimtexSuccess', 'success'] : ['VimtexWarning', 'fail']])
|
||||||
|
|
||||||
@ -411,22 +415,58 @@ function! vimtex#latexmk#output() " {{{1
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Create latexmk output window
|
" If window already open, then go there
|
||||||
if bufnr(tmp) >= 0
|
if exists('s:output')
|
||||||
silent exe 'bwipeout' . bufnr(tmp)
|
if bufwinnr(tmp) == s:output.winnr
|
||||||
|
execute s:output.winnr . 'wincmd w'
|
||||||
|
return
|
||||||
|
else
|
||||||
|
call s:output.destroy()
|
||||||
endif
|
endif
|
||||||
silent exe 'split ' . tmp
|
endif
|
||||||
|
|
||||||
|
" Create latexmk output window
|
||||||
|
silent execute 'split' tmp
|
||||||
|
|
||||||
|
" Create the output object
|
||||||
|
let s:output = {}
|
||||||
|
let s:output.name = tmp
|
||||||
|
let s:output.bufnr = bufnr('%')
|
||||||
|
let s:output.winnr = bufwinnr('%')
|
||||||
|
function! s:output.update() dict
|
||||||
|
if bufwinnr(self.name) != self.winnr
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Try to enforce a file read
|
||||||
|
execute 'checktime' self.name
|
||||||
|
redraw
|
||||||
|
|
||||||
|
" Go to last line of file if it is not the current window
|
||||||
|
if bufwinnr('%') != self.winnr
|
||||||
|
let l:return = bufwinnr('%')
|
||||||
|
execute 'keepalt' self.winnr . 'wincmd w'
|
||||||
|
normal! Gzb
|
||||||
|
execute 'keepalt' l:return . 'wincmd w'
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
function! s:output.destroy() dict
|
||||||
|
autocmd! vimtex_output_window
|
||||||
|
augroup! vimtex_output_window
|
||||||
|
unlet s:output
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Better automatic update
|
" Better automatic update
|
||||||
augroup vimtex_tmp_update
|
augroup vimtex_output_window
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufEnter * silent! checktime
|
autocmd BufDelete <buffer> call s:output.destroy()
|
||||||
autocmd CursorHold * silent! checktime
|
autocmd BufEnter * call s:output.update()
|
||||||
autocmd CursorHoldI * silent! checktime
|
autocmd FocusGained * call s:output.update()
|
||||||
autocmd CursorMoved * silent! checktime
|
autocmd CursorHold * call s:output.update()
|
||||||
autocmd CursorMovedI * silent! checktime
|
autocmd CursorHoldI * call s:output.update()
|
||||||
|
autocmd CursorMoved * call s:output.update()
|
||||||
|
autocmd CursorMovedI * call s:output.update()
|
||||||
augroup END
|
augroup END
|
||||||
silent exe 'autocmd! BufDelete ' . tmp . ' augroup! vimtex_tmp_update'
|
|
||||||
|
|
||||||
" Set some mappings
|
" Set some mappings
|
||||||
nnoremap <buffer> <silent> q :bwipeout<cr>
|
nnoremap <buffer> <silent> q :bwipeout<cr>
|
||||||
|
Loading…
Reference in New Issue
Block a user