Safety checks for ghc-mod.
This commit is contained in:
commit
a0f59e7242
@ -15,8 +15,18 @@ if exists('g:loaded_syntastic_haskell_ghc_mod_checker')
|
||||
endif
|
||||
let g:loaded_syntastic_haskell_ghc_mod_checker = 1
|
||||
|
||||
let s:ghc_mod_new = -1
|
||||
|
||||
function! SyntaxCheckers_haskell_ghc_mod_IsAvailable() dict
|
||||
" We need either a Vim version that can handle NULs in system() output,
|
||||
" or a ghc-mod version that has the --boundary option.
|
||||
let s:ghc_mod_new = executable(self.getExec()) ? s:GhcModNew(self.getExec()) : -1
|
||||
return (s:ghc_mod_new >= 0) && (v:version >= 704 || s:ghc_mod_new)
|
||||
endfunction
|
||||
|
||||
function! SyntaxCheckers_haskell_ghc_mod_GetLocList() dict
|
||||
let makeprg = self.makeprgBuild({ 'exe': self.getExec() . ' check' })
|
||||
let makeprg = self.makeprgBuild({
|
||||
\ 'exe': self.getExec() . ' check' . (s:ghc_mod_new ? ' --boundary=""' : '') })
|
||||
|
||||
let errorformat =
|
||||
\ '%-G%\s%#,' .
|
||||
@ -34,6 +44,17 @@ function! SyntaxCheckers_haskell_ghc_mod_GetLocList() dict
|
||||
\ 'postprocess': ['compressWhitespace'] })
|
||||
endfunction
|
||||
|
||||
function! s:GhcModNew(exe)
|
||||
try
|
||||
let ghc_mod_version = filter(split(system(a:exe), '\n'), 'v:val =~# ''\m^ghc-mod version''')[0]
|
||||
let ret = syntastic#util#versionIsAtLeast(syntastic#util#parseVersion(ghc_mod_version), [2, 1, 2])
|
||||
catch /^Vim\%((\a\+)\)\=:E684/
|
||||
call syntastic#util#error("checker haskell/ghc_mod: can't parse version string (abnormal termination?)")
|
||||
let ret = -1
|
||||
endtry
|
||||
return ret
|
||||
endfunction
|
||||
|
||||
call g:SyntasticRegistry.CreateAndRegisterChecker({
|
||||
\ 'filetype': 'haskell',
|
||||
\ 'name': 'ghc_mod',
|
||||
|
Loading…
x
Reference in New Issue
Block a user