Why do I only get syntax highlighting for RSpec on some projects in VIM?

Shortly after starting a new project, I realized that I was not getting the correct syntax highlighting for my RSpec files.

At first I thought it was only because of my specific .vimrc project, which are loaded via set exrc . But even after I deleted it, it did not help.

I also thought that the problem is in the spec file itself, that it is not recognized as RSpec, so I took the file from another project, copied it and still did not get the highlight properly.

syntax highlighting

This is the same file open in two different places. One of them is in the original project, where it stands out, and on the right is the copied version.

The same thing happens for all RSpec files in this one project, but it seems to work everywhere.

Here is my ~ / .vimrc , but I don’t think it matters, because I have never had this problem before, only in this particular project.

+4
source share
1 answer

You use janus to install rails.vim. As you can see here , this plugin defines syntax methods for you and that RSpec syntax reason is included only in rails projects.

If you want to include this syntaxt in each spec file, you can add the following to your vimrc:

 autocmd BufRead *_spec.rb syn keyword rubyRspec describe context it specify it_should_behave_like before after setup subject its shared_examples_for shared_context let highlight def link rubyRspec Function 
+9
source

Source: https://habr.com/ru/post/1390799/


All Articles