checkpatch.vim 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. "============================================================================
  2. "File: checkpatch.vim
  3. "Description: Syntax checking plugin for syntastic.vim using checkpatch.pl
  4. "Maintainer: Daniel Walker <dwalker at fifo99 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_checkpatch_checker')
  12. finish
  13. endif
  14. let g:loaded_syntastic_c_checkpatch_checker = 1
  15. let s:save_cpo = &cpo
  16. set cpo&vim
  17. function! SyntaxCheckers_c_checkpatch_IsAvailable() dict
  18. call syntastic#log#deprecationWarn('c_checker_checkpatch_location', 'c_checkpatch_exec')
  19. if !exists('g:syntastic_c_checkpatch_exec') && !executable(self.getExec())
  20. if executable('checkpatch')
  21. let g:syntastic_c_checkpatch_exec = 'checkpatch'
  22. elseif executable('./scripts/checkpatch.pl')
  23. let g:syntastic_c_checkpatch_exec = fnamemodify('./scripts/checkpatch.pl', ':p')
  24. elseif executable('./scripts/checkpatch')
  25. let g:syntastic_c_checkpatch_exec = fnamemodify('./scripts/checkpatch', ':p')
  26. endif
  27. endif
  28. call self.log('exec =', self.getExec())
  29. return executable(self.getExec())
  30. endfunction
  31. function! SyntaxCheckers_c_checkpatch_GetLocList() dict
  32. let makeprg = self.makeprgBuild({ 'args_after': '--no-summary --no-tree --terse --file' })
  33. let errorformat =
  34. \ '%f:%l: %tARNING: %m,' .
  35. \ '%f:%l: %tRROR: %m'
  36. return SyntasticMake({
  37. \ 'makeprg': makeprg,
  38. \ 'errorformat': errorformat,
  39. \ 'returns': [0, 1],
  40. \ 'subtype': 'Style' })
  41. endfunction
  42. call g:SyntasticRegistry.CreateAndRegisterChecker({
  43. \ 'filetype': 'c',
  44. \ 'name': 'checkpatch',
  45. \ 'exec': 'checkpatch.pl'})
  46. let &cpo = s:save_cpo
  47. unlet s:save_cpo
  48. " vim: set sw=4 sts=4 et fdm=marker: