Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vim plugin open definition in a split not buffer #248

Closed
wants to merge 1 commit into from

Conversation

bengesoff
Copy link

Seems nicer for me? Opens a vertical split instead of a new buffer for the definition after 'gd'

Seems nicer for me? Opens a vertical split instead of a new buffer for the definition after 'gd'
@phildawes
Copy link
Collaborator

Hi @bengesoff,
Thanks for the patch! I don't really use the vim plugin so I don't know if this is a desired feature or not. In emacs I prefer to jump the whole frame.
Could a regular vim user chime in here please?

-Phil

@tafia
Copy link
Contributor

tafia commented May 23, 2015

I think could be a nice feature. Would it be possible to have both ? gd
and some other command ?
On 23 May 2015 14:50, "Phil Dawes" [email protected] wrote:

Hi @bengesoff https://github.com/bengesoff,
Thanks for the patch! I don't really use the vim plugin so I don't know if
this is a desired feature or not. In emacs I prefer to jump the whole frame.
Could a regular vim user chime in here please?

-Phil


Reply to this email directly or view it on GitHub
#248 (comment).

@ches
Copy link

ches commented May 30, 2015

The behavior of Vim's standard gd function which the mapping in Racer's plugin shadows does not open a split, so I think changing the behavior in the way it's done in this patch is undesirable, replacing the current buffer is expected.

This can be achieved though by adding your own mappings. This works for a vertical split:

nnoremap <buffer> gd :vsplit<CR> :call RacerGoToDefinition()<CR>

Do that via an autocmd FileType rust or in ~/.vim/after/ftplugin/rust.vim.

Personally I'm a fan of using the preview window which doesn't take my cursor out of the original file and can be dismissed consistently from anywhere with <C-w>z. For various filetypes with a specialized semantic go-to-definition plugin like Racer, I follow a convention of using <LocalLeader> and then mimicking standard Vim mappings for ctags jumping, e.g. :h CTRL-W_]:

nnoremap <buffer> <LocalLeader><C-w>] :split<CR> :call RacerGoToDefinition()<CR>

" No native Vim equivalents of these:
nnoremap <buffer> <LocalLeader><C-v>] :vsplit<CR> :call RacerGoToDefinition()<CR>
nnoremap <buffer> <LocalLeader><C-t>] :tab split<CR> :call RacerGoToDefinition()<CR>

Preview window equivalents (e.g. <C-W>}) are unfortunately more of a hassle because Vim has a bug with losing cursor position sometimes with the series of commands you'd naturally use to :pedit then move back to the original window. If you're determined to get them working, check how I've used `m`` in a wrapper function on this vim-erlang-tags patch.

If there's general interest I can send a PR for the Racer README showing a few suggested mappings that follow native analogs. I don't think actually adding them to the plugin proper is a good idea, because a prefix like <LocalLeader> is opinionated (though sensible for <LocalLeader>'s intent) and some people would likely not want un-prefixed ctags mappings overridden.

@phildawes
Copy link
Collaborator

Thanks @ches, this is excellent information. A README PR would be most welcome.
I'm a vim n00b and this project gets a lot of questions and issues about the vim plugin. Better documentation would go a long way to reducing that

@phildawes phildawes closed this May 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants