pylama.vim 2.5 KB

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