python.vim 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. "============================================================================
  2. "File: python.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_python_checker')
  13. finish
  14. endif
  15. let g:loaded_syntastic_python_python_checker = 1
  16. if !exists('g:syntastic_python_python_use_codec')
  17. let g:syntastic_python_python_use_codec = 0
  18. endif
  19. let s:save_cpo = &cpo
  20. set cpo&vim
  21. let s:base_path = expand('<sfile>:p:h', 1) . syntastic#util#Slash()
  22. function! SyntaxCheckers_python_python_IsAvailable() dict
  23. if !executable(self.getExec())
  24. return 0
  25. endif
  26. return syntastic#util#versionIsAtLeast(self.getVersion(), [2, 6])
  27. endfunction
  28. function! SyntaxCheckers_python_python_GetLocList() dict
  29. let compiler = s:base_path . (g:syntastic_python_python_use_codec ? 'codec.py' : 'compile.py')
  30. call self.log('using compiler script', compiler)
  31. let makeprg = self.makeprgBuild({ 'exe': [self.getExec(), compiler] })
  32. let errorformat = '%E%f:%l:%c: %m'
  33. let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' }
  34. return SyntasticMake({
  35. \ 'makeprg': makeprg,
  36. \ 'errorformat': errorformat,
  37. \ 'env': env,
  38. \ 'returns': [0] })
  39. endfunction
  40. call g:SyntasticRegistry.CreateAndRegisterChecker({
  41. \ 'filetype': 'python',
  42. \ 'name': 'python'})
  43. let &cpo = s:save_cpo
  44. unlet s:save_cpo
  45. " vim: set sw=4 sts=4 et fdm=marker: