Skip to content

Instantly share code, notes, and snippets.

@PeterRincker
Created February 21, 2015 01:28
Show Gist options
  • Save PeterRincker/33dfe9e4203ceab2c518 to your computer and use it in GitHub Desktop.
Save PeterRincker/33dfe9e4203ceab2c518 to your computer and use it in GitHub Desktop.
compiler/python.vim
#!/usr/bin/env python
# put this file at ~/.vim/compiler.py
from __future__ import print_function
from sys import argv, exit
if len(argv) != 2:
exit(1)
try:
compile(open(argv[1]).read(), argv[1], 'exec', 0, 1)
except SyntaxError as err:
print('%s:%s:%s: %s' % (err.filename, err.lineno, err.offset, err.msg))
" Put this file at ~/.vim/compiler/python.vim
" Vim compiler file
" Compiler: Python
if exists("current_compiler")
finish
endif
let current_compiler = "python"
if exists(":CompilerSet") != 2 " older Vim always used :setlocal
command -nargs=* CompilerSet setlocal <args>
endif
let s:cpo_save = &cpo
set cpo-=C
let s:plugin_path = escape(expand('<sfile>:p:h'), '\')
CompilerSet errorformat=%E%f:%l:%c:\ %m
execute 'CompilerSet makeprg=python\ ' . s:plugin_path . '/python.py'
let &cpo = s:cpo_save
unlet s:cpo_save
@PeterRincker
Copy link
Author

Run :compiler python to set compiler to lint python. Run :make % to lint the current file.

python.py is taken directly from github:scrooloose/syntastic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment