clang_check.vim 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. "============================================================================
  2. "File: clang_check.vim
  3. "Description: Syntax checking plugin for syntastic.vim
  4. "Maintainer: Benjamin Bannier <bbannier 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. if exists('g:loaded_syntastic_c_clang_check_checker')
  12. finish
  13. endif
  14. let g:loaded_syntastic_c_clang_check_checker = 1
  15. if !exists('g:syntastic_clang_check_config_file')
  16. let g:syntastic_clang_check_config_file = '.syntastic_clang_check_config'
  17. endif
  18. if !exists('g:syntastic_c_clang_check_sort')
  19. let g:syntastic_c_clang_check_sort = 1
  20. endif
  21. let s:save_cpo = &cpo
  22. set cpo&vim
  23. function! SyntaxCheckers_c_clang_check_GetLocList() dict
  24. let makeprg = self.makeprgBuild({
  25. \ 'post_args':
  26. \ '-- ' .
  27. \ syntastic#c#ReadConfig(g:syntastic_clang_check_config_file) . ' ' .
  28. \ '-fshow-column ' .
  29. \ '-fshow-source-location ' .
  30. \ '-fno-caret-diagnostics ' .
  31. \ '-fno-color-diagnostics ' .
  32. \ '-fdiagnostics-format=clang' })
  33. let errorformat =
  34. \ '%E%f:%l:%c: fatal error: %m,' .
  35. \ '%E%f:%l:%c: error: %m,' .
  36. \ '%W%f:%l:%c: warning: %m,' .
  37. \ '%-G%\m%\%%(LLVM ERROR:%\|No compilation database found%\)%\@!%.%#,' .
  38. \ '%E%m'
  39. let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' }
  40. return SyntasticMake({
  41. \ 'makeprg': makeprg,
  42. \ 'errorformat': errorformat,
  43. \ 'env': env,
  44. \ 'defaults': {'bufnr': bufnr('')},
  45. \ 'returns': [0, 1] })
  46. endfunction
  47. call g:SyntasticRegistry.CreateAndRegisterChecker({
  48. \ 'filetype': 'c',
  49. \ 'name': 'clang_check',
  50. \ 'exec': 'clang-check'})
  51. let &cpo = s:save_cpo
  52. unlet s:save_cpo
  53. " vim: set sw=4 sts=4 et fdm=marker: