clang_check.vim 2.1 KB

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