0

I updated node with homebrew today and that meant that all the npm modules got blown away. This of course means that the jshint executable (e.g. obtained by npm install -g jshint) is no longer present so Syntastic just silently stopped checking syntax in my js files.

It didnt take me too long to notice, but I'd like to be able to know about this change. I'd like syntastic to display something (preferably in red) in the command statusline to the tune of Syntastic - cannot run jshint.

timss
  • 9,982
  • 4
  • 34
  • 56
Steven Lu
  • 41,389
  • 58
  • 210
  • 364

2 Answers2

2

The simplest solution would be to edit the file

syntastic/syntax_checkers/javascript/jshint.vim

And change the function from

function! SyntaxCheckers_javascript_jshint_IsAvailable()
    return executable('jshint')
endfunction

to

function! SyntaxCheckers_javascript_jshint_IsAvailable()
    if executable('jshint') != 1 
        echohl Error
        echo "Syntastic - cannot run jshint" 
        echohl None
    endif
    return executable('jshint')
endfunction

echohl sets the highlight color of echo to the hightlight group Error (which is most likely red but it may not be). Then it prints out the message you want to print when you save. However this is not on the status line.

FDinoff
  • 30,689
  • 5
  • 75
  • 96
  • this is pretty epic but it's not too portable. I just wished syntastic had a log it would write exceptional events (like not finding jshint as one example) to – Steven Lu Jun 02 '13 at 06:35
  • @StevenLu You should ask the developer or maintainer of Syntastic to add this feature. – FDinoff Jun 02 '13 at 18:07
0

It seems Syntastic unfortunately lacks the ability to report missing checkers with the visibility one could expect. Ideally such functionality should be added. For those not up for patching Syntastic, a possible workaround is to turn on debugging, search for strings known to be problematic and alert on them. E.g. by marking the first line with an error sign and bringing up the log in a new buffer. I added that to my .vimrc as shown below.

let g:syntastic_debug = 1

function! SyntasticCheckerNotFound()
  redir => messages
  silent messages
  redir END
  let pos = match(messages, "syntastic.*Checker.*is not available")
  if pos != -1
    new
    setlocal buftype=nofile
    put =messages
    sign place 1 line=1 name=SyntasticError buffer=1
"   goto pos
  endif
  let g:syntastic_debug = 0
endfunction

autocmd VimEnter <buffer> call SyntasticCheckerNotFound()

When running the function above on the VimEnter event, it only executes one time when vim is started and only on the first file provided as an argument. Far from perfect, but it could be good enough to decrease the time and effort required to determine broken linting due to missing checkers.

sampi
  • 576
  • 5
  • 15
  • Neat! I use ALE now (instead of syntastic). Interestingly, the same thing applies: missing checkers don’t get reported – Steven Lu Jul 14 '18 at 14:11