]> Cypherpunks repositories - gostls13.git/commitdiff
misc/vim: Add compiler plugin for Go
authorDavid Bürgin <676c7473@gmail.com>
Mon, 1 Jul 2013 06:20:50 +0000 (16:20 +1000)
committerDavid Symonds <dsymonds@golang.org>
Mon, 1 Jul 2013 06:20:50 +0000 (16:20 +1000)
This change adds a basic compiler plugin for Go. The plugin
integrates "go build" with Vim's ":make" command and the
quickfix list.

Fixes #5751.

R=golang-dev, dsymonds, niklas.schnelle, 0xjnml
CC=golang-dev
https://golang.org/cl/10466043

misc/vim/compiler/go.vim [new file with mode: 0644]
misc/vim/readme.txt

diff --git a/misc/vim/compiler/go.vim b/misc/vim/compiler/go.vim
new file mode 100644 (file)
index 0000000..2c8cce4
--- /dev/null
@@ -0,0 +1,30 @@
+" Copyright 2013 The Go Authors. All rights reserved.
+" Use of this source code is governed by a BSD-style
+" license that can be found in the LICENSE file.
+"
+" compiler/go.vim: Vim compiler file for Go.
+
+if exists("current_compiler")
+    finish
+endif
+let current_compiler = "go"
+
+if exists(":CompilerSet") != 2
+    command -nargs=* CompilerSet setlocal <args>
+endif
+
+let s:save_cpo = &cpo
+set cpo-=C
+
+CompilerSet makeprg=go\ build
+CompilerSet errorformat=
+        \%-G#\ %.%#,
+        \%A%f:%l:%c:\ %m,
+        \%A%f:%l:\ %m,
+        \%C%*\\s%m,
+        \%-G%.%#
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
+
+" vim:ts=4:sw=4:et
index dca24ea1d041432901f3c09ef8630d45e37b624f..a394cec5a9be4fdad21fde090c34e791b7a27667 100644 (file)
@@ -14,6 +14,7 @@ To use all the Vim plugins, add these lines to your $HOME/.vimrc.
 If you want to select fewer plugins, use the instructions in the rest of
 this file.
 
+
 Vim syntax highlighting
 -----------------------
 
@@ -69,6 +70,21 @@ To install automatic indentation:
      filetype indent on
 
 
+Vim compiler plugin
+-------------------
+
+To install the compiler plugin:
+
+  1. Same as 1 above.
+  2. Copy or link compiler/go.vim to the compiler directory underneath your vim
+     runtime directory (normally $HOME/.vim/compiler).
+  3. Activate the compiler plugin with ":compiler go". To always enable the
+     compiler plugin in Go source files add an autocommand to your .vimrc file
+     (normally $HOME/.vimrc):
+
+     autocmd FileType go compiler go
+
+
 Godoc plugin
 ------------