Skip to content

Commit a13a652

Browse files
filbrandentpope
authored andcommitted
Make gf mapping work with SpaceVim
SpaceVim includes a `nnoremap gf gf`, in order to clobber a mapping it installs for the `g` prefix, which displays a "guide" for the commands starting with `g`. (They do the same for the mappings with the `z` prefix.) https://github.com/SpaceVim/SpaceVim/blob/v1.4.0/autoload/SpaceVim/mapping/g.vim#L98 This ends up preventing vim-rails from installing a `gf` mapping of itself, since it uses a mapcheck() to only install a mapping when either none exists or a mapping it knowingly wants to override is present. But the mapping to itself from SpaceVim prevents that check from succeeding, which in turn prevents vim-rails from installing its own `gf` mapping. This affects `gf`, but not `<C-W>f` or `<C-W>gf` which work as expected. In order to work around this problem, update the pattern used by the mapcheck() checking for the `gf` mapping to also succeed when the mapped expression matches `gf` exactly. Tested on `Pos*t.first`, confirmed that it works same as `<C-W>f` would work. Also checked output of `:map gf` on SpaceVim with vim-rails, which matches the expected: n gf @<SNR>183_:find <Plug><cfile><CR> n gf * gf n g [G]
1 parent 184d12e commit a13a652

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

autoload/rails.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4825,7 +4825,7 @@ call s:add_methods('app', ['internal_load_path'])
48254825
nnoremap <SID>: :<C-U><C-R>=v:count ? v:count : ''<CR>
48264826
function! s:map_gf() abort
48274827
let pattern = '^$\|_gf(v:count\|[Rr]uby\|[Rr]ails'
4828-
if mapcheck('gf', 'n') =~# pattern
4828+
if mapcheck('gf', 'n') =~# pattern.'\|^gf$'
48294829
nmap <buffer><silent> gf <SID>:find <Plug><cfile><CR>
48304830
let b:undo_ftplugin .= "|sil! exe 'nunmap <buffer> gf'"
48314831
endif

0 commit comments

Comments
 (0)