# HG changeset patch # User Steve Losh # Date 1449663279 0 # Node ID a87221e612e65a7326631c654a5038fb75b0ee87 # Parent 4ad9d3c4ebbeb75e5957283160657a7e7770ea10 Start ooze diff -r 4ad9d3c4ebbe -r a87221e612e6 vim/bundle/ooze/plugin/ooze.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/bundle/ooze/plugin/ooze.vim Wed Dec 09 12:14:39 2015 +0000 @@ -0,0 +1,90 @@ +function! s:IsString(a) + return type(a:a) == 1 +endfunction + +function! s:HandleMessage(msg) + let stdout = get(a:msg, 'stdout') + if s:IsString(stdout) + echo stdout + endif + + let stderr = get(a:msg, 'stderr') + if s:IsString(stderr) + echo stderr + endif + + let value = get(a:msg, 'value') + if s:IsString(value) + echo value + endif +endfunction + +function! s:HandleData(data) + for msg in bencode#BdecodeAll(a:data) + call s:HandleMessage(msg) + endfor +endfunction + +silent! function s:JobHandler(job_id, data, event) + if a:event == 'stdout' + call s:HandleData(join(a:data, "\n")) + elseif a:event == 'stderr' + 1 + else + 1 + endif +endfunction + +let s:callbacks = { +\ 'on_stdout': function('s:JobHandler'), +\ 'on_stderr': function('s:JobHandler'), +\ 'on_exit': function('s:JobHandler') +\ } + +if !exists("g:ooze_connection") + let g:ooze_connection = 0 +endif + +function! OozeDisconnect() + if g:ooze_connection + call jobstop(g:ooze_connection) + let g:ooze_connection = 0 + endif +endfunction + +function! OozeConnect() + if g:ooze_connection + call OozeDisconnect() + endif + let g:ooze_connection = jobstart(['nc', 'localhost', '8675'], s:callbacks) +endfunction + +function! OozeEval(code) + if !g:ooze_connection + throw "Not connected!" + endif + let msg = {"op": "eval", "code": a:code} + call jobsend(g:ooze_connection, bencode#Bencode(msg)) +endfunction + +function! OozeEvalSelection() + let z = @z + normal! gv"zy + call OozeEval(@z) + let @z = z +endfunction + +function! OozeMapKeys() + nnoremap C :call OozeConnect() + nnoremap K :call OozeDisconnect() + + nnoremap E :call OozeEval(input("? ")) + vnoremap e :call OozeEvalSelection() + nnoremap e mz:silent normal! l:call PareditFindDefunBck()vab:call OozeEvalSelection()`z +endfunction + +augroup ooze_dev + au! + autocmd BufWritePost ooze.vim source % +augroup END + diff -r 4ad9d3c4ebbe -r a87221e612e6 vim/bundle/ooze/scratch.lisp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vim/bundle/ooze/scratch.lisp Wed Dec 09 12:14:39 2015 +0000 @@ -0,0 +1,5 @@ +(ql:quickload "nrepl") + +(ql:quickload "optima") + +(ql:quickload 'beef)