Once the RPC process is running, you can send real-time editor state changes to your Rust plugin using the rpcnotify function. This is typically done by mapping Neovim autocmd events to rpcnotify calls.
Common events to notify include:
cursor-moved-i: Triggered on CursorMovedI (Cursor moved in Insert mode).insert-change: Triggered on InsertChange (Text changed in Insert mode).insert-enter: Triggered on InsertEnter.insert-leave: Triggered on InsertLeave.quit: Sent to the plugin to signal it should shut down.
Example mapping for cursor movement:
function! s:NotifyCursorMovedI()
let [ bufnum, lnum, column, off ] = getpos('.')
call rpcnotify(s:jobid, 'cursor-moved-i', lnum, column)
endfunction
" Example of mapping an autocmd to an RPC notification
autocmd CursorMovedI * :call s:NotifyCursorMovedI()
function! s:NotifyCursorMovedI()
let [ bufnum, lnum, column, off ] = getpos('.')
call rpcnotify(s:jobid, 'cursor-moved-i', lnum, column)
endfunction