Vim has a switchbuf option to allow me open a new file in a split or tabpage.
if switchbuf has been set to useopen,usetab,newtab, when I selected an compiling error in the quickfix window, vim will check if the file has been open , if so , switch to the tabpage/window belongs to the file; if not, create a new tabpage for the file.
Vim will not just switch away my current file if I use <c-w>] instead of <c-]>, it will open a new split to display the definition.
When I use quickfix window or ctags in vim, vim allows me to choose what I want, switch away current file ? or just open in a new split/tabpage.
I don't like my current file to be switched away, and I hate the hidden option too.
Can LanguageClient give me the right of choice too ? May I use LanguageClient without breaking my work-flow ??
Sometimes, I just want to preview the definition and keep my current document, can I open it in the preview window ??
Maybe the best way is leaving me an argument in the function, like:
LanguageClient#textDocument_definition(open_command)
and can be used like:
call LanguageClient#textDocument_definition("e")
call LanguageClient#textDocument_definition("split")
call LanguageClient#textDocument_definition("vs")
call LanguageClient#textDocument_definition("tabedit")
call LanguageClient#textDocument_definition("preview")
call LanguageClient#textDocument_definition("MyOwnBufferSwitchingCommand")
Or, just follow switchbuf option, imitate vim's behavor ?
Check the function implementation. It should already been supported.
On Sun, Apr 22, 2018 at 23:43 Linwei notifications@github.com wrote:
Sometimes, I just want to preview the definition and keep my current
document, can I open it in the preview window ??Maybe the best way is leaving me an argument in the function, like:
LanguageClient#textDocument_definition(open_command)
and can be used like:
call LanguageClient#textDocument_definition("e")call LanguageClient#textDocument_definition("split")call LanguageClient#textDocument_definition("vs")call LanguageClient#textDocument_definition("tabedit")call LanguageClient#textDocument_definition("preview")call LanguageClient#textDocument_definition("MyOwnBufferSwitchingCommand")
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/autozimu/LanguageClient-neovim/issues/395#issuecomment-383470854,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABYt73-9cpANIVvS99uwzKH_pv5sT1moks5trXf4gaJpZM4TfUQx
.
I can't find it in the code or in the documentation, could you explain a little ??
I can't find any clue in the source, any hint ?
You could override default gotoCmd, using
:call LanguageClient#textDocument_definition({
\ 'gotoCmd': 'split',
\ })
Good to know the option switchbuf. I believe this plugin should respect this setting as well.
@autozimu any progress about the switchbuf option ?
gotoCmd does not work when multiple targets exist and selecting by fzf. How do one use customized command to open the target file in such case? @autozimu
@ipod825 I'm using
nnoremap <buffer> <silent> gD <c-w>v:call LanguageClient#textDocument_definition()<CR>
So first splitting, then going to the definition. Is a new option really necessary?
My customized command first check if the destination path is already open in a existing tabpage. If it does, jump to that tabpage. If not, record the current position in a stack, then open the target path in a new tabpage. Such operation is not possible without a new option.
FYI, here's the plugin that I use to achieve this.
@ipod825 I'm using
nnoremap <buffer> <silent> gD <c-w>v:call LanguageClient#textDocument_definition()<CR>So first splitting, then going to the definition. Is a new option really necessary?
I think this is the proper way to achieve this. I don't think switchbuf should have any effect in this case? From what I've seen it should have an effect on quickfix commands and it already does that in the way that if you have diagnostics in your quickfix and select one of those diagnostics it will open in whatever way you have set in switchbuf.
As what I believe a proper solution has been already provided I'm closing this issue, but feel free to re-open if you feel like there's a better way to do this or are not satisfied with that answer.
Most helpful comment
Sometimes, I just want to preview the definition and keep my current document, can I open it in the preview window ??
Maybe the best way is leaving me an argument in the function, like:
and can be used like:
Or, just follow
switchbufoption, imitate vim's behavor ?