2009-07-29 03:19:07 -04:00
|
|
|
if exists("loaded_python_syntax_checker")
|
|
|
|
finish
|
|
|
|
endif
|
|
|
|
let loaded_python_syntax_checker = 1
|
|
|
|
|
|
|
|
"bail if the user doesnt have pyflakes installed
|
2011-02-01 07:10:46 -05:00
|
|
|
if !executable("pyflakes") || !executable("grep")
|
2009-07-29 03:19:07 -04:00
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
|
|
|
function! SyntaxCheckers_python_GetLocList()
|
2010-09-23 22:36:53 -04:00
|
|
|
let makeprg = 'pyflakes '.shellescape(expand('%'))
|
2009-07-29 03:19:07 -04:00
|
|
|
let errorformat = '%E%f:%l: could not compile,%-Z%p^,%W%f:%l: %m,%-G%.%#'
|
|
|
|
|
|
|
|
let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
|
|
|
|
|
2011-02-01 07:10:46 -05:00
|
|
|
call clearmatches()
|
2009-07-29 03:19:07 -04:00
|
|
|
for i in errors
|
|
|
|
if i['type'] ==# 'E'
|
|
|
|
let i['text'] = "Syntax error"
|
|
|
|
endif
|
2011-02-01 07:10:46 -05:00
|
|
|
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
|
2011-04-07 06:55:00 -04:00
|
|
|
|
2011-02-01 07:10:46 -05:00
|
|
|
let term = split(i['text'], "'", 1)[1]
|
2011-04-07 06:55:00 -04:00
|
|
|
"let group = match(i['text'], 'undefined') > -1 ? 'SpellBad' : 'SpellCap'
|
|
|
|
let group = i['type'] == 'E' ? 'SpellBad' : 'SpellCap'
|
|
|
|
call matchadd(group, '\%' . i['lnum'] . 'l\V' . term)
|
|
|
|
|
|
|
|
elseif exists("i['col']")
|
|
|
|
let lastcol = col([i['lnum'], '$'])
|
|
|
|
let lcol = min([lastcol, i['col']])
|
|
|
|
call matchadd('SpellBad', '\%' . i['lnum'] . 'l\%' . lcol . 'c')
|
2011-02-01 07:10:46 -05:00
|
|
|
endif
|
2009-07-29 03:19:07 -04:00
|
|
|
endfor
|
|
|
|
|
|
|
|
return errors
|
|
|
|
endfunction
|