Skip to content

Commit 953a0f0

Browse files
committed
Open result buffer argument to command added
1 parent 9ef7f0d commit 953a0f0

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

autoload/executor.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let s:previous_buffer = ''
1111
let s:positions = ['top', 'bottom', 'left', 'right', 'tab']
1212
let s:default_position = 'bottom'
1313

14-
func! executor#exec(start_line, end_line, ...)
14+
func! executor#exec(start_line, end_line, open_result, ...)
1515
if !exists('g:loaded_buffr')
1616
call s:show_error('Please, install vim-buffr plugin first') | return
1717
endif
@@ -20,9 +20,9 @@ func! executor#exec(start_line, end_line, ...)
2020
let l:selection = getline(a:start_line, a:end_line)
2121

2222
if g:executor_exec_async && (v:version >= 800)
23-
call executor#async#exec(l:command, l:selection)
23+
call executor#async#exec(l:command, l:selection, a:open_result)
2424
else
25-
call executor#default#exec(l:command, l:selection)
25+
call executor#default#exec(l:command, l:selection, a:open_result)
2626
end
2727
endfunc
2828

autoload/executor/async.vim

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
" Licence: BSD-3-Clause
88
" ===========================================================================
99

10-
func! executor#async#exec(command, selection)
10+
func! executor#async#exec(command, selection, open_result)
1111
let s:command = a:command
1212
let s:result = []
13+
let s:open_result = a:open_result
1314
call s:execute(a:command, a:selection)
1415
endfunc
1516

@@ -36,5 +37,7 @@ func! s:out_callback(channel, data)
3637
endfunc
3738

3839
func! s:exit_callback(job, status)
39-
call executor#open_result(s:result, s:command)
40+
if s:open_result
41+
call executor#open_result(s:result, s:command)
42+
end
4043
endfunc

autoload/executor/default.vim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
" Licence: BSD-3-Clause
88
" ===========================================================================
99

10-
func! executor#default#exec(command, selection)
10+
func! executor#default#exec(command, selection, open_result)
1111
let l:result = s:execute(a:command, a:selection)
12-
call executor#open_result(split(l:result, "\n"), a:command)
12+
if a:open_result
13+
call executor#open_result(split(l:result, "\n"), a:command)
14+
endif
1315
endfunc
1416

1517
func! s:execute(command, selection)

doc/executor.vim

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ COMMANDS *vim-executor-commands*
4646

4747
*:Exec*
4848

49-
:[range]Exec {command} Execute shell {command} and open new buffer
50-
with a command output. If one line selected
51-
this line will be executed as a command, with
52-
more than one - plugin will pass lines as a file
53-
to the command as argument.
49+
:[range]Exec[!] {command} Execute shell {command} and open new buffer
50+
with the command output.
51+
If one line selected this line will be executed
52+
as a command, with more than one - plugin will
53+
pass lines to a command as an argument.
54+
If ! is given, buffer with result will not opened.
5455

5556
===============================================================================
5657
OPTIONS *vim-executor-options*

plugin/executor.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if !exists('g:executor_exec_async')
2727
let g:executor_exec_async = 1
2828
endif
2929

30-
comm! -nargs=+ -range=0 -complete=shellcmd Exec
31-
\ call executor#exec(<line1>, <line2>, <q-args>)
30+
comm! -nargs=+ -bang -range=0 -complete=shellcmd Exec
31+
\ call executor#exec(<line1>, <line2>, empty('<bang>'), <q-args>)
3232

3333
let g:loaded_executor = 1

0 commit comments

Comments
 (0)