Skip to content

Commit

Permalink
Allow mods and a count to control splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
rbong committed May 25, 2019
1 parent 75b3004 commit cb40f52
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
4 changes: 3 additions & 1 deletion doc/plugin/vifm-plugin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ terminal buffer, it will be used. Enabled by default inside GUI version.

*g:vifm_embed_split*
A boolean variable. When evaluates to true and Vifm is embedded in a
terminal, it will be run inside a new split. False by default.
terminal, it will be run inside a new split. This allows commands to support
|<mods>| and a |<count>| for controlling the orientation and size of the
split. False by default.

Extension for "vifm" filetype~

Expand Down
28 changes: 17 additions & 11 deletions plugin/vifm.vim
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,26 @@ endtry

let s:tab_drop_cmd = (s:has_drop ? 'tablast | tab drop' : 'tabedit')

command! -bar -nargs=* -complete=dir Vifm :call s:StartVifm('edit', <f-args>)
command! -bar -nargs=* -complete=dir EditVifm :call s:StartVifm('edit', <f-args>)
command! -bar -nargs=* -complete=dir VsplitVifm :call s:StartVifm('vsplit', <f-args>)
command! -bar -nargs=* -complete=dir SplitVifm :call s:StartVifm('split', <f-args>)
command! -bar -nargs=* -complete=dir DiffVifm :call s:StartVifm('vert diffsplit', <f-args>)
command! -bar -nargs=* -complete=dir TabVifm :call s:StartVifm(s:tab_drop_cmd, <f-args>)

function! s:StartVifm(editcmd, ...)
command! -bar -nargs=* -count -complete=dir Vifm
\ :call s:StartVifm('<mods>', <count>, 'edit', <f-args>)
command! -bar -nargs=* -count -complete=dir EditVifm
\ :call s:StartVifm('<mods>', <count>, 'edit', <f-args>)
command! -bar -nargs=* -count -complete=dir VsplitVifm
\ :call s:StartVifm('<mods>', <count>, 'vsplit', <f-args>)
command! -bar -nargs=* -count -complete=dir SplitVifm
\ :call s:StartVifm('<mods>', <count>, 'split', <f-args>)
command! -bar -nargs=* -count -complete=dir DiffVifm
\ :call s:StartVifm('<mods>', <count>, 'vert diffsplit', <f-args>)
command! -bar -nargs=* -count -complete=dir TabVifm
\ :call s:StartVifm('<mods>', <count>, s:tab_drop_cmd, <f-args>)

function! s:StartVifm(mods, count, editcmd, ...)
echohl WarningMsg | echo 'vifm executable wasn''t found' | echohl None
endfunction

call vifm#globals#Init()

function! s:StartVifm(editcmd, ...)
function! s:StartVifm(mods, count, editcmd, ...)
if a:0 > 2
echohl WarningMsg | echo 'Too many arguments' | echohl None
return
Expand Down Expand Up @@ -94,8 +100,8 @@ function! s:StartVifm(editcmd, ...)
silent! bdelete! #
call s:HandleRunResults(a:code, data.listf, data.typef, data.editcmd)
endfunction
if get(g:, 'vifm_embed_split')
new
if get(g:, 'vifm_embed_split', 0)
exec a:mods . ' ' . (a:count ? a:count : '') . 'new'
else
enew
endif
Expand Down

0 comments on commit cb40f52

Please sign in to comment.