pylama.vim 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. "============================================================================
  2. "File: pylama.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_pylama_checker')
  13. finish
  14. endif
  15. let g:loaded_syntastic_python_pylama_checker = 1
  16. if !exists('g:syntastic_python_pylama_sort')
  17. let g:syntastic_python_pylama_sort = 1
  18. endif
  19. let s:save_cpo = &cpo
  20. set cpo&vim
  21. function! SyntaxCheckers_python_pylama_GetHighlightRegex(item)
  22. return SyntaxCheckers_python_pyflakes_GetHighlightRegex(a:item)
  23. endfunction
  24. function! SyntaxCheckers_python_pylama_GetLocList() dict
  25. let makeprg = self.makeprgBuild({ 'args_after': '-f pep8' })
  26. " TODO: "WARNING:pylama:..." messages are probably a logging bug
  27. let errorformat =
  28. \ '%-GWARNING:pylama:%.%#,' .
  29. \ '%A%f:%l:%c: %m'
  30. let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' }
  31. let loclist = SyntasticMake({
  32. \ 'makeprg': makeprg,
  33. \ 'errorformat': errorformat,
  34. \ 'env': env })
  35. " adjust for weirdness in each checker
  36. for e in loclist
  37. let e['type'] = e['text'] =~? '\m^[RCW]' ? 'W' : 'E'
  38. if e['text'] =~# '\v\[%(mccabe|pep257|pylint)\]$'
  39. if has_key(e, 'col')
  40. let e['col'] += 1
  41. endif
  42. endif
  43. if e['text'] =~# '\v\[pylint\]$'
  44. if has_key(e, 'vcol')
  45. let e['vcol'] = 0
  46. endif
  47. endif
  48. if e['text'] =~# '\v\[%(mccabe|pep257|pep8)\]$'
  49. let e['subtype'] = 'Style'
  50. endif
  51. endfor
  52. return loclist
  53. endfunction
  54. runtime! syntax_checkers/python/pyflakes.vim
  55. call g:SyntasticRegistry.CreateAndRegisterChecker({
  56. \ 'filetype': 'python',
  57. \ 'name': 'pylama' })
  58. let &cpo = s:save_cpo
  59. unlet s:save_cpo
  60. " vim: set sw=4 sts=4 et fdm=marker: