Skip to content

Instantly share code, notes, and snippets.

@supermomonga
Created October 21, 2013 04:08
Show Gist options
  • Save supermomonga/7078534 to your computer and use it in GitHub Desktop.
Save supermomonga/7078534 to your computer and use it in GitHub Desktop.
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