mirror of
https://github.com/amix/vimrc
synced 2025-07-05 07:25:00 +08:00
prefinal close
This commit is contained in:
@ -0,0 +1,44 @@
|
||||
"============================================================================
|
||||
"File: flake8.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Authors: Sylvain Soliman <Sylvain dot Soliman+git at gmail dot com>
|
||||
" kstep <me@kstep.me>
|
||||
"
|
||||
"============================================================================
|
||||
if exists("g:loaded_syntastic_python_flake8_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_python_flake8_checker=1
|
||||
|
||||
function! SyntaxCheckers_python_flake8_IsAvailable()
|
||||
return executable('flake8')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_python_flake8_GetHighlightRegex(i)
|
||||
return SyntaxCheckers_python_pyflakes_GetHighlightRegex(a:i)
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_python_flake8_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'flake8',
|
||||
\ 'filetype': 'python',
|
||||
\ 'subchecker': 'flake8' })
|
||||
|
||||
let errorformat =
|
||||
\ '%E%f:%l: could not compile,%-Z%p^,'.
|
||||
\ '%W%f:%l:%c: F%n %m,'.
|
||||
\ '%W%f:%l:%c: C%n %m,'.
|
||||
\ '%E%f:%l:%c: %t%n %m,'.
|
||||
\ '%E%f:%l: %t%n %m,'.
|
||||
\ '%-G%.%#'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'python',
|
||||
\ 'name': 'flake8'})
|
||||
|
||||
runtime! syntax_checkers/python/pyflakes.vim
|
@ -0,0 +1,50 @@
|
||||
"============================================================================
|
||||
"File: pep257.vim
|
||||
"Description: Docstring style checking plugin for syntastic.vim
|
||||
"============================================================================
|
||||
"
|
||||
" For details about pep257 see: https://github.com/GreenSteam/pep257
|
||||
|
||||
if exists("g:loaded_syntastic_python_pep257_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_python_pep257_checker = 1
|
||||
|
||||
function! SyntaxCheckers_python_pep257_IsAvailable()
|
||||
return executable('pep257')
|
||||
endfunction
|
||||
|
||||
" sanity: kill empty lines here rather than munging errorformat
|
||||
function! SyntaxCheckers_python_pep257_Preprocess(errors)
|
||||
return filter(copy(a:errors), 'v:val != ""')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_python_pep257_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'pep257',
|
||||
\ 'filetype': 'python',
|
||||
\ 'subchecker': 'pep257' })
|
||||
|
||||
let errorformat =
|
||||
\ '%E%f:%l:%c%\%.%\%.%\d%\+:%\d%\+: %m,' .
|
||||
\ '%E%f:%l:%c: %m,' .
|
||||
\ '%+C %m'
|
||||
|
||||
let loclist = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'subtype': 'Style',
|
||||
\ 'preprocess': 'SyntaxCheckers_python_pep257_Preprocess',
|
||||
\ 'postprocess': ['compressWhitespace'] })
|
||||
|
||||
" pep257 outputs byte offsets rather than column numbers
|
||||
for n in range(len(loclist))
|
||||
let loclist[n]['col'] = get(loclist[n], 'col', 0) + 1
|
||||
endfor
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'python',
|
||||
\ 'name': 'pep257'})
|
46
sources_non_forked/syntastic/syntax_checkers/python/pep8.vim
Normal file
46
sources_non_forked/syntastic/syntax_checkers/python/pep8.vim
Normal file
@ -0,0 +1,46 @@
|
||||
"============================================================================
|
||||
"File: pep8.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: LCD 47 <lcd047 at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
"
|
||||
" For details about pep8 see: https://github.com/jcrocholl/pep8
|
||||
|
||||
if exists("g:loaded_syntastic_python_pep8_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_python_pep8_checker=1
|
||||
|
||||
function! SyntaxCheckers_python_pep8_IsAvailable()
|
||||
return executable('pep8')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_python_pep8_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'pep8',
|
||||
\ 'filetype': 'python',
|
||||
\ 'subchecker': 'pep8' })
|
||||
|
||||
let errorformat = '%f:%l:%c: %m'
|
||||
|
||||
let loclist = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'subtype': 'Style' })
|
||||
|
||||
for n in range(len(loclist))
|
||||
let loclist[n]['type'] = loclist[n]['text'] =~? '^W' ? 'W' : 'E'
|
||||
endfor
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'python',
|
||||
\ 'name': 'pep8'})
|
@ -0,0 +1,31 @@
|
||||
"============================================================================
|
||||
"File: py3kwarn.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Authors: Liam Curry <liam@curry.name>
|
||||
"
|
||||
"============================================================================
|
||||
if exists("g:loaded_syntastic_python_py3kwarn_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_python_py3kwarn_checker=1
|
||||
|
||||
function! SyntaxCheckers_python_py3kwarn_IsAvailable()
|
||||
return executable('py3kwarn')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_python_py3kwarn_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'py3kwarn',
|
||||
\ 'filetype': 'python',
|
||||
\ 'subchecker': 'py3kwarn' })
|
||||
|
||||
let errorformat = '%W%f:%l:%c: %m'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'python',
|
||||
\ 'name': 'py3kwarn'})
|
@ -0,0 +1,63 @@
|
||||
"============================================================================
|
||||
"File: pyflakes.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Authors: Martin Grenfell <martin.grenfell@gmail.com>
|
||||
" kstep <me@kstep.me>
|
||||
" Parantapa Bhattacharya <parantapa@gmail.com>
|
||||
"
|
||||
"============================================================================
|
||||
if exists("g:loaded_syntastic_python_pyflakes_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_python_pyflakes_checker=1
|
||||
|
||||
function! SyntaxCheckers_python_pyflakes_IsAvailable()
|
||||
return executable('pyflakes')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_python_pyflakes_GetHighlightRegex(i)
|
||||
if match(a:i['text'], 'is assigned to but never used') > -1
|
||||
\ || match(a:i['text'], 'imported but unused') > -1
|
||||
\ || match(a:i['text'], 'undefined name') > -1
|
||||
\ || match(a:i['text'], 'redefinition of') > -1
|
||||
\ || match(a:i['text'], 'referenced before assignment') > -1
|
||||
\ || match(a:i['text'], 'duplicate argument') > -1
|
||||
\ || match(a:i['text'], 'after other statements') > -1
|
||||
\ || match(a:i['text'], 'shadowed by loop variable') > -1
|
||||
|
||||
" fun with Python's %r: try "..." first, then '...'
|
||||
let terms = split(a:i['text'], '"', 1)
|
||||
if len(terms) > 2
|
||||
return terms[1]
|
||||
endif
|
||||
|
||||
let terms = split(a:i['text'], "'", 1)
|
||||
if len(terms) > 2
|
||||
return terms[1]
|
||||
endif
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_python_pyflakes_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'pyflakes',
|
||||
\ 'filetype': 'python',
|
||||
\ 'subchecker': 'pyflakes' })
|
||||
|
||||
let errorformat =
|
||||
\ '%E%f:%l: could not compile,'.
|
||||
\ '%-Z%p^,'.
|
||||
\ '%E%f:%l:%c: %m,'.
|
||||
\ '%E%f:%l: %m,'.
|
||||
\ '%-G%.%#'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'defaults': {'text': "Syntax error"} })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'python',
|
||||
\ 'name': 'pyflakes'})
|
@ -0,0 +1,67 @@
|
||||
"============================================================================
|
||||
"File: pylama.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Maintainer: LCD 47 <lcd047 at gmail dot com>
|
||||
"License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
" Want To Public License, Version 2, as published by Sam Hocevar.
|
||||
" See http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
"
|
||||
"============================================================================
|
||||
if exists('g:loaded_syntastic_python_pylama_checker')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_python_pylama_checker = 1
|
||||
|
||||
function! SyntaxCheckers_python_pylama_IsAvailable()
|
||||
return executable('pylama')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_python_pylama_GetHighlightRegex(i)
|
||||
return SyntaxCheckers_python_pyflakes_GetHighlightRegex(a:i)
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_python_pylama_GetLocList()
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'pylama',
|
||||
\ 'post_args': '-f pep8',
|
||||
\ 'filetype': 'python',
|
||||
\ 'subchecker': 'pylama' })
|
||||
|
||||
" TODO: "WARNING:pylama:..." messages are probably a logging bug
|
||||
let errorformat =
|
||||
\ '%-GWARNING:pylama:%.%#,' .
|
||||
\ '%A%f:%l:%c: %m'
|
||||
|
||||
let loclist = SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'postprocess': ['sort'] })
|
||||
|
||||
" adjust for weirdness in each checker
|
||||
for n in range(len(loclist))
|
||||
let loclist[n]['type'] = match(['R', 'C', 'W'], loclist[n]['text'][0]) >= 0 ? 'W' : 'E'
|
||||
if loclist[n]['text'] =~# '\v\[%(mccabe|pep257|pylint)\]$'
|
||||
if has_key(loclist[n], 'col')
|
||||
let loclist[n]['col'] += 1
|
||||
endif
|
||||
endif
|
||||
if loclist[n]['text'] =~# '\v\[pylint\]$'
|
||||
if has_key(loclist[n], 'vcol')
|
||||
let loclist[n]['vcol'] = 0
|
||||
endif
|
||||
endif
|
||||
if loclist[n]['text'] =~# '\v\[%(mccabe|pep257|pep8)\]$'
|
||||
let loclist[n]['subtype'] = 'Style'
|
||||
endif
|
||||
endfor
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'python',
|
||||
\ 'name': 'pylama' })
|
||||
|
||||
runtime! syntax_checkers/python/pyflakes.vim
|
@ -0,0 +1,58 @@
|
||||
"============================================================================
|
||||
"File: pylint.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Author: Parantapa Bhattacharya <parantapa at gmail dot com>
|
||||
"
|
||||
"============================================================================
|
||||
if exists("g:loaded_syntastic_python_pylint_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_python_pylint_checker=1
|
||||
|
||||
function! SyntaxCheckers_python_pylint_IsAvailable()
|
||||
return executable('pylint')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_python_pylint_GetLocList()
|
||||
let pylint_new = s:PylintNew()
|
||||
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'pylint',
|
||||
\ 'args': (pylint_new ? '--msg-template="{path}:{line}: [{msg_id}] {msg}" -r n' : '-f parseable -r n -i y'),
|
||||
\ 'filetype': 'python',
|
||||
\ 'subchecker': 'pylint' })
|
||||
|
||||
let errorformat =
|
||||
\ '%A%f:%l: %m,' .
|
||||
\ '%A%f:(%l): %m,' .
|
||||
\ '%-Z%p^%.%#,' .
|
||||
\ '%-G%.%#'
|
||||
|
||||
let loclist=SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat,
|
||||
\ 'postprocess': ['sort'] })
|
||||
|
||||
for n in range(len(loclist))
|
||||
let type = loclist[n]['text'][1]
|
||||
if type =~# '\m^[EF]'
|
||||
let loclist[n]['type'] = 'E'
|
||||
elseif type =~# '\m^[CRW]'
|
||||
let loclist[n]['type'] = 'W'
|
||||
else
|
||||
let loclist[n]['valid'] = 0
|
||||
endif
|
||||
let loclist[n]['vcol'] = 0
|
||||
endfor
|
||||
|
||||
return loclist
|
||||
endfunction
|
||||
|
||||
function s:PylintNew()
|
||||
let pylint_version = filter(split(system('pylint --version'), '\m, \|\n'), 'v:val =~# "^pylint"')[0]
|
||||
return syntastic#util#versionIsAtLeast(syntastic#util#parseVersion(pylint_version), [1])
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'python',
|
||||
\ 'name': 'pylint' })
|
@ -0,0 +1,43 @@
|
||||
"============================================================================
|
||||
"File: python.vim
|
||||
"Description: Syntax checking plugin for syntastic.vim
|
||||
"Author: Artem Nezvigin <artem at artnez dot com>
|
||||
"
|
||||
" `errorformat` derived from:
|
||||
" http://www.vim.org/scripts/download_script.php?src_id=1392
|
||||
"
|
||||
"============================================================================
|
||||
if exists("g:loaded_syntastic_python_python_checker")
|
||||
finish
|
||||
endif
|
||||
let g:loaded_syntastic_python_python_checker=1
|
||||
|
||||
function! SyntaxCheckers_python_python_IsAvailable()
|
||||
return executable('python')
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_python_python_GetLocList()
|
||||
let fname = "'" . escape(expand('%'), "\\'") . "'"
|
||||
|
||||
let makeprg = syntastic#makeprg#build({
|
||||
\ 'exe': 'python',
|
||||
\ 'args': '-c',
|
||||
\ 'fname': syntastic#util#shescape("compile(open(" . fname . ").read(), " . fname . ", 'exec')"),
|
||||
\ 'filetype': 'python',
|
||||
\ 'subchecker': 'python' })
|
||||
|
||||
let errorformat =
|
||||
\ '%E File "%f"\, line %l,' .
|
||||
\ '%C %p^,' .
|
||||
\ '%C %.%#,' .
|
||||
\ '%Z%m,' .
|
||||
\ '%-G%.%#'
|
||||
|
||||
return SyntasticMake({
|
||||
\ 'makeprg': makeprg,
|
||||
\ 'errorformat': errorformat })
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'python',
|
||||
\ 'name': 'python'})
|
Reference in New Issue
Block a user