mypy.vim 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. "============================================================================
  2. "File: mypy.vim
  3. "Description: Syntax checking plugin for syntastic
  4. "Author: Russ Hewgill <Russ dot Hewgill at gmail dot com>
  5. "
  6. "============================================================================
  7. if exists('g:loaded_syntastic_python_mypy_checker')
  8. finish
  9. endif
  10. let g:loaded_syntastic_python_mypy_checker = 1
  11. let s:save_cpo = &cpo
  12. set cpo&vim
  13. function! SyntaxCheckers_python_mypy_GetLocList() dict
  14. if !exists('s:mypy_new')
  15. " creative versioning: version string has changed from v0.4.6 to v0.470
  16. " XXX the test should be fine for now, since 470 > 4
  17. let s:mypy_new = syntastic#util#versionIsAtLeast(self.getVersion(), [0, 4, 5])
  18. endif
  19. let buf = bufnr('')
  20. let makeprg = self.makeprgBuild({
  21. \ 'args_after': (s:mypy_new ? '--show-column-numbers' : ''),
  22. \ 'fname': syntastic#util#shescape(fnamemodify(bufname(buf), ':p')) })
  23. let errorformat =
  24. \ '%f:%l:%c:%t:%m,' .
  25. \ '%f:%l:%t:%m'
  26. return SyntasticMake({
  27. \ 'makeprg': makeprg,
  28. \ 'errorformat': errorformat,
  29. \ 'returns': [0, 1],
  30. \ 'preprocess': 'mypy' })
  31. endfunction
  32. call g:SyntasticRegistry.CreateAndRegisterChecker({
  33. \ 'filetype': 'python',
  34. \ 'name': 'mypy'})
  35. let &cpo = s:save_cpo
  36. unlet s:save_cpo
  37. " vim: set sw=4 sts=4 et fdm=marker: