Skip to content

Commit 223dbaf

Browse files
committed
feat: allow ! for VimtexCompile to prevent stopping
refer: #2996
1 parent 264230b commit 223dbaf

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

autoload/vimtex/compiler.vim

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ function! vimtex#compiler#init_buffer() abort " {{{1
88
if !g:vimtex_compiler_enabled | return | endif
99

1010
" Define commands
11-
command! -buffer -nargs=* VimtexCompile call vimtex#compiler#compile(<f-args>)
12-
command! -buffer -bang -nargs=* VimtexCompileSS call vimtex#compiler#compile_ss(<f-args>)
11+
command! -buffer -bang -nargs=* VimtexCompile call vimtex#compiler#compile(<q-args>, <q-bang>)
12+
command! -buffer -nargs=* VimtexCompileSS call vimtex#compiler#compile_ss(<q-args>)
1313

1414
command! -buffer -range VimtexCompileSelected <line1>,<line2>call vimtex#compiler#compile_selected('command')
1515
command! -buffer VimtexCompileOutput call vimtex#compiler#output()
@@ -115,10 +115,13 @@ endfunction
115115
function! vimtex#compiler#compile(...) abort " {{{1
116116
if !b:vimtex.compiler.enabled | return | endif
117117

118-
if b:vimtex.compiler.is_running()
118+
let l:opts = a:0 > 0 ? a:1 : ''
119+
let l:bang = a:0 > 1 ? a:2 ==# '!' : v:false
120+
121+
if !b:vimtex.compiler.is_running()
122+
call vimtex#compiler#start(l:opts)
123+
elseif !l:bang
119124
call vimtex#compiler#stop()
120-
else
121-
call call('vimtex#compiler#start', a:000)
122125
endif
123126
endfunction
124127

@@ -132,7 +135,8 @@ function! vimtex#compiler#compile_ss(...) abort " {{{1
132135
return
133136
endif
134137

135-
call b:vimtex.compiler.start_single(expandcmd(join(a:000)))
138+
let l:opts = a:0 > 0 ? expandcmd(a:1) : ''
139+
call b:vimtex.compiler.start_single(l:opts)
136140

137141
if g:vimtex_compiler_silent | return | endif
138142
call vimtex#log#info('Compiler started in background!')
@@ -229,7 +233,8 @@ function! vimtex#compiler#start(...) abort " {{{1
229233
return
230234
endif
231235

232-
call b:vimtex.compiler.start(expandcmd(join(a:000)))
236+
let l:opts = a:0 > 0 ? expandcmd(a:1) : ''
237+
call b:vimtex.compiler.start(l:opts)
233238

234239
if g:vimtex_compiler_silent | return | endif
235240

doc/vimtex.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3586,11 +3586,14 @@ COMMANDS *vimtex-commands*
35863586

35873587
*:VimtexCompile*
35883588
*<plug>(vimtex-compile)*
3589-
:VimtexCompile [opts] If the compiler supports and is set to run in
3589+
:VimtexCompile[!] [opts] If the compiler supports and is set to run in
35903590
continuous mode, then this command works as
35913591
a compiler toggle. If not, this command will run
35923592
a single shot compilation.
35933593

3594+
If [!] is given, the command will only start
3595+
compilation, never stop it.
3596+
35943597
Arguments to the command will be passed on as options
35953598
when starting the compiler. This allows the user to
35963599
start the compiler with different options without

0 commit comments

Comments
 (0)