Skip to content

Commit bd240b2

Browse files
author
skywind3000
committed
new "-runner=xxx" option can work as an aliase to "-mode=term -pos=xxx"
1 parent ea59f76 commit bd240b2

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

plugin/asyncrun.vim

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
" asyncrun.vim - Run shell commands in background and output to quickfix
22
"
3-
" Maintainer: skywind3000 (at) gmail.com, 2016-2022
3+
" Maintainer: skywind3000 (at) gmail.com, 2016-2023
44
" Homepage: https://github.com/skywind3000/asyncrun.vim
55
"
6-
" Last Modified: 2022/11/29 07:05
6+
" Last Modified: 2023/01/18 19:58
77
"
88
" Run shell command in background and output to quickfix:
99
" :AsyncRun[!] [options] {cmd} ...
@@ -1716,6 +1716,13 @@ function! s:run(opts)
17161716

17171717
let l:mode = get(l:modemap, l:mode, l:mode)
17181718

1719+
" alias "-runner=name" to "-mode=term -pos=name"
1720+
if get(l:opts, 'runner', '') != ''
1721+
let l:opts.pos = get(l:opts, 'runner', '')
1722+
let l:opts.mode = 6
1723+
let l:mode = 6
1724+
endif
1725+
17191726
" alias "-mode=raw" to "-mode=async -raw=1"
17201727
if type(l:mode) == type('') && l:mode == 'raw'
17211728
let l:mode = 0
@@ -1781,14 +1788,8 @@ function! s:run(opts)
17811788
let test = ['cygwin', 'msys', 'mingw32', 'mingw64']
17821789
let test += ['clang64', 'clang32']
17831790
if has_key(g:asyncrun_program, name) != 0
1784-
let l:F = g:asyncrun_program[name]
1785-
if type(l:F) == type('')
1786-
let t = l:F
1787-
unlet l:F
1788-
let l:F = function(t)
1789-
endif
1790-
unsilent let l:command = l:F(l:opts)
1791-
unlet l:F
1791+
unsilent let hr = call call(g:asyncrun_program[name], [l:opts])
1792+
unsilent let l:command = hr
17921793
elseif index(test, name) >= 0
17931794
unsilent let l:command = s:program_msys(l:opts)
17941795
else
@@ -1840,17 +1841,14 @@ function! s:run(opts)
18401841
exec strpart(t, 1)
18411842
return ''
18421843
elseif l:runner != ''
1843-
let l:F = g:asyncrun_runner[l:runner]
1844-
if type(l:F) == type('')
1845-
let l:t = l:F
1846-
unlet l:F
1847-
let l:F = function(l:t)
1848-
endif
18491844
let obj = deepcopy(l:opts)
18501845
let obj.cmd = command
18511846
let obj.src = a:opts.cmd
1852-
call l:F(obj)
1853-
unlet l:F
1847+
if has_key(g:asyncrun_runner, l:runner)
1848+
call call(g:asyncrun_runner[l:runner], [obj])
1849+
else
1850+
call s:ErrorMsg(l:runner . " not found in g:asyncrun_runner")
1851+
endif
18541852
return ''
18551853
endif
18561854

@@ -2239,7 +2237,7 @@ endfunc
22392237
" asyncrun - version
22402238
"----------------------------------------------------------------------
22412239
function! asyncrun#version()
2242-
return '2.11.14'
2240+
return '2.11.15'
22432241
endfunc
22442242

22452243

0 commit comments

Comments
 (0)