为什么我只能在 VIM 的某些项目中获得 RSpec 的语法高亮显示?
在开始一个新项目后不久,我意识到我的 RSpec 文件没有得到正确的语法突出显示。
起初我认为这只是因为我的项目特定的 .vimrc
,它是通过 set exrc
加载的。但即使我删除了它,也没有帮助。
我还认为问题出在规范文件本身,它没有被识别为 RSpec,所以我从另一个项目中获取了一个文件,将其复制过来,但它仍然没有被正确突出显示。
这是在两个不同位置打开的同一个文件。左边的是原始项目,它确实突出显示,右边的是复制的版本。
该项目中的所有 RSpec 文件都会发生同样的情况,但它似乎在其他地方都适用。
这是我的 ~/.vimrc,但我不认为这是任何相关性,因为我以前从未遇到过这个问题,只在这个特定的项目中遇到过。
Soon after starting a new project I realized, that I'm not getting the correct syntax highlighting for my RSpec files.
At first I thought this is just because of my project specific .vimrc
, which are loaded via set exrc
. But even after I deleted it, it didn't help.
I also thought that the problem is in the spec file itself, that it doesn't get recognized as RSpec, so I took a file from another project, copied it over, and it still isn't getting properly highlighted.
This is the same file opened in two different places. The one on the left is in the original project, where it does get highlighting, and the one on the right is the copied version.
The same thing happens for all the RSpec files in that one project, but it seems to work everywhere else.
Here is my ~/.vimrc, but I don't think that's of any relevance, because I never had this issue before, only in this specific project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你使用的是 janus,所以你已经安装了rails.vim。正如您在此处看到的,该插件定义了适合您的语法方法,这就是为什么您仅在 Rails 项目中启用 RSpec 语法的原因。
如果您想在每个规范文件中启用该语法,您可以将以下内容添加到您的 vimrc 中:
You're using janus so you have rails.vim installed. As you can see here, that plugin defines the syntax methods for you and that's the reason why you have the RSpec syntax enabled only in rails projects.
If you want to enable that syntaxt in each spec file you can add the following to your vimrc: