@@ -15,13 +15,18 @@ if exists('g:loaded_syntastic_haskell_ghc_mod_checker')
1515endif
1616let g: loaded_syntastic_haskell_ghc_mod_checker = 1
1717
18+ let s: ghc_mod_new = -1
19+
1820function ! SyntaxCheckers_haskell_ghc_mod_IsAvailable ()
19- return executable (' ghc-mod' )
21+ " We need either a Vim version that can handle NULs in system() output,
22+ " or a ghc-mod version that has the --boundary option.
23+ let s: ghc_mod_new = executable (' ghc-mod' ) ? s: GhcModNew () : -1
24+ return (s: ghc_mod_new >= 0 ) && (v: version >= 704 || s: ghc_mod_new )
2025endfunction
2126
2227function ! SyntaxCheckers_haskell_ghc_mod_GetLocList ()
2328 let makeprg = syntastic#makeprg#build ({
24- \ ' exe' : ' ghc-mod check' ,
29+ \ ' exe' : ' ghc-mod check' . ( s: ghc_mod_new ? ' --boundary="" ' : ' ' ) ,
2530 \ ' filetype' : ' haskell' ,
2631 \ ' subchecker' : ' ghc_mod' })
2732
@@ -41,6 +46,17 @@ function! SyntaxCheckers_haskell_ghc_mod_GetLocList()
4146 \ ' postprocess' : [' compressWhitespace' ] })
4247endfunction
4348
49+ function ! s: GhcModNew ()
50+ try
51+ let ghc_mod_version = filter (split (system (' ghc-mod' ), ' \n' ), ' v:val =~# '' \m^ghc-mod version'' ' )[0 ]
52+ let ret = syntastic#util#versionIsAtLeast (syntastic#util#parseVersion (ghc_mod_version), [2 , 1 , 2 ])
53+ catch /^Vim\%((\a\+)\)\=:E684/
54+ call syntastic#util#error (" checker haskell/ghc_mod: can't parse version string (abnormal termination?)" )
55+ let ret = -1
56+ endtry
57+ return ret
58+ endfunction
59+
4460call g: SyntasticRegistry .CreateAndRegisterChecker ({
4561 \ ' filetype' : ' haskell' ,
4662 \ ' name' : ' ghc_mod' })
0 commit comments