Frage

I have installed Syntastic with Pathogen.

Syntastic works for Python files but not for JavaScript files with JSHint. JSHint works via command line or with other vim plugin like https://github.com/Shutnik/jshint2.vim

→ which jshint  
/usr/local/share/npm/bin/jshint

→ jshint --version
jshint v2.1.10

→ echo $PATH
/usr/local/share/npm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

When I run :SyntasticInfo, it doesn't find any checkers.

Syntastic info for filetype: javascript
Available checkers:
Currently active checker(s):

My vimrc

set nocompatible
filetype off
call pathogen#infect()
call pathogen#helptags()
filetype plugin indent on
syntax on

let g:syntastic_check_on_open=1
let g:syntastic_javascript_checkers = ['jshint']

I don't know what I've missed, if you have any idea why Syntastic doesn't detect JSHint. Thanks

War es hilfreich?

Lösung

Long story short; Syntastic needs the path of jshint.


I encountered a similar problem on Windows 8. After installing nodejs v0.10.22 and syntastic >= 3.2.0, the Vim command :SyntasticInfo would give me:

Syntastic: active mode enabled
Syntastic info for filetype: vim
Available checker(s): 
Currently enabled checker(s):

The documentation over at jshint.com/docs suggests that this is sufficient to install the module.

$ npm install jshint -g

This is true, apart from a somewhat surprising meaning of flag -g installs JSHint globally on your system. It means in your user's %AppData% folder:

(abbreviated output from previous command)
C:\Users\jaroslav\AppData\Roaming\npm\jshint -> \
C:\Users\jaroslav\AppData\Roaming\npm\node_modules\jshint\bin\jshint
jshint@2.3.0 C:\Users\jaroslav\AppData\Roaming\npm\node_modules\jshint
├── console-browserify@0.1.6
├── underscore@1.4.4
├── shelljs@0.1.4
├── minimatch@0.2.12 (sigmund@1.0.0, lru-cache@2.5.0)
└── cli@0.4.5 (glob@3.2.7)

Another piece of documentation from the syntastic FAQ reads:

Q. I installed syntastic but it isn't reporting any errors...

A. The most likely reason is that none of the syntax checkers that it requires is installed. For example: python requires either flake8, pyflakes or pylint to be installed and in $PATH. To see which executables are supported, just look in syntax_checkers//*.vim. Note that aliases do not work; the actual executable must be available in your $PATH. Symbolic links are okay. You can see syntastic's idea of available checkers by running :SyntasticInfo.

The solution amounts to setting the path of the jshint command in ~/.vimrc:

 let g:syntastic_jshint_exec='C:\Users\jaroslav\AppData\Roaming\npm\jshint.cmd'

:source $HOME/_vimrc
:SyntasticInfo
Syntastic: active mode enabled
Syntastic info for filetype: javascript
Available checker(s): jshint
Currently enabled checker(s): jshint

Alternatively, one could:

> cmd.exe
> cd C:\Users\jaroslav\AppData\Roaming\npm
> setx PATH "%cd%:%PATH%"

and let g:syntastic_jshint_exec='jshint.cmd'. I didn't try the last solution with %PATH% because Winders doesn't like long %PATH% variables.

Hopefully this saves you some time.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top