rubocop.vim 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. "============================================================================
  2. "File: rubocop.vim
  3. "Description: Syntax checking plugin for syntastic.vim
  4. "Maintainer: Recai Oktaş <roktas@bil.omu.edu.tr>
  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. "============================================================================
  12. if exists('g:loaded_syntastic_ruby_rubocop_checker')
  13. finish
  14. endif
  15. let g:loaded_syntastic_ruby_rubocop_checker = 1
  16. let s:save_cpo = &cpo
  17. set cpo&vim
  18. function! SyntaxCheckers_ruby_rubocop_IsAvailable() dict
  19. if !executable(self.getExec())
  20. return 0
  21. endif
  22. return syntastic#util#versionIsAtLeast(self.getVersion(), [0, 12, 0])
  23. endfunction
  24. function! SyntaxCheckers_ruby_rubocop_GetLocList() dict
  25. let makeprg = self.makeprgBuild({ 'args_after': '--format emacs' })
  26. let errorformat = '%f:%l:%c: %t: %m'
  27. let loclist = SyntasticMake({
  28. \ 'makeprg': makeprg,
  29. \ 'errorformat': errorformat,
  30. \ 'subtype': 'Style'})
  31. " convert rubocop severities to error types recognized by syntastic
  32. for e in loclist
  33. if e['type'] ==# 'F'
  34. let e['type'] = 'E'
  35. elseif e['type'] !=# 'W' && e['type'] !=# 'E'
  36. let e['type'] = 'W'
  37. endif
  38. endfor
  39. return loclist
  40. endfunction
  41. call g:SyntasticRegistry.CreateAndRegisterChecker({
  42. \ 'filetype': 'ruby',
  43. \ 'name': 'rubocop'})
  44. let &cpo = s:save_cpo
  45. unlet s:save_cpo
  46. " vim: set sw=4 sts=4 et fdm=marker: