Skip to content

Commit cac8762

Browse files
committed
Remove position and exec_async options
Use window split mods instead of position and detect exec_async by vim version
1 parent dad68a1 commit cac8762

File tree

5 files changed

+25
-45
lines changed

5 files changed

+25
-45
lines changed

autoload/executor.vim

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,30 @@
88
" ===========================================================================
99

1010
let s:previous_buffer = ''
11-
let s:positions = ['top', 'bottom', 'left', 'right', 'tab']
12-
let s:default_position = 'bottom'
1311

14-
func! executor#exec(start_line, end_line, open_result, ...) abort
12+
func! executor#exec(start_line, end_line, open_result, mods, ...) abort
1513
if !exists('g:loaded_buffr')
1614
call s:show_error('Please, install vim-buffr plugin first') | return
1715
endif
1816

1917
let l:command = join(a:000)
2018
let l:selection = getline(a:start_line, a:end_line)
2119

22-
if g:executor_exec_async && (v:version >= 800)
23-
call executor#async#exec(l:command, l:selection, a:open_result)
20+
if v:version >= 800
21+
call executor#async#exec(l:command, l:selection, a:open_result, a:mods)
2422
else
25-
call executor#default#exec(l:command, l:selection, a:open_result)
23+
call executor#default#exec(l:command, l:selection, a:open_result, a:mods)
2624
endif
2725
endfunc
2826

29-
func! executor#open_result(result, command) abort
27+
func! executor#open_result(result, command, mods) abort
3028
let l:buffer_name = s:buffer_name(a:command)
31-
call s:open_buffer(l:buffer_name)
29+
call s:open_buffer(l:buffer_name, a:mods)
3230
call append(0, a:result)
3331
silent normal! Gddgg
3432
endfunc
3533

36-
func! s:open_buffer(buffer_name) abort
34+
func! s:open_buffer(buffer_name, mods) abort
3735
let l:buffer_name = a:buffer_name
3836

3937
if g:executor_reuse_buffer
@@ -43,10 +41,7 @@ func! s:open_buffer(buffer_name) abort
4341
let s:previous_buffer = a:buffer_name
4442
endif
4543

46-
call buffr#open_or_create_buffer({
47-
\ 'position': s:buffer_position(),
48-
\ 'name': l:buffer_name
49-
\ })
44+
call buffr#open_or_create_buffer(l:buffer_name, a:mods)
5045
call s:set_buffer_defaults()
5146

5247
if g:executor_reuse_buffer
@@ -63,10 +58,6 @@ func! s:buffer_name(command) abort
6358
return l:name
6459
endfunc
6560

66-
func! s:buffer_position() abort
67-
return index(s:positions, g:executor_position) < 0 ? s:default_position : g:executor_position
68-
endfunc
69-
7061
func! s:set_buffer_defaults() abort
7162
setlocal buftype=nofile
7263
setlocal bufhidden=wipe

autoload/executor/async.vim

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

10-
func! executor#async#exec(command, selection, open_result) abort
10+
func! executor#async#exec(command, selection, open_result, mods) abort
1111
let s:command = a:command
1212
let s:result = []
1313
let s:open_result = a:open_result
14-
call s:execute(a:command, a:selection)
14+
let s:mods = a:mods
15+
call s:execute(a:command, a:selection, a:mods)
1516
endfunc
1617

17-
func! s:execute(command, selection) abort
18+
func! s:execute(command, selection, mods) abort
1819
let l:command = a:command
1920

2021
if len(a:selection) == 1 && !empty(a:selection[0])
@@ -38,6 +39,6 @@ endfunc
3839

3940
func! s:exit_callback(job, status) abort
4041
if s:open_result
41-
call executor#open_result(s:result, s:command)
42+
call executor#open_result(s:result, s:command, s:mods)
4243
endif
4344
endfunc

autoload/executor/default.vim

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

10-
func! executor#default#exec(command, selection, open_result) abort
10+
func! executor#default#exec(command, selection, open_result, mods) abort
1111
let l:result = s:execute(a:command, a:selection)
1212
if a:open_result
13-
call executor#open_result(split(l:result, "\n"), a:command)
13+
call executor#open_result(split(l:result, "\n"), a:command, a:mods)
1414
endif
1515
endfunc
1616

doc/executor.txt

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,28 @@ INSTALL *vim-executor-install*
2121
Vundle https://github.com/VundleVim/Vundle.vim
2222
>
2323
Plugin 'lucerion/vim-executor'
24+
Plugin 'lucerion/vim-buffr'
2425
<
2526
Pathogen https://github.com/tpope/vim-pathogen
2627
>
2728
cd ~/.vim/bundle
2829
git clone https://github.com/lucerion/vim-executor
30+
git clone https://github.com/lucerion/vim-buffr
2931
<
3032
NeoBundle https://github.com/Shougo/neobundle.vim
3133
>
3234
NeoBundle 'lucerion/vim-executor'
35+
NeoBundle 'lucerion/vim-buffr'
3336
<
3437
vim-plug https://github.com/junegunn/vim-plug
3538
>
3639
Plug 'lucerion/vim-executor'
40+
Plug 'lucerion/vim-buffr'
3741
<
3842
Manual
3943
>
4044
git clone https://github.com/lucerion/vim-executor
45+
git clone https://github.com/lucerion/vim-buffr
4146
<
4247
copy all of the files into your ~/.vim directory
4348

@@ -52,17 +57,13 @@ COMMANDS *vim-executor-commands*
5257
then one - passes to command as an argument.
5358
If ! is given, buffer with the result not
5459
be opened.
60+
Window split modes (|leftabove|, |rightbelow|,
61+
|topleft|, |botright|, |vsplit|, |tab|, etc)
62+
are available.
5563

5664
===============================================================================
5765
OPTIONS *vim-executor-options*
5866

59-
*g:executor_position*
60-
61-
Result buffer position.
62-
63-
Possible values: 'top', 'bottom', 'left', 'right', 'tab'
64-
Default value: 'bottom'
65-
6667
*g:executor_buffer_name*
6768

6869
A pattern for a buffer name. {command} will be replaced with executed command,
@@ -76,12 +77,6 @@ Reuse buffer with results instead of opening a new one.
7677

7778
Default value: 0
7879

79-
*g:executor_exec_async*
80-
81-
Enable/disable async command execution (only for vim version > 8.0).
82-
83-
Default value: 1
84-
8580
===============================================================================
8681
CHANGELOG *vim-executor-changelog*
8782

plugin/executor.vim

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ if exists('g:loaded_executor') || &compatible || v:version < 700
1212
endif
1313
let g:loaded_executor = 1
1414

15-
if !exists('g:executor_position')
16-
let g:executor_position = 'bottom'
17-
endif
18-
1915
if !exists('g:executor_buffer_name')
2016
let g:executor_buffer_name = '{command}'
2117
endif
@@ -24,8 +20,5 @@ if !exists('g:executor_reuse_buffer')
2420
let g:executor_reuse_buffer = 0
2521
endif
2622

27-
if !exists('g:executor_exec_async')
28-
let g:executor_exec_async = 1
29-
endif
30-
31-
comm! -nargs=+ -bang -range=0 -complete=shellcmd Exec call executor#exec(<line1>, <line2>, empty('<bang>'), <q-args>)
23+
comm! -nargs=+ -bang -range=0 -complete=shellcmd Exec
24+
\ call executor#exec(<line1>, <line2>, empty('<bang>'), <q-mods>, <q-args>)

0 commit comments

Comments
 (0)