syntastic python: highlight identificators with errors

This commit is contained in:
Konstantin Stepanov 2011-02-01 14:10:46 +02:00
parent 172a64916d
commit 8c5bf3afbd

View File

@ -4,7 +4,7 @@ endif
let loaded_python_syntax_checker = 1
"bail if the user doesnt have pyflakes installed
if !executable("pyflakes")
if !executable("pyflakes") || !executable("grep")
finish
endif
@ -14,10 +14,18 @@ function! SyntaxCheckers_python_GetLocList()
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
call clearmatches()
for i in errors
if i['type'] ==# 'E'
let i['text'] = "Syntax error"
endif
if match(i['text'], 'is assigned to but never used') > -1
\ || match(i['text'], 'imported but unused') > -1
\ || match(i['text'], 'undefined name') > -1
\ || match(i['text'], 'redefinition of unused') > -1
let term = split(i['text'], "'", 1)[1]
call matchadd('SpellBad', '\%' . i['lnum'] . 'l\<' . term . '\>')
endif
endfor
return errors