加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

vim – Syntastic不会将JSHint检测为可用的检查程序

发布时间:2020-12-16 01:26:55 所属栏目:安全 来源:网络整理
导读:我已经安装了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
我已经安装了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

当我运行: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,我不知道我错过了什么.谢谢

长话短说; 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:UsersjaroslavAppDataRoamingnpmjshint -> 
C:UsersjaroslavAppDataRoamingnpmnode_modulesjshintbinjshint
jshint@2.3.0 C:UsersjaroslavAppDataRoamingnpmnode_modulesjshint
├── 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:UsersjaroslavAppDataRoamingnpmjshint.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:UsersjaroslavAppDataRoamingnpm
> setx PATH "%cd%:%PATH%"

并且让g:syntastic_jshint_exec =’jshint.cmd’.我没有尝试使用%PATH%的最后一个解决方案,因为Winders不喜欢long%PATH%变量.

希望这可以为您节省一些时间.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读