From 48cf515ba54cfa289f1b20a3bdc5d5b7ede9739d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Sun, 14 Jul 2013 15:43:18 +0200 Subject: [PATCH] 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 #7747 --- src/etc/vim/ftplugin/rust.vim | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/etc/vim/ftplugin/rust.vim b/src/etc/vim/ftplugin/rust.vim index bf02d7b17239c..f22a2f8396845 100644 --- a/src/etc/vim/ftplugin/rust.vim +++ b/src/etc/vim/ftplugin/rust.vim @@ -41,3 +41,15 @@ if exists("g:loaded_delimitMate") endif 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" + +function! RustRun() + let l:bufno = bufnr('%') + + new + set buftype=nofile bufhidden=delete nobuflisted + setlocal noswapfile + + put =eval('getbufline(' . l:bufno . ', 1, 99999999999)') + 0d + silent! %!rust run /dev/stdin +endfunction