Improved docs, improved MuPDF support
This commit is contained in:
parent
270f2a80ba
commit
7f117363d8
@ -88,6 +88,14 @@ function! latex#latexmk#callback(status) " {{{1
|
|||||||
echo "latexmk compile: fail"
|
echo "latexmk compile: fail"
|
||||||
endif
|
endif
|
||||||
echohl None
|
echohl None
|
||||||
|
|
||||||
|
" Get window ID after first callback
|
||||||
|
if s:first_callback
|
||||||
|
let s:first_callback = 0
|
||||||
|
if g:latex_view_method == 'mupdf'
|
||||||
|
call latex#view#mupdf_poststart()
|
||||||
|
endif
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
@ -141,41 +149,19 @@ endfunction
|
|||||||
" }}}1
|
" }}}1
|
||||||
function! latex#latexmk#compile() " {{{1
|
function! latex#latexmk#compile() " {{{1
|
||||||
let data = g:latex#data[b:latex.id]
|
let data = g:latex#data[b:latex.id]
|
||||||
|
|
||||||
if data.pid
|
if data.pid
|
||||||
echomsg "latexmk is already running for `" . data.base . "'"
|
echomsg "latexmk is already running for `" . data.base . "'"
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call s:latexmk_set_cmd(data)
|
" Build command line and start latexmk
|
||||||
|
let exe = s:latexmk_build_cmd(data)
|
||||||
" Start latexmk
|
|
||||||
let exe = {}
|
|
||||||
let exe.null = 0
|
|
||||||
if !g:latex_latexmk_continuous && !g:latex_latexmk_background
|
|
||||||
let exe.bg = 0
|
|
||||||
let exe.silent = 0
|
|
||||||
endif
|
|
||||||
let exe.cmd = data.cmds.compile
|
|
||||||
call latex#util#execute(exe)
|
call latex#util#execute(exe)
|
||||||
|
|
||||||
if g:latex_latexmk_continuous
|
if g:latex_latexmk_continuous
|
||||||
call s:latexmk_set_pid(data)
|
call s:latexmk_set_pid(data)
|
||||||
|
|
||||||
echomsg 'latexmk started in continuous mode ...'
|
echomsg 'latexmk started in continuous mode ...'
|
||||||
|
|
||||||
" Get window ID
|
|
||||||
if g:latex_view_method == 'mupdf'
|
|
||||||
" give time to read window ID
|
|
||||||
sleep
|
|
||||||
let cmd = 'xdotool search --class MuPDF'
|
|
||||||
let mupdf_ids = systemlist(cmd)
|
|
||||||
|
|
||||||
if len(mupdf_ids) == 0
|
|
||||||
let g:latex#data[b:latex.id].mupdf_id = 0
|
|
||||||
else
|
|
||||||
let g:latex#data[b:latex.id].mupdf_id = mupdf_ids[-1]
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
else
|
||||||
echomsg 'latexmk compiling ...'
|
echomsg 'latexmk compiling ...'
|
||||||
endif
|
endif
|
||||||
@ -336,7 +322,10 @@ endfunction
|
|||||||
" }}}1
|
" }}}1
|
||||||
|
|
||||||
" Helper functions for latexmk command
|
" Helper functions for latexmk command
|
||||||
function! s:latexmk_set_cmd(data) " {{{1
|
function! s:latexmk_build_cmd(data) " {{{1
|
||||||
|
let exe = {}
|
||||||
|
let exe.null = 0
|
||||||
|
|
||||||
" Note: We don't send output to /dev/null, but rather to a temporary file,
|
" Note: We don't send output to /dev/null, but rather to a temporary file,
|
||||||
" which allows inspection of latexmk output
|
" which allows inspection of latexmk output
|
||||||
let tmp = tempname()
|
let tmp = tempname()
|
||||||
@ -371,6 +360,7 @@ function! s:latexmk_set_cmd(data) " {{{1
|
|||||||
let cmd .= ' -e ''$success_cmd .= "' . success . '"'''
|
let cmd .= ' -e ''$success_cmd .= "' . success . '"'''
|
||||||
let cmd .= ' -e ''$failure_cmd .= "' . failed . '"'''
|
let cmd .= ' -e ''$failure_cmd .= "' . failed . '"'''
|
||||||
endif
|
endif
|
||||||
|
let s:first_callback = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let cmd .= ' ' . shellescape(a:data.base)
|
let cmd .= ' ' . shellescape(a:data.base)
|
||||||
@ -384,8 +374,16 @@ function! s:latexmk_set_cmd(data) " {{{1
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let exe.cmd = cmd
|
||||||
let a:data.cmds.compile = cmd
|
let a:data.cmds.compile = cmd
|
||||||
let a:data.tmp = tmp
|
let a:data.tmp = tmp
|
||||||
|
|
||||||
|
if !g:latex_latexmk_continuous && !g:latex_latexmk_background
|
||||||
|
let exe.bg = 0
|
||||||
|
let exe.silent = 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
return exe
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
|
@ -19,6 +19,7 @@ function! latex#view#init(initialized) " {{{1
|
|||||||
\ })
|
\ })
|
||||||
call latex#util#set_default('g:latex_view_method', '')
|
call latex#util#set_default('g:latex_view_method', '')
|
||||||
call latex#util#set_default('g:latex_view_mupdf_options', '')
|
call latex#util#set_default('g:latex_view_mupdf_options', '')
|
||||||
|
call latex#util#set_default('g:latex_view_mupdf_send_keys', '')
|
||||||
call latex#util#set_default('g:latex_view_okular_options', '')
|
call latex#util#set_default('g:latex_view_okular_options', '')
|
||||||
call latex#util#set_default('g:latex_view_sumatrapdf_options', '')
|
call latex#util#set_default('g:latex_view_sumatrapdf_options', '')
|
||||||
call latex#util#error_deprecated('g:latex_viewer')
|
call latex#util#error_deprecated('g:latex_viewer')
|
||||||
@ -94,6 +95,33 @@ function! latex#view#mupdf() "{{{1
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" }}}1
|
" }}}1
|
||||||
|
function! latex#view#mupdf_poststart() "{{{1
|
||||||
|
" First get the window id
|
||||||
|
let mupdf_ids = []
|
||||||
|
if executable('xdotool')
|
||||||
|
let cmd = 'xdotool search --class MuPDF'
|
||||||
|
let mupdf_ids = systemlist(cmd)
|
||||||
|
endif
|
||||||
|
if len(mupdf_ids) == 0
|
||||||
|
echomsg "Couldn't find MuPDF window ID!"
|
||||||
|
let g:latex#data[b:latex.id].mupdf_id = 0
|
||||||
|
else
|
||||||
|
let g:latex#data[b:latex.id].mupdf_id = mupdf_ids[-1]
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Next return focus to vim and send some keys to mupdf if desired
|
||||||
|
if executable('xdotool')
|
||||||
|
if g:latex_view_mupdf_send_keys != ''
|
||||||
|
let cmd = 'xdotool key --window ' . g:latex#data[b:latex.id].mupdf_id
|
||||||
|
let cmd .= ' ' . g:latex_view_mupdf_send_keys
|
||||||
|
call system(cmd)
|
||||||
|
endif
|
||||||
|
|
||||||
|
silent execute '!xdotool windowfocus ' . v:windowid
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"}}}1
|
||||||
function! latex#view#mupdf_rsearch() "{{{1
|
function! latex#view#mupdf_rsearch() "{{{1
|
||||||
if !s:mupdf_exists_win()
|
if !s:mupdf_exists_win()
|
||||||
echomsg "Can't search backwards: Is the PDF file open?"
|
echomsg "Can't search backwards: Is the PDF file open?"
|
||||||
@ -268,17 +296,7 @@ function! s:mupdf_start() "{{{1
|
|||||||
call latex#util#execute(exe)
|
call latex#util#execute(exe)
|
||||||
let g:latex#data[b:latex.id].cmds.view = exe.cmd
|
let g:latex#data[b:latex.id].cmds.view = exe.cmd
|
||||||
|
|
||||||
" Get window ID
|
call latex#view#mupdf_poststart()
|
||||||
if executable('xdotool')
|
|
||||||
let cmd = 'xdotool search --class MuPDF'
|
|
||||||
let mupdf_ids = systemlist(cmd)
|
|
||||||
if len(mupdf_ids) == 0
|
|
||||||
echomsg "Couldn't find MuPDF window ID!"
|
|
||||||
let g:latex#data[b:latex.id].mupdf_id = 0
|
|
||||||
else
|
|
||||||
let g:latex#data[b:latex.id].mupdf_id = mupdf_ids[-1]
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"}}}1
|
"}}}1
|
||||||
|
@ -566,6 +566,11 @@ Set custom options for the given viewer. >
|
|||||||
let g:latex_view_mupdf_options = ''
|
let g:latex_view_mupdf_options = ''
|
||||||
let g:latex_view_okular_options = ''
|
let g:latex_view_okular_options = ''
|
||||||
let g:latex_view_sumatrapdf_options = ''
|
let g:latex_view_sumatrapdf_options = ''
|
||||||
|
<
|
||||||
|
*g:latex_view_mupdf_send_keys*
|
||||||
|
String of keys sent to MuPDF after the PDF file has been opened. The keys are
|
||||||
|
sent by the function |latex#view#mupdf_poststart|. >
|
||||||
|
let g:latex_view_mupdf_send_keys = ''
|
||||||
<
|
<
|
||||||
==============================================================================
|
==============================================================================
|
||||||
OMNI COMPLETION *vim-latex-completion*
|
OMNI COMPLETION *vim-latex-completion*
|
||||||
@ -1016,7 +1021,12 @@ Overview:~
|
|||||||
|latex#util#kpsewhich|
|
|latex#util#kpsewhich|
|
||||||
|latex#util#tex2tree|
|
|latex#util#tex2tree|
|
||||||
|latex#util#tree2tex|
|
|latex#util#tree2tex|
|
||||||
|latex#view#view|
|
|latex#view#general|
|
||||||
|
|latex#view#mupdf|
|
||||||
|
|latex#view#mupdf_poststart|
|
||||||
|
|latex#view#mupdf_rsearch|
|
||||||
|
|latex#view#okular|
|
||||||
|
|latex#view#sumatrapdf|
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
Detailed descriptions:~
|
Detailed descriptions:~
|
||||||
@ -1184,8 +1194,23 @@ Turn tex structure to a tree composed of lists. E.g. >
|
|||||||
Turns a tree composed of lists into tex structure. E.g. >
|
Turns a tree composed of lists into tex structure. E.g. >
|
||||||
[ "testing" , [ "tex2tree", []]] => { testing { tex2tree { } } }
|
[ "testing" , [ "tex2tree", []]] => { testing { tex2tree { } } }
|
||||||
<
|
<
|
||||||
*latex#view#view*
|
*latex#view#general*
|
||||||
Open the output file with the default viewer |g:latex_view_method|.
|
Open the output file with the viewer that is specified with the option
|
||||||
|
|g:latex_view_general_viewer|.
|
||||||
|
|
||||||
|
*latex#view#mupdf*
|
||||||
|
*latex#view#okular*
|
||||||
|
*latex#view#sumatrapdf*
|
||||||
|
First open the output file if it is not open with MuPDF/Okular/SumatraPDF.
|
||||||
|
Then perform a forward search.
|
||||||
|
|
||||||
|
*latex#view#mupdf_poststart*
|
||||||
|
Function that is called after the MuPDF window has been opened. The function
|
||||||
|
is used to run `xdotool` commands, for instance to return focus to vim and to
|
||||||
|
possibly send some keys to MuPDF as specified in |g:latex_view_mupdf_send_keys|.
|
||||||
|
|
||||||
|
*latex#view#mupdf_rsearch*
|
||||||
|
Perform a reverse search by use of `xdotool` and `synctex`.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
FAQ *vim-latex-faq*
|
FAQ *vim-latex-faq*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user