Skip to content

Instantly share code, notes, and snippets.

@srishanbhattarai
Created February 4, 2019 09:28
Show Gist options
  • Save srishanbhattarai/73b89cffe65789187e8f3cd49db4e221 to your computer and use it in GitHub Desktop.
Save srishanbhattarai/73b89cffe65789187e8f3cd49db4e221 to your computer and use it in GitHub Desktop.
Job connect
" Initialize the channel
if !exists('s:calculatorJobId')
let s:calculatorJobId = 0
endif
" The path to the binary that was created out of 'cargo build' or 'cargo build --release". This will generally be 'target/release/name'
let s:bin = '/path/to/rust-binary'
" Entry point. Initialize RPC. If it succeeds, then attach commands to the `rpcnotify` invocations.
function! s:connect()
let id = s:initRpc()
if 0 == id
echoerr "calculator: cannot start rpc process"
elseif -1 == id
echoerr "calculator: rpc process is not executable"
else
" Mutate our jobId variable to hold the channel ID
let s:calculatorJobId = id
// TODO: Configure commands to their RPC invocations.
endif
endfunction
" Initialize RPC
function! s:initRpc()
if s:calculatorJobId == 0
let jobid = jobstart([s:bin], { 'rpc': v:true })
return jobid
else
return s:calculatorJobId
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment