Syntastic适用于Python文件,但不适用于JSHint的JavaScript文件.
JSHint通过命令行或其他vim插件(如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
当我运行:SyntasticInfo时,它没有找到任何检查器.
Syntastic info for filetype: javascript Available checkers: Currently active checker(s):
我的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']
如果你知道为什么Syntastic没有检测到JSHint,我不知道我错过了什么.谢谢
我在Windows 8上遇到了类似的问题.安装nodejs v0.10.22和syntastic> = 3.2.0之后,Vim命令:SyntasticInfo会给我:
Syntastic: active mode enabled Syntastic info for filetype: vim Available checker(s): Currently enabled checker(s):
jshint.com/docs上的文档表明这足以安装模块.
$npm install jshint -g
这是事实,除了标志的一些令人惊讶的含义-g在您的系统上全局安装JSHint.这意味着在您的用户的%AppData%文件夹中:
(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)
syntastic FAQ的另一份文件内容如下:
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.
解决方案相当于在〜/ .vimrc中设置jshint命令的路径:
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
或者,人们可以:
> cmd.exe > cd C:\Users\jaroslav\AppData\Roaming\npm > setx PATH "%cd%:%PATH%"
并且让g:syntastic_jshint_exec =’jshint.cmd’.我没有尝试使用%PATH%的最后一个解决方案,因为Winders不喜欢long%PATH%变量.
希望这可以为您节省一些时间.