Skip to content

Commit 48cf515

Browse files
committed
Vim: Add a RustRun function to run the current buffer contents
This allows to run the contents of a buffer through "rust run" and show the results in a scratch buffer. Handy for things that are just a bit too big to be done comfortably in rusti. Refs rust-lang#7747
1 parent 51cb984 commit 48cf515

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/etc/vim/ftplugin/rust.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,15 @@ if exists("g:loaded_delimitMate")
4141
endif
4242

4343
let b:undo_ftplugin = "setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd< | if exists('b:rust_original_delimitMate_excluded_regions') | let b:delimitMate_excluded_regions = b:rust_original_delimitMate_excluded_regions | unlet b:rust_original_delimitMate_excluded_regions | elseif exists('b:delimitMate_excluded_regions') | unlet b:delimitMate_excluded_regions | endif"
44+
45+
function! RustRun()
46+
let l:bufno = bufnr('%')
47+
48+
new
49+
set buftype=nofile bufhidden=delete nobuflisted
50+
setlocal noswapfile
51+
52+
put =eval('getbufline(' . l:bufno . ', 1, 99999999999)')
53+
0d
54+
silent! %!rust run /dev/stdin
55+
endfunction

0 commit comments

Comments
 (0)