Skip to content

Instantly share code, notes, and snippets.

@ujihisa
Created July 25, 2014 04:57
Show Gist options
  • Save ujihisa/bd2dd4b66ea0a51609d7 to your computer and use it in GitHub Desktop.
Save ujihisa/bd2dd4b66ea0a51609d7 to your computer and use it in GitHub Desktop.
let s:P = g:V.import('ProcessManager')
let s:p = s:P.of('qr', 'clojure-1.6')
nnoremap <Space>r :<C-u>call <SID>run()<Cr>
function! s:run()
if s:p.is_new()
call s:p.wait(['user=> '])
endif
call s:p.writeln2(join(getline(1, '$'), "\n"))
call s:p.read_until(['user=> '])
new
let s:winbufnr = winbufnr('.')
wincmd p
augroup process-manager-example
autocmd! CursorHold,CursorHoldI * call s:loop()
augroup END
endfunction
function! s:loop()
let result = s:p.go_acc()
if result.fail
echomsg 'failed'
augroup process-manager-example
autocmd!
augroup END
elseif result.done
execute s:winbufnr . 'wincmd w'
for line in split(result.err . result.out, "\n")
call append(line('$'), line)
endfor
wincmd p
augroup process-manager-example
autocmd!
augroup END
else
call feedkeys(mode() ==# 'i' ? "\<C-g>\<ESC>" : "g\<ESC>", 'n')
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment