Nimbin[12]?Mirrors & Forks / syntastic / commits / 1b7ef51a

syntastic git · master

syntastic vim plugin (fork)

vim fork · first commit 2009-07-10 · last commit 2022-07-10 (4 years ago) · synced 3 days ago · upstream: github.com/vim-syntastic/syntastic

Vim Script 99%
git clone https://git.christianimmanuel.de/mirrors-forks/syntastic.gitwget https://git.christianimmanuel.de/mirrors-forks/syntastic/archive/syntastic.tar.gz

Checker mypy: support for column numbers (@pbasista).

LCD 47 · 2018-01-04 10:40 · 1b7ef51ab52f9f673e587691f3f028887d56302c

 autoload/syntastic/preprocess.vim | 22 ++++++++++++++++------
 plugin/syntastic.vim              |  2 +-
 syntax_checkers/python/mypy.vim   | 13 ++++++++++---
 3 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/autoload/syntastic/preprocess.vim b/autoload/syntastic/preprocess.vim
index 79e4face..ff7f3a30 100644
--- a/autoload/syntastic/preprocess.vim
+++ b/autoload/syntastic/preprocess.vim
@@ -634,17 +634,27 @@ endfunction " }}}2
 function! syntastic#preprocess#mypy(errors) abort " {{{2
     let out = []
     for e in a:errors
-        " new format
-        let parts = matchlist(e, '\v^(.{-1,}):(\d+): error: (.+)')
-        if len(parts) > 3
-            call add(out, join(parts[1:3], ':'))
+        " column numbers
+        let parts = matchlist(e, '\v^(.{-1,}):(\d+):(\d+): ([ew])%(rror|arning): (.+)')
+        if len(parts) > 5
+            let parts[3] += 1
+            call add(out, join(parts[1:5], ':'))
             continue
         endif
 
-        " old format
+        " no column numbers
+        let parts = matchlist(e, '\v^(.{-1,}):(\d+): ([ew])%(rror|arning): (.+)')
+        if len(parts) > 4
+            call add(out, join(parts[1:4], ':'))
+            continue
+        endif
+
+        " obsolete format
         let parts = matchlist(e, '\v^(.{-1,}), line (\d+): (.+)')
         if len(parts) > 3
-            call add(out, join(parts[1:3], ':'))
+            let parts[4] = parts[3]
+            let parts[3] = 'e'
+            call add(out, join(parts[1:4], ':'))
         endif
     endfor
     return out
diff --git a/plugin/syntastic.vim b/plugin/syntastic.vim
index f25a1866..cedcaed6 100644
--- a/plugin/syntastic.vim
+++ b/plugin/syntastic.vim
@@ -19,7 +19,7 @@ if has('reltime')
     lockvar! g:_SYNTASTIC_START
 endif
 
-let g:_SYNTASTIC_VERSION = '3.8.0-100'
+let g:_SYNTASTIC_VERSION = '3.8.0-101'
 lockvar g:_SYNTASTIC_VERSION
 
 " Sanity checks {{{1
diff --git a/syntax_checkers/python/mypy.vim b/syntax_checkers/python/mypy.vim
index 7bdca6ad..9429a6f5 100644
--- a/syntax_checkers/python/mypy.vim
+++ b/syntax_checkers/python/mypy.vim
@@ -14,14 +14,21 @@ let s:save_cpo = &cpo
 set cpo&vim
 
 function! SyntaxCheckers_python_mypy_GetLocList() dict
-    let makeprg = self.makeprgBuild({})
+    if !exists('s:mypy_new')
+        " creative versioning: version string has changed from v0.4.6 to v0.470
+        " XXX the test should be fine for now, since 470 > 4
+        let s:mypy_new = syntastic#util#versionIsAtLeast(self.getVersion(), [0, 4, 5])
+    endif
 
-    let errorformat = '%f:%l:%m'
+    let makeprg = self.makeprgBuild({ 'args_after': (s:mypy_new ? '--show-column-numbers' : '') })
+
+    let errorformat =
+        \ '%f:%l:%c:%t:%m,' .
+        \ '%f:%l:%t:%m'
 
     return SyntasticMake({
         \ 'makeprg': makeprg,
         \ 'errorformat': errorformat,
-        \ 'defaults': { 'type': 'E' },
         \ 'returns': [0, 1],
         \ 'preprocess': 'mypy' })
 endfunction