tow*_*ane 6 vim jshint syntastic
我已经安装了Syntastic with Pathogen.
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
Run Code Online (Sandbox Code Playgroud)
当我运行:SyntasticInfo时,它没有找到任何检查器.
Syntastic info for filetype: javascript
Available checkers:
Currently active checker(s):
Run Code Online (Sandbox Code Playgroud)
我的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']
Run Code Online (Sandbox Code Playgroud)
如果你知道为什么Syntastic没有检测到JSHint,我不知道我错过了什么.谢谢
Яро*_*лин 21
我在Windows 8上遇到了类似的问题.安装nodejsv0.10.22和syntastic> = 3.2.0后,Vim命令:SyntasticInfo会给我:
Syntastic: active mode enabled
Syntastic info for filetype: vim
Available checker(s):
Currently enabled checker(s):
Run Code Online (Sandbox Code Playgroud)
jshint.com/docs上的文档表明这足以安装模块.
$ npm install jshint -g
Run Code Online (Sandbox Code Playgroud)
这是事实,除了标志的一些令人惊讶的含义-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)
Run Code Online (Sandbox Code Playgroud)
来自语法常见问题解答的另一篇文档如下:
问:我安装了syntastic但它没有报告任何错误......
答:最可能的原因是它没有安装所需的语法检查程序.例如:python需要安装flake8,pyflakes或pylint,并且需要安装在$ PATH中.要查看支持哪些可执行文件,请查看syntax_checkers //*.vim.请注意,别名不起作用; 必须在$ PATH中提供实际的可执行文件.符号链接没问题.您可以通过运行SyntasticInfo来查看syntastic对可用检查器的想法.
解决方案相当于jshint在〜/ .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
Run Code Online (Sandbox Code Playgroud)
或者,人们可以:
> cmd.exe
> cd C:\Users\jaroslav\AppData\Roaming\npm
> setx PATH "%cd%:%PATH%"
Run Code Online (Sandbox Code Playgroud)
和let g:syntastic_jshint_exec='jshint.cmd'.我没有尝试使用%PATH%的最后一个解决方案,因为Winders不喜欢long%PATH%变量.