autoload/lsp/symbol.vim | 12 ++++++++---- doc/lsp.txt | 17 ++++++++++------- diff --git a/autoload/lsp/symbol.vim b/autoload/lsp/symbol.vim index 66b1ea5e3520e0e4c9befb310041b1556b3f05ad..f61d65065eed38f00a9cb45e6eddf8340e4192d4 100644 --- a/autoload/lsp/symbol.vim +++ b/autoload/lsp/symbol.vim @@ -264,15 +264,19 @@ wid->win_gotoid() else var bnr: number = fname->bufnr() if bnr != -1 - if &modified || &buftype != '' + # Reuse an existing buffer. If the current buffer has unsaved changes + # and 'hidden' is not set or if the current buffer is a special + # buffer, then open the buffer in a new window. + if (&modified && !&hidden) || &buftype != '' exe 'sbuffer ' .. bnr else exe 'buf ' .. bnr endif else - if &modified || &buftype != '' - # if the current buffer has unsaved changes, then open the file in a - # new window + if (&modified && !&hidden) || &buftype != '' + # if the current buffer has unsaved changes and 'hidden' is not set, + # or if the current buffer is a special buffer, then open the file + # in a new window exe 'split ' .. fname else exe 'edit ' .. fname diff --git a/doc/lsp.txt b/doc/lsp.txt index f463686d4d96370396b7814360f5d847dfae87b2..93ed7ccc3996c26b0f2d04ae7d74230807a535bd 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -2,7 +2,7 @@ *lsp.txt* Language Server Protocol (LSP) Plugin for Vim9 Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com) For Vim version 8.2.2342 and above -Last change: Feb 17, 2022 +Last change: Mar 8, 2022 ============================================================================== *lsp-license* @@ -244,12 +244,15 @@ path to the LSP server executable. *:LspGotoDefinition* :LspGotoDefinition Jumps to the definition of the symbol under the - cursor. If the file is already present in a window, - then jumps to that window. Otherwise, opens the file - in a new window. If the jump is successful, then the - current cursor location is pushed onto the tag stack. - Also the |``| mark is set to the position before the - jump. + cursor. If the file is already present in a window, + then jumps to that window. Otherwise, opens the file + in a new window. If the current buffer is modified + and 'hidden' is not set or if the current buffer is a + special buffer, then a new window is opened. If the + jump is successful, then the current cursor location + is pushed onto the tag stack. The |CTRL-T| command + can be used to go back up the tag stack. Also the + |``| mark is set to the position before the jump. *:LspGotoDeclaration* :LspGotoDeclaration Jumps to the declaration of the symbol under the