go.vim 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. " Copyright 2013 The Go Authors. All rights reserved.
  2. " Use of this source code is governed by a BSD-style
  3. " license that can be found in the LICENSE file.
  4. "
  5. " compiler/go.vim: Vim compiler file for Go.
  6. if exists("g:current_compiler")
  7. finish
  8. endif
  9. let g:current_compiler = "go"
  10. if exists(":CompilerSet") != 2
  11. command -nargs=* CompilerSet setlocal <args>
  12. endif
  13. let s:save_cpo = &cpo
  14. set cpo-=C
  15. if filereadable("makefile") || filereadable("Makefile")
  16. CompilerSet makeprg=make
  17. else
  18. CompilerSet makeprg=go\ build
  19. endif
  20. " Define the patterns that will be recognized by QuickFix when parsing the
  21. " output of Go command that use this errorforamt (when called make, cexpr or
  22. " lmake, lexpr). This is the global errorformat, however some command might
  23. " use a different output, for those we define them directly and modify the
  24. " errorformat ourselves. More information at:
  25. " http://vimdoc.sourceforge.net/htmldoc/quickfix.html#errorformat
  26. CompilerSet errorformat =%-G#\ %.%# " Ignore lines beginning with '#' ('# command-line-arguments' line sometimes appears?)
  27. CompilerSet errorformat+=%-G%.%#panic:\ %m " Ignore lines containing 'panic: message'
  28. CompilerSet errorformat+=%Ecan\'t\ load\ package:\ %m " Start of multiline error string is 'can\'t load package'
  29. CompilerSet errorformat+=%A%f:%l:%c:\ %m " Start of multiline unspecified string is 'filename:linenumber:columnnumber:'
  30. CompilerSet errorformat+=%A%f:%l:\ %m " Start of multiline unspecified string is 'filename:linenumber:'
  31. CompilerSet errorformat+=%C%*\\s%m " Continuation of multiline error message is indented
  32. CompilerSet errorformat+=%-G%.%# " All lines not matching any of the above patterns are ignored
  33. let &cpo = s:save_cpo
  34. unlet s:save_cpo
  35. " vim: sw=2 ts=2 et