LspGotoDefinition on filename opens file in a horizontal split
When I use LspGotoDefinition on a filename under the cursor,
the file is opened on a horizontal split.
Can I configure it to never do that?
I found a workaround (also includes :tag command in case Lsp fails)
function! Gototo() abort
let l:cur_win = win_getid()
let l:pos = getcurpos()
silent! LspGotoDefinition
if getcurpos() ==# l:pos
let l:word = expand('<cword>')
let l:word_escaped = escape(l:word, '\')
execute 'tag ' . l:word_escaped
return
endif
let l:new_win = win_getid()
if l:new_win != l:cur_win
let l:buf = expand('%:p')
close
execute 'edit' l:buf
endif
endfunction
nnoremap <C-]> :call Gototo()<CR>
Shouldn't :help 'switchbuf' define this behavior?
I've tried set switchbuf= but the result was the same.
I am not able to reproduce this issue. When I try to open a file using the :LspGotoDefinition command, it opens the file in the current window (if the current window is not modified or a special buffer). Can you describe the sequence of steps to reproduce this issue? Is the buffer in the current window modified? Do you have the hidden option set? Are you specifying any command modifiers to the :LspGotoDefinition command?
Yes, I have the hidden option set.
But I have been messing around with my vimrc and now I can't reproduce the problem.