oclint.vim 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. "============================================================================
  2. "File: oclint.vim
  3. "Description: Syntax checking plugin for syntastic.vim
  4. "Maintainer: "UnCO" Lin <undercooled aT lavabit 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_oclint_checker')
  12. finish
  13. endif
  14. let g:loaded_syntastic_c_oclint_checker = 1
  15. if !exists('g:syntastic_oclint_config_file')
  16. let g:syntastic_oclint_config_file = '.syntastic_oclint_config'
  17. endif
  18. if !exists('g:syntastic_c_oclint_sort')
  19. let g:syntastic_c_oclint_sort = 1
  20. endif
  21. let s:save_cpo = &cpo
  22. set cpo&vim
  23. function! SyntaxCheckers_c_oclint_GetLocList() dict
  24. let makeprg = self.makeprgBuild({
  25. \ 'post_args': '-- -c ' . syntastic#c#ReadConfig(g:syntastic_oclint_config_file) })
  26. let errorformat =
  27. \ '%E%f:%l:%c: fatal error: %m,' .
  28. \ '%E%f:%l:%c: error: %m,' .
  29. \ '%W%f:%l:%c: warning: %m,' .
  30. \ '%E%f:%l:%c: %m,' .
  31. \ '%-G%.%#'
  32. let loclist = SyntasticMake({
  33. \ 'makeprg': makeprg,
  34. \ 'errorformat': errorformat,
  35. \ 'subtype': 'Style',
  36. \ 'postprocess': ['compressWhitespace'],
  37. \ 'returns': [0, 3, 5] })
  38. for e in loclist
  39. if e['text'] =~# '\v P3( |$)'
  40. let e['type'] = 'W'
  41. endif
  42. let e['text'] = substitute(e['text'], '\m\C P[1-3]$', '', '')
  43. let e['text'] = substitute(e['text'], '\m\C P[1-3] ', ': ', '')
  44. endfor
  45. return loclist
  46. endfunction
  47. call g:SyntasticRegistry.CreateAndRegisterChecker({
  48. \ 'filetype': 'c',
  49. \ 'name': 'oclint'})
  50. let &cpo = s:save_cpo
  51. unlet s:save_cpo
  52. " vim: set sw=4 sts=4 et fdm=marker: