开发者

With rails.vim, why don't commands work when the active buffer is empty or not a file that's part of a rails project?

If I don't have a file open from the rails project I'm working on, I can't use any rails.vim commands such as :Rcontroller, :Rmodel, :Rview (I get the error: Not an editor command).开发者_如何学Python

Additionally, if i try to use :Rconfig or :Rroutes when I don't have a rails file open, I get the error: Not an editor command: :Rfind application.yml.

I'm using a pre-fab vim config so I am guessing I need to hunt down an issue in there? Or is this just the way rails.vim is meant to work?


The short answer is that this is the way rails.vim works.

rails.vim tries to detect the Rails project using the path of the current buffer. In general this makes sense because a number of the commands provided by rails.vim are specific to the current file. Also, it is very possible to open files from several Rails projects in the same Vim session, so even commands that only reference the project as a whole need to be tied to the current context.

It would be nice if the project-level commands like you describe could be available when you're in a new buffer by falling back to getcwd() and detect that the current working directory is a Rails application. But from a cursory examination of the source, I think it would require some significant restructuring of the plugin.

I wrote a plugin called Open that opens up a project using NERDTree and project the README as a default view. One of the advantages of this is that by having a file open by default, you can use any of the Rails commands immediately.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜