cppcheck.vim 2.2 KB

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