From 6c59a318fdbe9d7cf504693207b2e72c8900cad9 Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Wed, 19 Jul 2017 09:10:42 +0200 Subject: [PATCH] Add a count to Copen to set quickfix height --- autoload/dispatch.vim | 9 +++++++-- autoload/dispatch/tmux.vim | 2 +- plugin/dispatch.vim | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/autoload/dispatch.vim b/autoload/dispatch.vim index 1d8755f..b7ea36e 100644 --- a/autoload/dispatch.vim +++ b/autoload/dispatch.vim @@ -842,7 +842,12 @@ endfunction " }}}1 " Quickfix window {{{1 -function! dispatch#copen(bang) abort +function! dispatch#copen(bang, count) abort + if a:count != 0 + let g:dispatch_temporary_quickfix_height = a:count + elseif has_key(g:, 'dispatch_temporary_quickfix_height') + unlet g:dispatch_temporary_quickfix_height + endif if empty(s:makes) return 'echoerr ' . string('No dispatches yet') endif @@ -895,7 +900,7 @@ endfunction function! s:cwindow(request, all, copen) call s:cgetfile(a:request, a:all) - let height = get(g:, 'dispatch_quickfix_height', 10) + let height = get(g:, 'dispatch_temporary_quickfix_height', get(g:, 'dispatch_quickfix_height', 10)) let was_qf = s:is_quickfix() execute 'botright' (a:copen ? 'copen' : 'cwindow') height if !was_qf && s:is_quickfix() && a:copen !=# -2 diff --git a/autoload/dispatch/tmux.vim b/autoload/dispatch/tmux.vim index 872a328..d00b664 100644 --- a/autoload/dispatch/tmux.vim +++ b/autoload/dispatch/tmux.vim @@ -48,7 +48,7 @@ function! dispatch#tmux#make(request) abort \ . ' > ' . a:request.file . '.complete'] : []))) let title = shellescape(get(a:request, 'title', get(a:request, 'compiler', 'make'))) - let height = get(g:, 'dispatch_tmux_height', get(g:, 'dispatch_quickfix_height', 10)) + let height = get(g:, 'dispatch_tmux_height', get(g:, 'dispatch_temporary_quickfix_height', get(g:, 'dispatch_quickfix_height', 10))) if get(a:request, 'background', 0) let cmd = 'new-window -d -n '.title elseif has('gui_running') || empty($TMUX) || (!empty(''.session) && session !=# system('tmux display-message -p "#S"')[0:-2]) diff --git a/plugin/dispatch.vim b/plugin/dispatch.vim index 93488c7..2d8a518 100644 --- a/plugin/dispatch.vim +++ b/plugin/dispatch.vim @@ -25,7 +25,7 @@ command! -bang -nargs=* -complete=customlist,dispatch#command_complete Spawn command! -bang -nargs=* -complete=customlist,dispatch#command_complete Start \ execute dispatch#start_command(0, ) -command! -bang -bar Copen call dispatch#copen(0) +command! -bang -count -bar Copen call dispatch#copen(0, ) function! DispatchComplete(id) abort return dispatch#complete(a:id)