1
0
mirror of https://github.com/amix/vimrc synced 2025-07-20 10:55:01 +08:00
This commit is contained in:
huangqundl
2017-03-17 23:12:53 +08:00
parent 47b213d974
commit cba39b7326
855 changed files with 59981 additions and 35298 deletions

View File

@ -0,0 +1,31 @@
#!/usr/bin/env python
from __future__ import print_function
from sys import argv, exit
import codecs
import re
import os
if len(argv) != 2:
exit(1)
try:
with open(argv[1]) as fle:
text = fle.readlines()
if text:
match = re.match(r"#\s*coding\s*:\s*(?P<coding>\w+)", text[0])
if match:
text = codecs.lookup(match.groupdict()["coding"]).incrementaldecoder().decode(
''.join(text).encode('utf-8')).encode('utf-8')
if isinstance(text, list):
text = ''.join(text).encode('utf-8')
compile(text, argv[1], 'exec', 0, 1)
except SyntaxError as err:
print('%s:%s:%s: %s' % (err.filename, err.lineno, err.offset, err.msg))
except Exception as err:
print('%s:%s:%s: %s' % (os.path.abspath(argv[1]), 1, 0, err))

View File

@ -6,7 +6,7 @@
"
"============================================================================
if exists("g:loaded_syntastic_python_flake8_checker")
if exists('g:loaded_syntastic_python_flake8_checker')
finish
endif
let g:loaded_syntastic_python_flake8_checker = 1
@ -44,7 +44,7 @@ function! SyntaxCheckers_python_flake8_GetLocList() dict
let e['text'] .= printf(' [%s%03d]', e['type'], e['nr'])
" E901 are syntax errors
" E902 are I/O errors
if e['type'] ==? 'E' && e['nr'] !~ '\m^9'
if e['type'] ==? 'E' && e['nr'] !~# '\m^9'
let e['subtype'] = 'Style'
endif
call remove(e, 'nr')
@ -69,4 +69,4 @@ call g:SyntasticRegistry.CreateAndRegisterChecker({
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -36,17 +36,17 @@ function! SyntaxCheckers_python_frosted_GetLocList() dict
\ 'returns': [0, 1] })
for e in loclist
let e["col"] += 1
let e['col'] += 1
let parts = matchlist(e.text, '\v^([EW]\d+):([^:]*):(.+)')
if len(parts) >= 4
let e["type"] = parts[1][0]
let e["text"] = parts[3] . ' [' . parts[1] . ']'
let e["hl"] = '\V\<' . escape(parts[2], '\') . '\>'
elseif e["text"] =~? '\v^I\d+:'
let e["valid"] = 0
let e['type'] = parts[1][0]
let e['text'] = parts[3] . ' [' . parts[1] . ']'
let e['hl'] = '\V\<' . escape(parts[2], '\') . '\>'
elseif e['text'] =~? '\v^I\d+:'
let e['valid'] = 0
else
let e["vcol"] = 0
let e['vcol'] = 0
endif
endfor
@ -60,4 +60,4 @@ call g:SyntasticRegistry.CreateAndRegisterChecker({
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -5,7 +5,7 @@
"
"============================================================================
if exists("g:loaded_syntastic_python_mypy_checker")
if exists('g:loaded_syntastic_python_mypy_checker')
finish
endif
let g:loaded_syntastic_python_mypy_checker = 1
@ -16,13 +16,14 @@ set cpo&vim
function! SyntaxCheckers_python_mypy_GetLocList() dict
let makeprg = self.makeprgBuild({})
let errorformat = '%f\, line %l: %m'
let errorformat = '%f:%l:%m'
return SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'defaults': { 'type': 'E' },
\ 'returns': [0, 1] })
\ 'returns': [0, 1],
\ 'preprocess': 'mypy' })
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
@ -32,4 +33,4 @@ call g:SyntasticRegistry.CreateAndRegisterChecker({
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,63 +1,23 @@
"============================================================================
"File: pep257.vim
"Description: Docstring style checking plugin for syntastic.vim
"============================================================================
"Description: Syntax checking plugin for syntastic
"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 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
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_python_pep257_GetLocList() dict
if !exists('s:pep257_new')
let ver = syntastic#util#getVersion(self.getExecEscaped() . ' --version')
call self.log(self.getExec() . ' version =', ver)
let s:pep257_new = syntastic#util#versionIsAtLeast(ver, [0, 3])
endif
let makeprg = self.makeprgBuild({})
if s:pep257_new
let errorformat =
\ '%E%f:%l %.%#:,' .
\ '%+C %m'
else
let errorformat =
\ '%E%f:%l:%c%\%.%\%.%\d%\+:%\d%\+: %m,' .
\ '%E%f:%l:%c: %m,' .
\ '%+C %m'
endif
let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' }
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'env': env,
\ 'subtype': 'Style',
\ 'preprocess': 'killEmpty',
\ 'postprocess': ['compressWhitespace'] })
if s:pep257_new == 0
" byte offsets rather than column numbers
for e in loclist
let e['col'] = get(e, 'col', 0) + 1
endfor
endif
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'python',
\ 'name': 'pep257'})
\ 'name': 'pep257',
\ 'redirect': 'python/pydocstyle'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,6 +1,6 @@
"============================================================================
"File: pep8.vim
"Description: Syntax checking plugin for syntastic.vim
"Description: Syntax checking plugin for syntastic
"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
@ -9,42 +9,15 @@
" 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")
if exists('g:loaded_syntastic_python_pep8_checker')
finish
endif
let g:loaded_syntastic_python_pep8_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_python_pep8_GetLocList() dict
let makeprg = self.makeprgBuild({})
let errorformat = '%f:%l:%c: %m'
let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' }
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'env': env,
\ 'subtype': 'Style' })
for e in loclist
let e['type'] = e['text'] =~? '^W' ? 'W' : 'E'
endfor
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'python',
\ 'name': 'pep8'})
\ 'name': 'pep8',
\ 'redirect': 'python/pycodestyle'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -10,7 +10,7 @@
"
"============================================================================
if exists("g:loaded_syntastic_python_prospector_checker")
if exists('g:loaded_syntastic_python_prospector_checker')
finish
endif
let g:loaded_syntastic_python_prospector_checker = 1
@ -26,16 +26,11 @@ function! SyntaxCheckers_python_prospector_IsAvailable() dict
if !executable(self.getExec())
return 0
endif
let ver = syntastic#util#getVersion(self.getExecEscaped() . ' --version')
call self.log(self.getExec() . ' version =', ver)
return syntastic#util#versionIsAtLeast(ver, [0, 7])
return syntastic#util#versionIsAtLeast(self.getVersion(), [0, 7])
endfunction
function! SyntaxCheckers_python_prospector_GetLocList() dict
let makeprg = self.makeprgBuild({
\ 'args': '--external-config merge',
\ 'args_after': '--messages-only --absolute-paths --die-on-tool-error --zero-exit --output-format json' })
let errorformat = '%f:%l:%c: %m'
@ -75,4 +70,4 @@ call g:SyntasticRegistry.CreateAndRegisterChecker({
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -5,7 +5,7 @@
"
"============================================================================
if exists("g:loaded_syntastic_python_py3kwarn_checker")
if exists('g:loaded_syntastic_python_py3kwarn_checker')
finish
endif
let g:loaded_syntastic_python_py3kwarn_checker = 1
@ -33,4 +33,4 @@ call g:SyntasticRegistry.CreateAndRegisterChecker({
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -0,0 +1,48 @@
"============================================================================
"File: pycodestyle.vim
"Description: Syntax checking plugin for syntastic
"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_pycodestyle_checker')
finish
endif
let g:loaded_syntastic_python_pycodestyle_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_python_pycodestyle_GetLocList() dict
let makeprg = self.makeprgBuild({})
let errorformat = '%f:%l:%c: %m'
let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' }
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'env': env,
\ 'subtype': 'Style' })
for e in loclist
let e['type'] = e['text'] =~? '^W' ? 'W' : 'E'
endfor
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'python',
\ 'name': 'pycodestyle'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -0,0 +1,66 @@
"============================================================================
"File: pydocstyle.vim
"Description: Syntax checking plugin for syntastic
"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_pydocstyle_checker')
finish
endif
let g:loaded_syntastic_python_pydocstyle_checker = 1
let s:save_cpo = &cpo
set cpo&vim
function! SyntaxCheckers_python_pydocstyle_GetLocList() dict
if !exists('s:pydocstyle_new')
let s:pydocstyle_new = syntastic#util#versionIsAtLeast(self.getVersion(), [0, 3])
endif
let makeprg = self.makeprgBuild({})
if s:pydocstyle_new
let errorformat =
\ '%E%f:%l %.%#:,' .
\ '%+C %m'
else
let errorformat =
\ '%E%f:%l:%c%\%.%\%.%\d%\+:%\d%\+: %m,' .
\ '%E%f:%l:%c: %m,' .
\ '%+C %m'
endif
let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' }
let loclist = SyntasticMake({
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'env': env,
\ 'subtype': 'Style',
\ 'preprocess': 'killEmpty',
\ 'postprocess': ['compressWhitespace'] })
if s:pydocstyle_new == 0
" byte offsets rather than column numbers
for e in loclist
let e['col'] = get(e, 'col', 0) + 1
endfor
endif
return loclist
endfunction
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'python',
\ 'name': 'pydocstyle'})
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -7,7 +7,7 @@
"
"============================================================================
if exists("g:loaded_syntastic_python_pyflakes_checker")
if exists('g:loaded_syntastic_python_pyflakes_checker')
finish
endif
let g:loaded_syntastic_python_pyflakes_checker = 1
@ -27,12 +27,12 @@ function! SyntaxCheckers_python_pyflakes_GetHighlightRegex(i)
" fun with Python's %r: try "..." first, then '...'
let term = matchstr(a:i['text'], '\m^.\{-}"\zs.\{-1,}\ze"')
if term != ''
if term !=# ''
return '\V\<' . escape(term, '\') . '\>'
endif
let term = matchstr(a:i['text'], '\m^.\{-}''\zs.\{-1,}\ze''')
if term != ''
if term !=# ''
return '\V\<' . escape(term, '\') . '\>'
endif
endif
@ -55,7 +55,7 @@ function! SyntaxCheckers_python_pyflakes_GetLocList() dict
\ 'makeprg': makeprg,
\ 'errorformat': errorformat,
\ 'env': env,
\ 'defaults': {'text': "Syntax error"} })
\ 'defaults': {'text': 'Syntax error'} })
for e in loclist
let e['vcol'] = 0
@ -71,4 +71,4 @@ call g:SyntasticRegistry.CreateAndRegisterChecker({
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -27,7 +27,12 @@ function! SyntaxCheckers_python_pylama_GetHighlightRegex(item)
endfunction
function! SyntaxCheckers_python_pylama_GetLocList() dict
let makeprg = self.makeprgBuild({ 'args_after': '-f pep8' })
if !exists('s:pylama_new')
let s:pylama_new = syntastic#util#versionIsAtLeast(self.getVersion(), [4])
endif
let makeprg = self.makeprgBuild({
\ 'args_after': '-f pep8' . (s:pylama_new ? ' --force' : '') })
" TODO: "WARNING:pylama:..." messages are probably a logging bug
let errorformat =
@ -44,7 +49,7 @@ function! SyntaxCheckers_python_pylama_GetLocList() dict
" adjust for weirdness in each checker
for e in loclist
let e['type'] = e['text'] =~? '\m^[RCW]' ? 'W' : 'E'
if e['text'] =~# '\v\[%(mccabe|pep257|pylint)\]$'
if e['text'] =~# '\v\[%(isort|mccabe|pep257|pylint)\]$'
if has_key(e, 'col')
let e['col'] += 1
endif
@ -54,7 +59,7 @@ function! SyntaxCheckers_python_pylama_GetLocList() dict
let e['vcol'] = 0
endif
endif
if e['text'] =~# '\v\[%(mccabe|pep257|pep8)\]$'
if e['text'] =~# '\v\[%(isort|mccabe|pep257|pep8)\]$'
let e['subtype'] = 'Style'
endif
endfor
@ -71,4 +76,4 @@ call g:SyntasticRegistry.CreateAndRegisterChecker({
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -1,11 +1,11 @@
"============================================================================
"File: pylint.vim
"Description: Syntax checking plugin for syntastic.vim
"Author: Parantapa Bhattacharya <parantapa at gmail dot com>
"Maintainer: Parantapa Bhattacharya <parantapa at gmail dot com>
"
"============================================================================
if exists("g:loaded_syntastic_python_pylint_checker")
if exists('g:loaded_syntastic_python_pylint_checker')
finish
endif
let g:loaded_syntastic_python_pylint_checker = 1
@ -19,7 +19,7 @@ set cpo&vim
let s:pylint_new = -1
function! SyntaxCheckers_python_pylint_IsAvailable() dict
function! SyntaxCheckers_python_pylint_IsAvailable() dict " {{{1
if !executable(self.getExec())
return 0
endif
@ -32,22 +32,22 @@ function! SyntaxCheckers_python_pylint_IsAvailable() dict
" On new-ish Fedora it's "python3-pylint 1.2.0".
" Have you guys considered switching to creative writing yet? ;)
let pylint_version = filter( split(system(self.getExecEscaped() . ' --version'), '\m, \=\|\n'),
\ 'v:val =~# ''\m^\(python[-0-9]*-\|\.\)\=pylint[-0-9]*\>''' )[0]
let ver = syntastic#util#parseVersion(substitute(pylint_version, '\v^\S+\s+', '', ''))
let version_output = syntastic#util#system(self.getExecEscaped() . ' --version')
let pylint_version = filter( split(version_output, '\m, \=\|\n'), 'v:val =~# ''\m^\(python[-0-9]*-\|\.\)\=pylint[-0-9]*\>''' )[0]
let parsed_ver = syntastic#util#parseVersion(substitute(pylint_version, '\v^\S+\s+', '', ''))
call self.setVersion(parsed_ver)
call self.log(self.getExec() . ' version =', ver)
let s:pylint_new = syntastic#util#versionIsAtLeast(ver, [1])
let s:pylint_new = syntastic#util#versionIsAtLeast(parsed_ver, [1])
catch /\m^Vim\%((\a\+)\)\=:E684/
call syntastic#log#ndebug(g:_SYNTASTIC_DEBUG_LOCLIST, 'checker output:', split(version_output, "\n", 1))
call syntastic#log#error("checker python/pylint: can't parse version string (abnormal termination?)")
let s:pylint_new = -1
endtry
return s:pylint_new >= 0
endfunction
endfunction " }}}1
function! SyntaxCheckers_python_pylint_GetLocList() dict
function! SyntaxCheckers_python_pylint_GetLocList() dict " {{{1
let makeprg = self.makeprgBuild({
\ 'args_after': (s:pylint_new ?
\ '-f text --msg-template="{path}:{line}:{column}:{C}: [{symbol}] {msg}" -r n' :
@ -86,7 +86,7 @@ function! SyntaxCheckers_python_pylint_GetLocList() dict
endfor
return loclist
endfunction
endfunction " }}}1
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'python',
@ -95,4 +95,4 @@ call g:SyntasticRegistry.CreateAndRegisterChecker({
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:
" vim: set sw=4 sts=4 et fdm=marker:

View File

@ -10,29 +10,31 @@
"
"============================================================================
if exists("g:loaded_syntastic_python_python_checker")
if exists('g:loaded_syntastic_python_python_checker')
finish
endif
let g:loaded_syntastic_python_python_checker = 1
if !exists('g:syntastic_python_python_use_codec')
let g:syntastic_python_python_use_codec = 0
endif
let s:save_cpo = &cpo
set cpo&vim
let s:compiler = expand('<sfile>:p:h') . syntastic#util#Slash() . 'compile.py'
let s:base_path = expand('<sfile>:p:h', 1) . syntastic#util#Slash()
function! SyntaxCheckers_python_python_IsAvailable() dict
if !executable(self.getExec())
return 0
endif
let ver = syntastic#util#getVersion(self.getExecEscaped() . ' --version')
call self.log(self.getExec() . ' version =', ver)
return syntastic#util#versionIsAtLeast(ver, [2, 6])
return syntastic#util#versionIsAtLeast(self.getVersion(), [2, 6])
endfunction
function! SyntaxCheckers_python_python_GetLocList() dict
let makeprg = self.makeprgBuild({ 'exe': [self.getExec(), s:compiler] })
let compiler = s:base_path . (g:syntastic_python_python_use_codec ? 'codec.py' : 'compile.py')
call self.log('using compiler script', compiler)
let makeprg = self.makeprgBuild({ 'exe': [self.getExec(), compiler] })
let errorformat = '%E%f:%l:%c: %m'
@ -52,4 +54,4 @@ call g:SyntasticRegistry.CreateAndRegisterChecker({
let &cpo = s:save_cpo
unlet s:save_cpo
" vim: set et sts=4 sw=4:
" vim: set sw=4 sts=4 et fdm=marker: