cppcheck.vim 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "============================================================================
  2. "File: cppcheck.vim
  3. "Description: Syntax checking plugin for syntastic.vim using cppcheck.pl
  4. "Maintainer: LCD 47 <lcd047 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_cppcheck_checker')
  12. finish
  13. endif
  14. let g:loaded_syntastic_c_cppcheck_checker = 1
  15. if !exists('g:syntastic_cppcheck_config_file')
  16. let g:syntastic_cppcheck_config_file = '.syntastic_cppcheck_config'
  17. endif
  18. let s:save_cpo = &cpo
  19. set cpo&vim
  20. function! SyntaxCheckers_c_cppcheck_GetLocList() dict
  21. let makeprg = self.makeprgBuild({
  22. \ 'args': syntastic#c#ReadConfig(g:syntastic_cppcheck_config_file),
  23. \ 'args_after': '-q --enable=style' })
  24. let errorformat =
  25. \ '[%f:%l]: (%trror) %m,' .
  26. \ '[%f:%l]: (%tarning) %m,' .
  27. \ '[%f:%l]: (%ttyle) %m,' .
  28. \ '[%f:%l]: (%terformance) %m,' .
  29. \ '[%f:%l]: (%tortability) %m,' .
  30. \ '[%f:%l]: (%tnformation) %m,' .
  31. \ '[%f:%l]: (%tnconclusive) %m,' .
  32. \ '%-G%.%#'
  33. let loclist = SyntasticMake({
  34. \ 'makeprg': makeprg,
  35. \ 'errorformat': errorformat,
  36. \ 'preprocess': 'cppcheck',
  37. \ 'returns': [0] })
  38. for e in loclist
  39. if e['type'] =~? '\m^[SPI]'
  40. let e['type'] = 'w'
  41. let e['subtype'] = 'Style'
  42. endif
  43. endfor
  44. return loclist
  45. endfunction
  46. call g:SyntasticRegistry.CreateAndRegisterChecker({
  47. \ 'filetype': 'c',
  48. \ 'name': 'cppcheck'})
  49. let &cpo = s:save_cpo
  50. unlet s:save_cpo
  51. " vim: set sw=4 sts=4 et fdm=marker: