From e573b3020c032400eed60b649a2cbf55266e6bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 30 Jun 2016 16:03:25 +0200 Subject: Add current configurations from old repository --- .../syntastic/syntax_checkers/python/codec.py | 31 +++++++ .../syntastic/syntax_checkers/python/compile.py | 13 +++ .../syntastic/syntax_checkers/python/flake8.vim | 72 ++++++++++++++++ .../syntastic/syntax_checkers/python/frosted.vim | 63 ++++++++++++++ .../syntastic/syntax_checkers/python/mypy.vim | 36 ++++++++ .../syntastic/syntax_checkers/python/pep257.vim | 23 +++++ .../syntastic/syntax_checkers/python/pep8.vim | 23 +++++ .../syntax_checkers/python/prospector.vim | 73 ++++++++++++++++ .../syntastic/syntax_checkers/python/py3kwarn.vim | 36 ++++++++ .../syntax_checkers/python/pycodestyle.vim | 48 +++++++++++ .../syntax_checkers/python/pydocstyle.vim | 66 +++++++++++++++ .../syntastic/syntax_checkers/python/pyflakes.vim | 74 ++++++++++++++++ .../syntastic/syntax_checkers/python/pylama.vim | 79 +++++++++++++++++ .../syntastic/syntax_checkers/python/pylint.vim | 98 ++++++++++++++++++++++ .../syntastic/syntax_checkers/python/python.vim | 57 +++++++++++++ 15 files changed, 792 insertions(+) create mode 100755 vim/bundle/syntastic/syntax_checkers/python/codec.py create mode 100755 vim/bundle/syntastic/syntax_checkers/python/compile.py create mode 100644 vim/bundle/syntastic/syntax_checkers/python/flake8.vim create mode 100644 vim/bundle/syntastic/syntax_checkers/python/frosted.vim create mode 100644 vim/bundle/syntastic/syntax_checkers/python/mypy.vim create mode 100644 vim/bundle/syntastic/syntax_checkers/python/pep257.vim create mode 100644 vim/bundle/syntastic/syntax_checkers/python/pep8.vim create mode 100644 vim/bundle/syntastic/syntax_checkers/python/prospector.vim create mode 100644 vim/bundle/syntastic/syntax_checkers/python/py3kwarn.vim create mode 100644 vim/bundle/syntastic/syntax_checkers/python/pycodestyle.vim create mode 100644 vim/bundle/syntastic/syntax_checkers/python/pydocstyle.vim create mode 100644 vim/bundle/syntastic/syntax_checkers/python/pyflakes.vim create mode 100644 vim/bundle/syntastic/syntax_checkers/python/pylama.vim create mode 100644 vim/bundle/syntastic/syntax_checkers/python/pylint.vim create mode 100644 vim/bundle/syntastic/syntax_checkers/python/python.vim (limited to 'vim/bundle/syntastic/syntax_checkers/python') diff --git a/vim/bundle/syntastic/syntax_checkers/python/codec.py b/vim/bundle/syntastic/syntax_checkers/python/codec.py new file mode 100755 index 0000000..6e980c7 --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/python/codec.py @@ -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\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)) diff --git a/vim/bundle/syntastic/syntax_checkers/python/compile.py b/vim/bundle/syntastic/syntax_checkers/python/compile.py new file mode 100755 index 0000000..32f1413 --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/python/compile.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python + +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)) diff --git a/vim/bundle/syntastic/syntax_checkers/python/flake8.vim b/vim/bundle/syntastic/syntax_checkers/python/flake8.vim new file mode 100644 index 0000000..257b69d --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/python/flake8.vim @@ -0,0 +1,72 @@ +"============================================================================ +"File: flake8.vim +"Description: Syntax checking plugin for syntastic.vim +"Authors: Sylvain Soliman +" kstep +" +"============================================================================ + +if exists('g:loaded_syntastic_python_flake8_checker') + finish +endif +let g:loaded_syntastic_python_flake8_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_python_flake8_GetHighlightRegex(item) + return SyntaxCheckers_python_pyflakes_GetHighlightRegex(a:item) +endfunction + +function! SyntaxCheckers_python_flake8_GetLocList() dict + let makeprg = self.makeprgBuild({}) + + let errorformat = + \ '%E%f:%l: could not compile,%-Z%p^,' . + \ '%A%f:%l:%c: %t%n %m,' . + \ '%A%f:%l: %t%n %m,' . + \ '%-G%.%#' + + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + + let loclist = SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'env': env }) + + for e in loclist + " E*** and W*** are pep8 errors + " F*** are PyFlakes codes + " C*** are McCabe complexity messages + " N*** are naming conventions from pep8-naming + + if has_key(e, 'nr') + 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' + let e['subtype'] = 'Style' + endif + call remove(e, 'nr') + endif + + if e['type'] =~? '\m^[CNW]' + let e['subtype'] = 'Style' + endif + + let e['type'] = e['type'] =~? '\m^[EFC]' ? 'E' : 'W' + endfor + + return loclist +endfunction + +runtime! syntax_checkers/python/pyflakes.vim + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'python', + \ 'name': 'flake8'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/syntastic/syntax_checkers/python/frosted.vim b/vim/bundle/syntastic/syntax_checkers/python/frosted.vim new file mode 100644 index 0000000..d642795 --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/python/frosted.vim @@ -0,0 +1,63 @@ +"============================================================================ +"File: frosted.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: LCD 47 +"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_frosted_checker') + finish +endif +let g:loaded_syntastic_python_frosted_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_python_frosted_GetLocList() dict + let makeprg = self.makeprgBuild({ 'args_after': '-vb' }) + + let errorformat = + \ '%f:%l:%c:%m,' . + \ '%E%f:%l: %m,' . + \ '%-Z%p^,' . + \ '%-G%.%#' + + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + + let loclist = SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'env': env, + \ 'returns': [0, 1] }) + + for e in loclist + 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 + else + let e['vcol'] = 0 + endif + endfor + + return loclist +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'python', + \ 'name': 'frosted' }) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/syntastic/syntax_checkers/python/mypy.vim b/vim/bundle/syntastic/syntax_checkers/python/mypy.vim new file mode 100644 index 0000000..19ca1fd --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/python/mypy.vim @@ -0,0 +1,36 @@ +"============================================================================ +"File: mypy.vim +"Description: Syntax checking plugin for syntastic.vim +"Author: Russ Hewgill +" +"============================================================================ + +if exists('g:loaded_syntastic_python_mypy_checker') + finish +endif +let g:loaded_syntastic_python_mypy_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_python_mypy_GetLocList() dict + let makeprg = self.makeprgBuild({}) + + let errorformat = '%f:%l:%m' + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'defaults': { 'type': 'E' }, + \ 'returns': [0, 1], + \ 'preprocess': 'mypy' }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'python', + \ 'name': 'mypy'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/syntastic/syntax_checkers/python/pep257.vim b/vim/bundle/syntastic/syntax_checkers/python/pep257.vim new file mode 100644 index 0000000..e59166b --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/python/pep257.vim @@ -0,0 +1,23 @@ +"============================================================================ +"File: pep257.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: LCD 47 +"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_pep257_checker') + finish +endif +let g:loaded_syntastic_python_pep257_checker = 1 + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'python', + \ 'name': 'pep257', + \ 'redirect': 'python/pydocstyle'}) + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/syntastic/syntax_checkers/python/pep8.vim b/vim/bundle/syntastic/syntax_checkers/python/pep8.vim new file mode 100644 index 0000000..80ab980 --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/python/pep8.vim @@ -0,0 +1,23 @@ +"============================================================================ +"File: pep8.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: LCD 47 +"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_pep8_checker') + finish +endif +let g:loaded_syntastic_python_pep8_checker = 1 + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'python', + \ 'name': 'pep8', + \ 'redirect': 'python/pycodestyle'}) + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/syntastic/syntax_checkers/python/prospector.vim b/vim/bundle/syntastic/syntax_checkers/python/prospector.vim new file mode 100644 index 0000000..c5e4735 --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/python/prospector.vim @@ -0,0 +1,73 @@ +"============================================================================ +"File: prospector.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: LCD 47 +"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_prospector_checker') + finish +endif +let g:loaded_syntastic_python_prospector_checker = 1 + +if !exists('g:syntastic_python_prospector_sort') + let g:syntastic_python_prospector_sort = 1 +endif + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_python_prospector_IsAvailable() dict + if !executable(self.getExec()) + return 0 + endif + return syntastic#util#versionIsAtLeast(self.getVersion(), [0, 7]) +endfunction + +function! SyntaxCheckers_python_prospector_GetLocList() dict + let makeprg = self.makeprgBuild({ + \ 'args_after': '--messages-only --absolute-paths --die-on-tool-error --zero-exit --output-format json' }) + + let errorformat = '%f:%l:%c: %m' + + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + + let loclist = SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'env': env, + \ 'preprocess': 'prospector', + \ 'returns': [0] }) + + for e in loclist + if e['text'] =~# '\v\[%(dodgy|mccabe|pep8|pep257|pyroma)\]$' + let e['subtype'] = 'Style' + endif + + if e['text'] =~# '\v\[pylint\]$' + let e['type'] = e['text'] =~? '\m^[CRW]' ? 'W' : 'E' + elseif e['text'] =~# '\v\[%(frosted|pep8)\]$' + let e['type'] = e['text'] =~? '\m^W' ? 'W' : 'E' + elseif e['text'] =~# '\v\[%(dodgy|pyroma|vulture)\]$' + let e['type'] = 'W' + else + let e['type'] = 'E' + endif + endfor + + return loclist +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'python', + \ 'name': 'prospector'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/syntastic/syntax_checkers/python/py3kwarn.vim b/vim/bundle/syntastic/syntax_checkers/python/py3kwarn.vim new file mode 100644 index 0000000..b0e7771 --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/python/py3kwarn.vim @@ -0,0 +1,36 @@ +"============================================================================ +"File: py3kwarn.vim +"Description: Syntax checking plugin for syntastic.vim +"Authors: Liam Curry +" +"============================================================================ + +if exists('g:loaded_syntastic_python_py3kwarn_checker') + finish +endif +let g:loaded_syntastic_python_py3kwarn_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_python_py3kwarn_GetLocList() dict + let makeprg = self.makeprgBuild({}) + + let errorformat = '%W%f:%l:%c: %m' + + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'env': env }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'python', + \ 'name': 'py3kwarn'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/syntastic/syntax_checkers/python/pycodestyle.vim b/vim/bundle/syntastic/syntax_checkers/python/pycodestyle.vim new file mode 100644 index 0000000..3b1e705 --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/python/pycodestyle.vim @@ -0,0 +1,48 @@ +"============================================================================ +"File: pycodestyle.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: LCD 47 +"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: diff --git a/vim/bundle/syntastic/syntax_checkers/python/pydocstyle.vim b/vim/bundle/syntastic/syntax_checkers/python/pydocstyle.vim new file mode 100644 index 0000000..05ea6b3 --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/python/pydocstyle.vim @@ -0,0 +1,66 @@ +"============================================================================ +"File: pydocstyle.vim +"Description: Syntax checking plugin for syntastic +"Maintainer: LCD 47 +"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: diff --git a/vim/bundle/syntastic/syntax_checkers/python/pyflakes.vim b/vim/bundle/syntastic/syntax_checkers/python/pyflakes.vim new file mode 100644 index 0000000..d403135 --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/python/pyflakes.vim @@ -0,0 +1,74 @@ +"============================================================================ +"File: pyflakes.vim +"Description: Syntax checking plugin for syntastic.vim +"Authors: Martin Grenfell +" kstep +" Parantapa Bhattacharya +" +"============================================================================ + +if exists('g:loaded_syntastic_python_pyflakes_checker') + finish +endif +let g:loaded_syntastic_python_pyflakes_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_python_pyflakes_GetHighlightRegex(i) + if stridx(a:i['text'], 'is assigned to but never used') >= 0 + \ || stridx(a:i['text'], 'imported but unused') >= 0 + \ || stridx(a:i['text'], 'undefined name') >= 0 + \ || stridx(a:i['text'], 'redefinition of') >= 0 + \ || stridx(a:i['text'], 'referenced before assignment') >= 0 + \ || stridx(a:i['text'], 'duplicate argument') >= 0 + \ || stridx(a:i['text'], 'after other statements') >= 0 + \ || stridx(a:i['text'], 'shadowed by loop variable') >= 0 + + " fun with Python's %r: try "..." first, then '...' + let term = matchstr(a:i['text'], '\m^.\{-}"\zs.\{-1,}\ze"') + if term !=# '' + return '\V\<' . escape(term, '\') . '\>' + endif + + let term = matchstr(a:i['text'], '\m^.\{-}''\zs.\{-1,}\ze''') + if term !=# '' + return '\V\<' . escape(term, '\') . '\>' + endif + endif + return '' +endfunction + +function! SyntaxCheckers_python_pyflakes_GetLocList() dict + let makeprg = self.makeprgBuild({}) + + let errorformat = + \ '%E%f:%l: could not compile,'. + \ '%-Z%p^,'. + \ '%E%f:%l:%c: %m,'. + \ '%E%f:%l: %m,'. + \ '%-G%.%#' + + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + + let loclist = SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'env': env, + \ 'defaults': {'text': 'Syntax error'} }) + + for e in loclist + let e['vcol'] = 0 + endfor + + return loclist +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'python', + \ 'name': 'pyflakes'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/syntastic/syntax_checkers/python/pylama.vim b/vim/bundle/syntastic/syntax_checkers/python/pylama.vim new file mode 100644 index 0000000..d4aab0a --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/python/pylama.vim @@ -0,0 +1,79 @@ +"============================================================================ +"File: pylama.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: LCD 47 +"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 + +if !exists('g:syntastic_python_pylama_sort') + let g:syntastic_python_pylama_sort = 1 +endif + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_python_pylama_GetHighlightRegex(item) + return SyntaxCheckers_python_pyflakes_GetHighlightRegex(a:item) +endfunction + +function! SyntaxCheckers_python_pylama_GetLocList() dict + 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 = + \ '%-GWARNING:pylama:%.%#,' . + \ '%A%f:%l:%c: %m' + + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + + let loclist = SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'env': env }) + + " adjust for weirdness in each checker + for e in loclist + let e['type'] = e['text'] =~? '\m^[RCW]' ? 'W' : 'E' + if e['text'] =~# '\v\[%(isort|mccabe|pep257|pylint)\]$' + if has_key(e, 'col') + let e['col'] += 1 + endif + endif + if e['text'] =~# '\v\[pylint\]$' + if has_key(e, 'vcol') + let e['vcol'] = 0 + endif + endif + if e['text'] =~# '\v\[%(isort|mccabe|pep257|pep8)\]$' + let e['subtype'] = 'Style' + endif + endfor + + return loclist +endfunction + +runtime! syntax_checkers/python/pyflakes.vim + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'python', + \ 'name': 'pylama' }) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/syntastic/syntax_checkers/python/pylint.vim b/vim/bundle/syntastic/syntax_checkers/python/pylint.vim new file mode 100644 index 0000000..884d07a --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/python/pylint.vim @@ -0,0 +1,98 @@ +"============================================================================ +"File: pylint.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: Parantapa Bhattacharya +" +"============================================================================ + +if exists('g:loaded_syntastic_python_pylint_checker') + finish +endif +let g:loaded_syntastic_python_pylint_checker = 1 + +if !exists('g:syntastic_python_pylint_sort') + let g:syntastic_python_pylint_sort = 1 +endif + +let s:save_cpo = &cpo +set cpo&vim + +let s:pylint_new = -1 + +function! SyntaxCheckers_python_pylint_IsAvailable() dict " {{{1 + if !executable(self.getExec()) + return 0 + endif + + try + " On Windows the version is shown as "pylint-script.py 1.0.0". + " On Gentoo Linux it's "pylint-python2.7 0.28.0". + " On NixOS, that would be ".pylint-wrapped 0.26.0". + " On Arch Linux it's "pylint2 1.1.0". + " On new-ish Fedora it's "python3-pylint 1.2.0". + " Have you guys considered switching to creative writing yet? ;) + + 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) + + 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 " }}}1 + +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' : + \ '-f parseable -r n -i y') }) + + let errorformat = + \ '%A%f:%l:%c:%t: %m,' . + \ '%A%f:%l: %m,' . + \ '%A%f:(%l): %m,' . + \ '%-Z%p^%.%#,' . + \ '%-G%.%#' + + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + + let loclist = SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'env': env, + \ 'returns': range(32) }) + + for e in loclist + if !s:pylint_new + let e['type'] = e['text'][1] + endif + + if e['type'] =~? '\m^[EF]' + let e['type'] = 'E' + elseif e['type'] =~? '\m^[CRW]' + let e['type'] = 'W' + else + let e['valid'] = 0 + endif + + let e['col'] += 1 + let e['vcol'] = 0 + endfor + + return loclist +endfunction " }}}1 + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'python', + \ 'name': 'pylint' }) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/vim/bundle/syntastic/syntax_checkers/python/python.vim b/vim/bundle/syntastic/syntax_checkers/python/python.vim new file mode 100644 index 0000000..17ad2c9 --- /dev/null +++ b/vim/bundle/syntastic/syntax_checkers/python/python.vim @@ -0,0 +1,57 @@ +"============================================================================ +"File: python.vim +"Description: Syntax checking plugin for syntastic.vim +"Maintainer: LCD 47 +"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_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:base_path = expand(':p:h', 1) . syntastic#util#Slash() + +function! SyntaxCheckers_python_python_IsAvailable() dict + if !executable(self.getExec()) + return 0 + endif + return syntastic#util#versionIsAtLeast(self.getVersion(), [2, 6]) +endfunction + +function! SyntaxCheckers_python_python_GetLocList() dict + 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' + + let env = syntastic#util#isRunningWindows() ? {} : { 'TERM': 'dumb' } + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat, + \ 'env': env, + \ 'returns': [0] }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'python', + \ 'name': 'python'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: -- cgit v1.2.3