How do I override gf with vim-rails

十年热恋 提交于 2019-12-24 01:41:25

问题


I've written a Vimscript function - CoffeeScriptIncludeExpr - that when assigned to includeexpr, allows me to use gf to open a CoffeeScript file when the cursor is on its classname.

However, this doesn't work in a Rails project. My vimrc contains the following

autocmd User Rails.javascript.coffee* set includeexpr=CoffeeScriptIncludeExpr()
autocmd User Rails.javascript.coffee* set path=app/assets/javascripts/**

which I had hoped would have the desired effect.

If I type gf in a CoffeeScript file with the cursor on FooBar, vim prints an error message stating Can't find file 'foo_bar.rb' in path. Puzzlingly, typing set includexpr? shows it's set to CoffeeScriptIncludeExpr. Similarly for set path?. But the error message suggests vim-rails is running the show.

What do I need to do to get gf to work with my CoffeeScript files?


回答1:


It looks like vim-rails overrides the gf command; find out with :verbose nmap gf.

To undo this, remove the mapping with:

:autocmd User Rails.javascript.coffee* nunmap <buffer> gf


来源:https://stackoverflow.com/questions/15430440/how-do-i-override-gf-with-vim-rails

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!