Created
October 21, 2013 04:08
-
-
Save supermomonga/7078534 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let g:socket_test_ruby_port = 12345 | |
let g:socket_test_ruby_path = 'ruby' | |
let g:socket_test_ruby_script_path = './socket.rb' | |
function! g:socket_test_send(command) | |
let sock = vimproc#socket_open('localhost', g:socket_test_ruby_port) | |
call sock.write(a:command) | |
call sock.close() | |
endfunction | |
function! g:socket_test_start() | |
if !g:socket_test_is_run() | |
let g:socket_test_pid = vimproc#popen2(join([g:socket_test_ruby_path, g:socket_test_ruby_script_path, g:socket_test_ruby_port], ' '))['pid'] | |
endif | |
endfunction | |
function! g:socket_test_stop() | |
if g:socket_test_is_run() | |
call vimproc#kill(g:socket_test_pid, 3) | |
endif | |
endfunction | |
function! g:socket_test_is_run() | |
if exists('g:socket_test_pid') | |
return vimproc#kill(g:socket_test_pid, 0) == 0 | |
else | |
return 0 | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment