prospector.vim 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. "============================================================================
  2. "File: prospector.vim
  3. "Description: Syntax checking plugin for syntastic.vim
  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. "============================================================================
  12. if exists('g:loaded_syntastic_python_prospector_checker')
  13. finish
  14. endif
  15. let g:loaded_syntastic_python_prospector_checker = 1
  16. if !exists('g:syntastic_python_prospector_sort')
  17. let g:syntastic_python_prospector_sort = 1
  18. endif
  19. let s:save_cpo = &cpo
  20. set cpo&vim
  21. function! SyntaxCheckers_python_prospector_IsAvailable() dict
  22. if !executable(self.getExec())
  23. return 0
  24. endif
  25. return syntastic#util#versionIsAtLeast(self.getVersion(), [0, 7])
  26. endfunction
  27. function! SyntaxCheckers_python_prospector_GetLocList() dict
  28. let makeprg = self.makeprgBuild({
  29. \ 'args_after': '--messages-only --absolute-paths --die-on-tool-error --zero-exit --output-format json' })
  30. let errorformat = '%f:%l:%c: %m'
  31. let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' }
  32. let loclist = SyntasticMake({
  33. \ 'makeprg': makeprg,
  34. \ 'errorformat': errorformat,
  35. \ 'env': env,
  36. \ 'preprocess': 'prospector',
  37. \ 'returns': [0] })
  38. for e in loclist
  39. if e['text'] =~# '\v\[%(dodgy|mccabe|pep8|pep257|pyroma)\]$'
  40. let e['subtype'] = 'Style'
  41. endif
  42. if e['text'] =~# '\v\[pylint\]$'
  43. let e['type'] = e['text'] =~? '\m^[CRW]' ? 'W' : 'E'
  44. elseif e['text'] =~# '\v\[%(frosted|pep8)\]$'
  45. let e['type'] = e['text'] =~? '\m^W' ? 'W' : 'E'
  46. elseif e['text'] =~# '\v\[%(dodgy|pyroma|vulture)\]$'
  47. let e['type'] = 'W'
  48. else
  49. let e['type'] = 'E'
  50. endif
  51. endfor
  52. return loclist
  53. endfunction
  54. call g:SyntasticRegistry.CreateAndRegisterChecker({
  55. \ 'filetype': 'python',
  56. \ 'name': 'prospector'})
  57. let &cpo = s:save_cpo
  58. unlet s:save_cpo
  59. " vim: set sw=4 sts=4 et fdm=marker: