IRust vim plugin using deno
Make sure deno is installed and then append these lines to vim configuration file (or your plugin magnager equivalent):
Plug 'vim-denops/denops.vim' "Allows using plugins written with deno
Plug 'sigmaSd/irust-vim-plugin' "This actual plugin- Make sure that
local_severis set totruein IRust configuration file - Open a rust file
- Run
:IRustto start the repl
Now you can send input to the repl using different methods:
:IRustSendCurrentWordsends the word under the cursor:IRustSendCurrentLinesends the current line:IRustSendSelectionsends the selected text
There are also commands to sync the current file to the repl
:IRustSyncToCursorcopies the whole file to IRust buffer, and sets its internal cursor to the current line (so variables in scope can be accessed):IRustSyncCrateToCursorcopies the whole src directory and toml file to IRust, this is the same asIRustSyncToCursorbut more powerful since it allows using files that have internal or external imports
Couple of caveat of sync:
- Should be only used with
main.rsfile - The file should be already formatted with
cargo fmtbefore using sync IRustSyncCrateToCursorassumes a particular layout of the crate, it should at least have$crate/src/main.rsas an entry point- more..
Bindings example:
nnoremap <space>ii :IRust<CR>
nnoremap <space>ir :IRustReset<CR>
nnoremap <space>iw :IRustSendCurrentWord<CR>
nnoremap <space>il :IRustSendCurrentLine<CR>
nnoremap <space>ic :IRustSyncToCursor<CR>
nnoremap <space>ick :IRustSyncCrateToCursor<CR>
vnoremap <space>is :IRustSendSelection<CR>