Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 74fd7e6

Browse files
committed
Show chacker output when whining that we can't parse version string.
1 parent 2e60dd4 commit 74fd7e6

6 files changed

Lines changed: 45 additions & 35 deletions

File tree

plugin/syntastic.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if has('reltime')
1919
lockvar! g:_SYNTASTIC_START
2020
endif
2121

22-
let g:_SYNTASTIC_VERSION = '3.6.0-119'
22+
let g:_SYNTASTIC_VERSION = '3.6.0-120'
2323
lockvar g:_SYNTASTIC_VERSION
2424

2525
" Sanity checks {{{1

plugin/syntastic/checker.vim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,13 @@ function! g:SyntasticChecker.getVersion(...) abort " {{{2
127127
call self.log('getVersion: ' . string(command) . ': ' .
128128
\ string(split(version_output, "\n", 1)) .
129129
\ (v:shell_error ? ' (exit code ' . v:shell_error . ')' : '') )
130-
call self.setVersion(syntastic#util#parseVersion(version_output))
130+
let parsed_ver = syntastic#util#parseVersion(version_output)
131+
if len(parsed_ver)
132+
call self.setVersion(parsed_ver)
133+
else
134+
call syntastic#log#ndebug(g:_SYNTASTIC_DEBUG_LOCLIST, 'checker output:', split(version_output, "\n", 1))
135+
call syntastic#log#error("checker " . self._filetype . "/" . self._name . ": can't parse version string (abnormal termination?)")
136+
endif
131137
endif
132138
return get(self, '_version', [])
133139
endfunction " }}}2
@@ -136,8 +142,6 @@ function! g:SyntasticChecker.setVersion(version) abort " {{{2
136142
if len(a:version)
137143
let self._version = copy(a:version)
138144
call self.log(self.getExec() . ' version =', a:version)
139-
else
140-
call syntastic#log#error("checker " . self._filetype . "/" . self._name . ": can't parse version string (abnormal termination?)")
141145
endif
142146
endfunction " }}}2
143147

syntax_checkers/haskell/ghc-mod.vim

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,23 @@ function! SyntaxCheckers_haskell_ghc_mod_IsAvailable() dict
3030
" know the version in order to know how to find out the version. :)
3131

3232
" Try "ghc-mod version".
33-
let ver = filter(split(syntastic#util#system(self.getExecEscaped() . ' version'), '\n'), 'v:val =~# ''\m\sversion''')
33+
let version_output = split(syntastic#util#system(self.getExecEscaped() . ' version'), '\n', 1)
34+
let ver = filter(copy(version_output), 'v:val =~# ''\m\sversion''')
3435
if !len(ver)
3536
" That didn't work. Try "ghc-mod" alone.
36-
let ver = filter(split(syntastic#util#system(self.getExecEscaped()), '\n'), 'v:val =~# ''\m\sversion''')
37+
let version_output = split(syntastic#util#system(self.getExecEscaped()), '\n', 1)
38+
let ver = filter(copy(version_output), 'v:val =~# ''\m\sversion''')
3739
endif
40+
let parsed_ver = len(ver) ? syntastic#util#parseVersion(ver[0]) : []
3841

39-
if len(ver)
42+
if len(parsed_ver)
4043
" Encouraged by the great success in finding out the version, now we
4144
" need either a Vim that can handle NULs in system() output, or a
4245
" ghc-mod that has the "--boundary" option.
43-
let parsed_ver = syntastic#util#parseVersion(ver[0])
4446
call self.setVersion(parsed_ver)
4547
let s:ghc_mod_new = syntastic#util#versionIsAtLeast(parsed_ver, [2, 1, 2])
4648
else
49+
call syntastic#log#ndebug(g:_SYNTASTIC_DEBUG_LOCLIST, 'checker output:', version_output)
4750
call syntastic#log#error("checker haskell/ghc_mod: can't parse version string (abnormal termination?)")
4851
let s:ghc_mod_new = -1
4952
endif

syntax_checkers/javascript/jsxhint.vim

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ let s:save_cpo = &cpo
1818
set cpo&vim
1919

2020
function! SyntaxCheckers_javascript_jsxhint_IsAvailable() dict
21-
let jsxhint_version = syntastic#util#system(self.getExecEscaped() . ' --version')
22-
if v:shell_error || (jsxhint_version !~# '\m^JSXHint\>')
23-
return 0
21+
let version_output = syntastic#util#system(self.getExecEscaped() . ' --version')
22+
let parsed_ver = !v:shell_error && (version_output =~# '\m^JSXHint\>') ? syntastic#util#parseVersion(version_output) : []
23+
if len(parsed_ver)
24+
call self.setVersion(parsed_ver)
25+
else
26+
call syntastic#log#ndebug(g:_SYNTASTIC_DEBUG_LOCLIST, 'checker output:', split(version_output, "\n", 1))
27+
call syntastic#log#error("checker javascript/jsxhint: can't parse version string (abnormal termination?)")
2428
endif
2529

26-
let ver = syntastic#util#parseVersion(jsxhint_version)
27-
call self.setVersion(ver)
28-
29-
return syntastic#util#versionIsAtLeast(ver, [0, 4, 1])
30+
return syntastic#util#versionIsAtLeast(parsed_ver, [0, 4, 1])
3031
endfunction
3132

3233
function! SyntaxCheckers_javascript_jsxhint_GetLocList() dict

syntax_checkers/python/pylint.vim

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"============================================================================
22
"File: pylint.vim
33
"Description: Syntax checking plugin for syntastic.vim
4-
"Author: Parantapa Bhattacharya <parantapa at gmail dot com>
4+
"Maintainer: Parantapa Bhattacharya <parantapa at gmail dot com>
55
"
66
"============================================================================
77

@@ -32,13 +32,14 @@ function! SyntaxCheckers_python_pylint_IsAvailable() dict
3232
" On new-ish Fedora it's "python3-pylint 1.2.0".
3333
" Have you guys considered switching to creative writing yet? ;)
3434

35-
let pylint_version = filter( split(syntastic#util#system(self.getExecEscaped() . ' --version'), '\m, \=\|\n'),
36-
\ 'v:val =~# ''\m^\(python[-0-9]*-\|\.\)\=pylint[-0-9]*\>''' )[0]
37-
let ver = syntastic#util#parseVersion(substitute(pylint_version, '\v^\S+\s+', '', ''))
38-
call self.setVersion(ver)
35+
let version_output = syntastic#util#system(self.getExecEscaped() . ' --version')
36+
let pylint_version = filter( split(version_output, '\m, \=\|\n'), 'v:val =~# ''\m^\(python[-0-9]*-\|\.\)\=pylint[-0-9]*\>''' )[0]
37+
let parsed_ver = syntastic#util#parseVersion(substitute(pylint_version, '\v^\S+\s+', '', ''))
38+
call self.setVersion(parsed_ver)
3939

40-
let s:pylint_new = syntastic#util#versionIsAtLeast(ver, [1])
40+
let s:pylint_new = syntastic#util#versionIsAtLeast(parsed_ver, [1])
4141
catch /\m^Vim\%((\a\+)\)\=:E684/
42+
call syntastic#log#ndebug(g:_SYNTASTIC_DEBUG_LOCLIST, 'checker output:', split(version_output, "\n", 1))
4243
call syntastic#log#error("checker python/pylint: can't parse version string (abnormal termination?)")
4344
let s:pylint_new = -1
4445
endtry

syntax_checkers/typescript/tsc.vim

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"File: tsc.vim
33
"Description: TypeScript syntax checker
44
"Maintainer: Bill Casarin <[email protected]>
5+
"
56
"============================================================================
67

78
if exists('g:loaded_syntastic_typescript_tsc_checker')
@@ -16,24 +17,24 @@ endif
1617
let s:save_cpo = &cpo
1718
set cpo&vim
1819

19-
function! SyntaxCheckers_typescript_tsc_GetLocList() dict
20-
if !exists('s:tsc_new')
20+
function! SyntaxCheckers_typescript_tsc_IsAvailable() dict
21+
let version_output = split(syntastic#util#system(self.getExecEscaped() . ' --version'), '\n', 1)
22+
let ver = filter(copy(version_output), 'v:val =~# ''\m\<Version ''')
23+
let parsed_ver = len(ver) ? syntastic#util#parseVersion(ver[0], '\v<Version \zs\d+(\.\d+)\ze') : []
24+
25+
if len(parsed_ver)
26+
call self.setVersion(parsed_ver)
27+
let s:tsc_new = syntastic#util#versionIsAtLeast(parsed_ver, [1, 5])
28+
else
29+
call syntastic#log#ndebug(g:_SYNTASTIC_DEBUG_LOCLIST, 'checker output:', version_output)
30+
call syntastic#log#error("checker typescript/tsc: can't parse version string (abnormal termination?)")
2131
let s:tsc_new = -1
22-
try
23-
let tsc_version = filter(split(syntastic#util#system(self.getExecEscaped() . ' --version'), '\n'), 'v:val =~# ''\m\<Version ''')[0]
24-
let ver = syntastic#util#parseVersion(tsc_version, '\v<Version \zs\d+(\.\d+)\ze')
25-
call self.setVersion(ver)
26-
27-
let s:tsc_new = syntastic#util#versionIsAtLeast(ver, [1, 5])
28-
catch /\m^Vim\%((\a\+)\)\=:E684/
29-
call syntastic#log#error("checker typescript/tsc: can't parse version string (abnormal termination?)")
30-
endtry
3132
endif
3233

33-
if s:tsc_new < 0
34-
return []
35-
endif
34+
return s:tsc_new >= 0
35+
endfunction
3636

37+
function! SyntaxCheckers_typescript_tsc_GetLocList() dict
3738
let makeprg = self.makeprgBuild({
3839
\ 'args': '--module commonjs',
3940
\ 'args_after': (s:tsc_new ? '--noEmit' : '--out ' . syntastic#util#DevNull()) })

0 commit comments

Comments
 (0)