gofmt.vim 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "============================================================================
  2. "File: gofmt.vim
  3. "Description: Check go syntax using 'gofmt -l'
  4. "Maintainer: Brandon Thomson <bt@brandonthomson.com>
  5. "License: This program is free software. It comes without any warranty,
  6. " to the extent permitted by applicable law. You can redistribute
  7. " it and/or modify it under the terms of the Do What The Fuck You
  8. " Want To Public License, Version 2, as published by Sam Hocevar.
  9. " See http://sam.zoy.org/wtfpl/COPYING for more details.
  10. "
  11. "============================================================================
  12. "
  13. " This syntax checker does not reformat your source code.
  14. " Use a BufWritePre autocommand to that end:
  15. " autocmd FileType go autocmd BufWritePre <buffer> Fmt
  16. if exists('g:loaded_syntastic_go_gofmt_checker')
  17. finish
  18. endif
  19. let g:loaded_syntastic_go_gofmt_checker = 1
  20. let s:save_cpo = &cpo
  21. set cpo&vim
  22. function! SyntaxCheckers_go_gofmt_GetLocList() dict
  23. let makeprg = self.makeprgBuild({
  24. \ 'args_after': '-l',
  25. \ 'tail_after': '> ' . syntastic#util#DevNull() })
  26. let errorformat = '%f:%l:%c: %m,%-G%.%#'
  27. return SyntasticMake({
  28. \ 'makeprg': makeprg,
  29. \ 'errorformat': errorformat,
  30. \ 'defaults': {'type': 'e'} })
  31. endfunction
  32. call g:SyntasticRegistry.CreateAndRegisterChecker({
  33. \ 'filetype': 'go',
  34. \ 'name': 'gofmt'})
  35. let &cpo = s:save_cpo
  36. unlet s:save_cpo
  37. " vim: set sw=4 sts=4 et fdm=marker: