From 917d720f4859e807ec806e3674b18cd8950f136a Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Fri, 12 Jul 2013 23:44:27 +1000 Subject: [PATCH] rustc compiler config for Vim. Note that this is not actually *used* by default; it is a matter of configuration still, because you might want to: - Compile all .rs files with `rustc %` (where each can be built itself) - Compile all .rs files with `rustc some-file.rs` (where you are editing part of a crate) - Compile with a different tool, such as `make`. (In this case you might put a `~/.vim/after/compiler/rustc.vim` to match such cases, set makeprg and extend errorformat as appropriate. That should probably go in a different compiler mode, e.g. make-rustc.) To try using it, `:compiler rustc`. Then, `:make` on a file you would run `rustc` on will work its magic, invoking rustc. To automate this, you could have something like `autocmd FileType rust compiler rustc` in your Vim config. --- src/etc/vim/compiler/rustc.vim | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/etc/vim/compiler/rustc.vim diff --git a/src/etc/vim/compiler/rustc.vim b/src/etc/vim/compiler/rustc.vim new file mode 100644 index 00000000000..f9b854ed049 --- /dev/null +++ b/src/etc/vim/compiler/rustc.vim @@ -0,0 +1,33 @@ +" Vim compiler file +" Compiler: Rust Compiler +" Maintainer: Chris Morgan +" Latest Revision: 2013 Jul 12 + +if exists("current_compiler") + finish +endif +let current_compiler = "rustc" + +let s:cpo_save = &cpo +set cpo&vim + +if exists(":CompilerSet") != 2 + command -nargs=* CompilerSet setlocal +endif + +if exists("g:rustc_makeprg_no_percent") && g:rustc_makeprg_no_percent == 1 + CompilerSet makeprg=rustc +else + CompilerSet makeprg=rustc\ \% +endif + +CompilerSet errorformat= + \%f:%l:%c:\ %t%*[^:]:\ %m, + \%f:%l:%c:\ %*\\d:%*\\d\ %t%*[^:]:\ %m, + \%-G%f:%l\ %s, + \%-G%*[\ ]^, + \%-G%*[\ ]^%*[~], + \%-G%*[\ ]... + +let &cpo = s:cpo_save +unlet s:cpo_save