Created
February 4, 2019 09:28
-
-
Save srishanbhattarai/73b89cffe65789187e8f3cd49db4e221 to your computer and use it in GitHub Desktop.
Job connect
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
" 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