Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added custom callback for compile_command #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions autoload/dispatch.vim
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ if !exists('s:makes')
let s:files = {}
endif

function! dispatch#compile_command(bang, args) abort
function! dispatch#compile_command(bang, args, ...) abort
if !empty(a:args)
let args = a:args
else
Expand Down Expand Up @@ -297,6 +297,8 @@ function! dispatch#compile_command(bang, args) abort
let request.command = args
endif

let request.callback = a:0 >= 1 ? a:1 : "dispatch#default_callback"

if empty(request.compiler)
unlet request.compiler
endif
Expand Down Expand Up @@ -395,6 +397,13 @@ function! dispatch#completed(request) abort
return get(s:request(a:request), 'completed', 0)
endfunction

function! dispatch#default_callback(request) abort
if !a:request.background
call s:cgetfile(a:request, 0, 0)
redraw
endif
endfunction

function! dispatch#complete(file, ...) abort
if !dispatch#completed(a:file)
let request = s:request(a:file)
Expand All @@ -406,9 +415,8 @@ function! dispatch#complete(file, ...) abort
echo 'Finished :Dispatch' request.command
endif
endif
if !request.background
call s:cgetfile(request, 0, 0)
redraw
if has_key(request, 'callback') && !empty(request.callback)
exec 'call '.request.callback.'(request)'
endif
endif
return ''
Expand Down