vim-rails implements the
gf key-binding by adding a mapping for it.
But it will only add a mapping for
gf if it detects it wasn't mapped before, or if a previous mapping for
gf matches a regex including
Rails (presumably because it's overriding known mappings from other related plug-ins by tpope such as vim-ruby or projectionist.)
The code snippet is:
let pattern = '^$\|_gf(v:count\|[Rr]uby\|[Rr]ails'
if mapcheck('gf', 'n') =~# pattern
nmap <buffer><silent> gf <SID>:find <Plug><cfile><CR>
On the other hand, SpaceVim defines a mapping for
nnoremap gf gf
It's an odd mapping that just maps it to itself... (Not sure why SpaceVim wants such a mapping, since it doesn't seem to do anything, just maps the command to itself. I just posted a follow up question about these odd mappings.)
If it was installed, the
gf mapping from vim-rails would supercede the mapping from SpaceVim.
But since vim-rails checks first, it finds the mapping from SpaceVim, which doesn't match its regex of expected mappings to override, it never really installs its
gf key-binding, which causes the problem as reported here.
(Simply dropping the
nnoremap gf gf is not enough, since the used
mapcheck() will match prefixes and SpaceVim also creates a mapping for
g by itself, so that mapping breaks the checks as well.)
Even though this issue seems to be triggered by the odd set of mappings created by SpaceVim, perhaps the easiest fix here would be to fix vim-rails to also install its
gf key-binding if it finds the SpaceVim one, simply by adding a straight
^gf$ to the list of mappings to replace in its
UPDATE: I sent out PR #558 to suggest this change to vim-rails. Tested it on SpaceVim and it worked for me as expected.
UPDATE 2: The PR was merged upstream by tpope, so latest vim-rails should now work fine with SpaceVim! 🎉