oclint.vim 2.0 KB

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