gcc.vim 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. "============================================================================
  2. "File: c.vim
  3. "Description: Syntax checking plugin for syntastic.vim
  4. "Maintainer: Gregor Uhlenheuer <kongo2002 at gmail dot 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. if exists('g:loaded_syntastic_c_gcc_checker')
  13. finish
  14. endif
  15. let g:loaded_syntastic_c_gcc_checker = 1
  16. if !exists('g:syntastic_c_compiler_options')
  17. let g:syntastic_c_compiler_options = '-std=gnu99'
  18. endif
  19. let s:save_cpo = &cpo
  20. set cpo&vim
  21. function! SyntaxCheckers_c_gcc_IsAvailable() dict
  22. if !exists('g:syntastic_c_compiler')
  23. let g:syntastic_c_compiler = executable(self.getExec()) ? self.getExec() : 'clang'
  24. endif
  25. call self.log('g:syntastic_c_compiler =', g:syntastic_c_compiler)
  26. return executable(expand(g:syntastic_c_compiler, 1))
  27. endfunction
  28. function! SyntaxCheckers_c_gcc_GetLocList() dict
  29. return syntastic#c#GetLocList('c', 'gcc', {
  30. \ 'errorformat':
  31. \ '%-G%f:%s:,' .
  32. \ '%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,' .
  33. \ '%-G%f:%l: %#error: %#for each function it appears%.%#,' .
  34. \ '%-GIn file included%.%#,' .
  35. \ '%-G %#from %f:%l\,,' .
  36. \ '%f:%l:%c: %trror: %m,' .
  37. \ '%f:%l:%c: %tarning: %m,' .
  38. \ '%f:%l:%c: %m,' .
  39. \ '%f:%l: %trror: %m,' .
  40. \ '%f:%l: %tarning: %m,'.
  41. \ '%f:%l: %m',
  42. \ 'main_flags': '-x c -fsyntax-only',
  43. \ 'header_flags': '-x c',
  44. \ 'header_names': '\m\.h$' })
  45. endfunction
  46. call g:SyntasticRegistry.CreateAndRegisterChecker({
  47. \ 'filetype': 'c',
  48. \ 'name': 'gcc' })
  49. let &cpo = s:save_cpo
  50. unlet s:save_cpo
  51. " vim: set sw=4 sts=4 et fdm=marker: