Created
February 21, 2015 01:28
-
-
Save PeterRincker/33dfe9e4203ceab2c518 to your computer and use it in GitHub Desktop.
compiler/python.vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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