Skip to content

Commit

Permalink
Expose daemon kill function
Browse files Browse the repository at this point in the history
  • Loading branch information
maralla committed Nov 8, 2017
1 parent a8d0f78 commit 1cc55dd
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion autoload/completor/daemon.vim
Expand Up @@ -67,7 +67,7 @@ else
" vim8
function! s:job_start_daemon(cmd)
return job_start(a:cmd, {
\ 'out_cb': {c, m -> s:vim_daemon_handler(m)},
\ 'out_cb': {c,m->s:vim_daemon_handler(m)},
\ 'err_io': 'out',
\ 'mode': 'nl'
\ })
Expand All @@ -89,6 +89,7 @@ function! s:daemon.respawn(cmd, name)
endif
let self.job = s:job_start_daemon(a:cmd)
let self.type = a:name
let self.cmd = a:cmd
let self.requested = v:false
let self.t = localtime()
endfunction
Expand All @@ -102,6 +103,7 @@ function! s:daemon.status(name)
if exists('self.type') && self.type != a:name
if s ==# 'run'
call completor#compat#job_stop(self.job)
let s = completor#compat#job_status(self.job)
endif
return 'none'
endif
Expand Down Expand Up @@ -147,3 +149,20 @@ function! completor#daemon#process(action, cmd, name)
let s:daemon.requested = v:true
let s:daemon.t = localtime()
endfunction


function! s:check_status()
if s:daemon.status(s:daemon.type) != 'run'
echo 'Daemon killed'
endif
endfunction


function! completor#daemon#kill()
if has_key(s:daemon, 'type')
call s:daemon.kill()
call timer_start(300, {t->s:check_status()})
else
echo 'Daemon killed.'
endif
endfunction

0 comments on commit 1cc55dd

Please sign in to comment.