Skip to content

Commit 3fedd42

Browse files
author
skywind3000
committed
1. fixed neovim/windows: command name containing spaces will break
2. new: VIM_PRONAME, VIM_DIRNAME, VIM_CLINE
1 parent edf1463 commit 3fedd42

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

plugin/asyncrun.vim

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Maintainer: skywind3000 (at) gmail.com, 2016, 2017, 2018, 2019, 2020
44
" Homepage: http://www.vim.org/scripts/script.php?script_id=5431
55
"
6-
" Last Modified: 2020/02/16 00:47
6+
" Last Modified: 2020/02/16 14:00
77
"
88
" Run shell command in background and output to quickfix:
99
" :AsyncRun[!] [options] {cmd} ...
@@ -652,20 +652,13 @@ function! s:AsyncRun_Job_Start(cmd)
652652
call s:ErrorMsg("empty arguments")
653653
return -3
654654
endif
655+
let l:args = []
655656
if g:asyncrun_shell == ''
656-
if !executable(&shell)
657-
let l:text = "invalid config in &shell and &shellcmdflag"
658-
call s:ErrorMsg(l:text . ", &shell must be an executable.")
659-
return -4
660-
endif
661-
let l:args = [&shell, &shellcmdflag]
657+
let l:args += split(&shell)
658+
let l:args += split(&shellcmdflag)
662659
else
663-
if !executable(g:asyncrun_shell)
664-
let l:text = "invalid config in g:asyncrun_shell"
665-
call s:ErrorMsg(l:text . ", it must be an executable.")
666-
return -4
667-
endif
668-
let l:args = [g:asyncrun_shell, g:asyncrun_shellflag]
660+
let l:args += split(g:asyncrun_shell)
661+
let l:args += split(g:asyncrun_shellflag)
669662
endif
670663
let s:async_info.errorformat = s:async_efm
671664
let l:name = []
@@ -675,7 +668,11 @@ function! s:AsyncRun_Job_Start(cmd)
675668
let l:args += [a:cmd]
676669
else
677670
let l:tmp = s:ScriptWrite(a:cmd, 0)
678-
let l:args += [l:tmp]
671+
if s:async_nvim == 0
672+
let l:args += [l:tmp]
673+
else
674+
let l:args = shellescape(l:tmp)
675+
endif
679676
endif
680677
elseif type(a:cmd) == 3
681678
if s:asyncrun_windows == 0
@@ -1522,13 +1519,16 @@ function! asyncrun#run(bang, opts, args, ...)
15221519
let l:macros['VIM_RELNAME'] = expand("%:p:.")
15231520
let l:macros['VIM_CWORD'] = expand("<cword>")
15241521
let l:macros['VIM_CFILE'] = expand("<cfile>")
1522+
let l:macros['VIM_CLINE'] = line('.')
15251523
let l:macros['VIM_VERSION'] = ''.v:version
15261524
let l:macros['VIM_SVRNAME'] = v:servername
15271525
let l:macros['VIM_COLUMNS'] = ''.&columns
15281526
let l:macros['VIM_LINES'] = ''.&lines
15291527
let l:macros['VIM_GUI'] = has('gui_running')? 1 : 0
15301528
let l:macros['VIM_ROOT'] = asyncrun#get_root('%')
15311529
let l:macros['VIM_HOME'] = expand(split(&rtp, ',')[0])
1530+
let l:macros['VIM_PRONAME'] = fnamemodify(l:macros['VIM_ROOT'], ':t')
1531+
let l:macros['VIM_DIRNAME'] = fnamemodify(l:macros['VIM_CWD'], ':t')
15321532
let l:macros['<cwd>'] = l:macros['VIM_CWD']
15331533
let l:macros['<root>'] = l:macros['VIM_ROOT']
15341534
let l:retval = ''
@@ -1579,6 +1579,7 @@ function! asyncrun#run(bang, opts, args, ...)
15791579
let l:macros['VIM_RELDIR'] = expand("%:h:.")
15801580
let l:macros['VIM_RELNAME'] = expand("%:p:.")
15811581
let l:macros['VIM_CFILE'] = expand("<cfile>")
1582+
let l:macros['VIM_DIRNAME'] = fnamemodify(l:macros['VIM_CWD'], ':t')
15821583
let l:macros['<cwd>'] = l:macros['VIM_CWD']
15831584
endif
15841585

@@ -1650,7 +1651,7 @@ endfunc
16501651
" asyncrun -version
16511652
"----------------------------------------------------------------------
16521653
function! asyncrun#version()
1653-
return '2.4.2'
1654+
return '2.4.3'
16541655
endfunc
16551656

16561657

0 commit comments

Comments
 (0)