如何获得语法检查以在/使用 vim 工作? [英] How Do I get a syntax check to work in/with vim?

查看:21
本文介绍了如何获得语法检查以在/使用 vim 工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题已经以一种或另一种形式被问过十几次了,这让我大吃一惊,没有一个人真正解决了如何配置 syntasticjslint 这样它实际上做了它应该做的事情(它的 README 文件完全没用)

This question has been asked, in one form or another, a dozen times here, and it blows my mind how not a single one actually addresses how to configure syntastic or jslint such that it actually does what it is supposed to do (its README file is completely useless)

见这里

任何人都可以提供一些分步说明或此类说明的链接.我尝试安装 jslint 和 spidermonkey,但无处可去.

Can anyone provide some step by step instructions, or a link to such instructions. I tried to install jslint and spidermonkey, and I got nowhere.

我设法让语法检查工作(感谢 romainl).我在此过程中学到的一些东西可能会对遇到类似问题的人有所帮助

I managed to get the syntax check to work (thanks to romainl). A few things I learned along the way that may help anyone with a similar problem

  1. 要构建 Javascript Lint,请查找嵌套在 jsl-xxx/src/中的 README 文件README.html
  2. 构建说明是 gmake -f Makefile.refgmakemake 相同 所以发出命令 sudo ln -s/usr/bin/make/usr/bin/gmake
  3. jsl 现在可以在 jsl-0.3.0/src/Linux_All_DBG.OBJ/jsl 中找到.要使其普遍可用,请执行以下操作:ln -s/whatever/jsl-0.3.0/src/Linux_All_DBG.OBJ/home/ForestGump/bin/jsl.更多信息这里
  4. 要检查 jsl 是否确实有效,请找到一个测试文件(此处) 然后发出命令 jsl -process test.js.它应该列出所有错误.
  5. 要自定义命令行,请将其添加到 vimrc 文件中 set statusline=%{SyntasticStatuslineFlag()}
  1. To build Javascript Lint look for the README file nested in jsl-x.x.x/src/README.html
  2. The build instructions are gmake -f Makefile.ref but gmake is the same thing as make so issue the command sudo ln -s /usr/bin/make /usr/bin/gmake
  3. jsl will now be found in jsl-0.3.0/src/Linux_All_DBG.OBJ/jsl. To make it generally accessible do something like: ln -s /whatever/jsl-0.3.0/src/Linux_All_DBG.OBJ /home/ForestGump/bin/jsl. More information here
  4. To check that jsl actually works find a test file ( here) then issue the command jsl -process test.js. It should list all the errors.
  5. To customize your command line, add this to your vimrc file set statusline=%{SyntasticStatuslineFlag()}

推荐答案

你做了什么?什么有效,什么无效?您是否收到错误消息?

What did you do? What works and what doesn't? Do you get error messages?

这是我所做的:

  1. JavaScript Lint 站点下载了 jsl 源.
  2. 构建 jsl 并将其移动到我的 $PATH 中的某个位置.
  3. 通过对随机 .js 文件运行它来检查它是否有效
  4. Pathogen 包的形式下载并安装 Syntastic.
  5. 输入 :helptags/path/to/syntastic/doc 因为出于某种原因,Pathogen 的自动帮助标签生成对我不起作用.
  6. 阅读 Syntastic 的文档::help syntastic.
  1. Downloaded the jsl sources from the JavaScript Lint site.
  2. Built jsl and moved it somewhere in my $PATH.
  3. Checked if it worked by running it against a random .js file
  4. Downloaded and installed Syntastic as a Pathogen bundle.
  5. Typed :helptags /path/to/syntastic/doc because for some reason Pathogen's automatic help tags generation doesn't work for me.
  6. Read Syntastic's documentation: :help syntastic.

第 1 步到第 5 步花费的时间不超过 3 或 4 分钟,甚至可能更少.

Steps 1 to 5 didn't take more than 3 or 4 minutes, maybe less.

第 6 步是强制性的,无论您尝试使用什么新工具.RTFM.

Step 6 is obligatory, whatever new tool you try. RTFM.

在我的 .vimrc 中除了这 3 行之外我不需要配置任何东西(我相信第三行是多余的):

I didn't have to configure anything beside these 3 lines in my .vimrc (and I believe the third is redundant):

let g:syntastic_auto_loc_list=1
let g:syntastic_disabled_filetypes=['html']
let g:syntastic_enable_signs=1

并通过以下方式自定义我的状态行:

and customizing my statusline a bit with:

%{SyntasticStatuslineFlag()}

编辑

这是我的状态线:

set statusline=%<\ %n:%f\ %m%r%y%{SyntasticStatuslineFlag()}%=line:\ %l\ of\ %L,\ col:\ %c%V,\ win:\ %{WindowNumber()}\ 

不要逐字复制,否则会因最后的函数调用而出现一些错误.在 Syntastic 的帮助中有一段关于此的内容.

Don't copy it verbatim or you'll get some errors due to the function call at the end. There is a paragraph about that in syntastic's help.

结束编辑

毕竟,如果算上阅读文档需要 10 或 12 分钟,我有一个非常有用的位置列表,每次我保存一个有语法错误的 .js 文件时都会弹出标志.

After all that, 10 or 12 minutes if you count reading the documentation, I have a very helpful location list and signs poping up each time I save a .js file with syntax errors.

这篇关于如何获得语法检查以在/使用 vim 工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆