about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Morgan <me@chrismorgan.info>2013-07-12 23:44:27 +1000
committerChris Morgan <me@chrismorgan.info>2013-07-12 23:51:03 +1000
commit917d720f4859e807ec806e3674b18cd8950f136a (patch)
tree6ffaeb24c50d3a4e0582fb3dda6548269f3a6b81
parentf67935257b19b0904b282c949770d85089fdcf3c (diff)
downloadrust-917d720f4859e807ec806e3674b18cd8950f136a.tar.gz
rust-917d720f4859e807ec806e3674b18cd8950f136a.zip
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.
-rw-r--r--src/etc/vim/compiler/rustc.vim33
1 files changed, 33 insertions, 0 deletions
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 <me@chrismorgan.info>
+" 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 <args>
+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