summaryrefslogtreecommitdiff
path: root/vimrc
diff options
context:
space:
mode:
authorjohannst <stoelp@eit.uni-kl.de>2016-11-10 22:44:41 +0100
committerjohannst <stoelp@eit.uni-kl.de>2016-11-10 22:44:41 +0100
commit9377f6b6cf8263290dbe4ad14b81ade1fc538f2e (patch)
tree9ba85f1d1827a4a921f9ae5c5a460fb2aa2419db /vimrc
parent65dc8dcfeea1441d0f93b938227135c20ddcb5e3 (diff)
downloaddotfiles-9377f6b6cf8263290dbe4ad14b81ade1fc538f2e.tar.gz
dotfiles-9377f6b6cf8263290dbe4ad14b81ade1fc538f2e.zip
vimrc added function to kill async job
Diffstat (limited to 'vimrc')
-rw-r--r--vimrc27
1 files changed, 20 insertions, 7 deletions
diff --git a/vimrc b/vimrc
index bc41df4..b57d314 100644
--- a/vimrc
+++ b/vimrc
@@ -345,21 +345,21 @@ if s:sandbox_enable
function! s:JobExitCB(job, status)
"execute 'cbuffer! ' . g:stderr_buffer
echom 'AsyncCmdProcessor: Job exited'
- let s:async_job_running=0
+ let s:gAsyncJobRunning=0
endfunction
- let s:async_job_running=0
+ let s:gAsyncJobRunning=0
function! s:AsyncCmdProcessor(...)
if a:0 == 0
echom 'AsyncCmdProcessor: no cmd specified'
return
endif
- if s:async_job_running == 1
+ if s:gAsyncJobRunning == 1
echom 'AsyncCmdProcessor: currently only one job at a time supported'
return
endif
- let s:async_job_running=1
+ let s:gAsyncJobRunning=1
let l:current_buffer = bufnr('%')
@@ -374,7 +374,7 @@ if s:sandbox_enable
endfor
echom l:cmd
- let s:async_job = job_start(l:cmd, {
+ let s:gAsyncJob = job_start(l:cmd, {
\ 'out_io': 'buffer',
\ 'out_buf': s:async_buffer,
\ 'out_cb': function('s:StdOutCB'),
@@ -387,23 +387,36 @@ if s:sandbox_enable
\})
endfunction
+ " can not be script local because used in statusline
function! GetAsyncJobStatus()
- if exists('s:async_job')
- return job_status(s:async_job)
+ if exists('s:gAsyncJob')
+ return job_status(s:gAsyncJob)
endif
return '*'
endfunction
+ function! s:KillAsyncJob()
+ if exists('s:gAsyncJob')
+ let l:dudel = job_stop(s:gAsyncJob)
+ execute 'sleep 200ms'
+ if job_status(s:gAsyncJob) !=? 'dead'
+ echom 'Failed to kill AsyncJob'
+ endif
+ endif
+ endfunction
+
function! s:CreateLogBuffer(buffer_name)
let l:buffer_num = bufnr(a:buffer_name, 1)
execute 'b ' . l:buffer_num
execute '%d'
execute 'setlocal buflisted'
execute 'setlocal buftype=nofile'
+ execute 'setlocal wrap'
return l:buffer_num
endfunction
command! -nargs=* Async call s:AsyncCmdProcessor(<f-args>)
nnoremap <leader>a :Async
+ nnoremap <leader>ak :call <SID>KillAsyncJob()<CR>
endif
"}}}