autoload/lsp/symbol.vim | 12 ++++++------ autoload/lsp/typehierarchy.vim | 4 +--- autoload/lsp/util.vim | 10 ++++++---- doc/lsp.txt | 13 ++++++++++--- diff --git a/autoload/lsp/symbol.vim b/autoload/lsp/symbol.vim index 17db79404afe1d57d883e9fd3f30e3d7634ab969..41d0b4dc0136ab9bd7f613fbcb5d064b8ff08cc7 100644 --- a/autoload/lsp/symbol.vim +++ b/autoload/lsp/symbol.vim @@ -267,9 +267,10 @@ save_winid->win_gotoid() endif enddef -# Display the symbol in file 'fname' at 'location' in a popup window. -def PeekSymbolLocation(lspserver: dict, fname: string, - location: dict) +# Display the file specified by LSP 'location' in a popup window and highlight +# the range in 'location'. +def PeekSymbolLocation(lspserver: dict, location: dict) + var fname = util.LspUriToFile(location.uri) var bnum = fname->bufadd() if bnum == 0 # Failed to create or find a buffer @@ -314,13 +315,12 @@ # Also, used to peek at the definition, declaration or implementation of a # symbol. export def GotoSymbol(lspserver: dict, location: dict, peekSymbol: bool, cmdmods: string) - var fname = util.LspUriToFile(location.uri) if peekSymbol - PeekSymbolLocation(lspserver, fname, location) + PeekSymbolLocation(lspserver, location) else # Save the current cursor location in the tag stack. util.PushCursorToTagStack() - util.JumpToLspLocation(fname, location, cmdmods) + util.JumpToLspLocation(location, cmdmods) endif enddef diff --git a/autoload/lsp/typehierarchy.vim b/autoload/lsp/typehierarchy.vim index ee5d72e88c6f0c2df05e8c446ddf048bdc944f20..faedaae5832f32e97482d0864cb2851daa60e688 100644 --- a/autoload/lsp/typehierarchy.vim +++ b/autoload/lsp/typehierarchy.vim @@ -129,11 +129,9 @@ # popup is canceled return endif - var item = typeUriMap[selIdx - 1] - var fname = util.LspUriToFile(item.uri) # Save the current cursor location in the tag stack. util.PushCursorToTagStack() - util.JumpToLspLocation(fname, item, '') + util.JumpToLspLocation(typeUriMap[selIdx - 1], '') enddef # Show the super or sub type hierarchy items 'types' as a tree in a popup window diff --git a/autoload/lsp/util.vim b/autoload/lsp/util.vim index 1af97b9bae03329b5c81653c80bcca1db20797f9..a3d72db60bb984d2176a0846b9787093b1704a8d 100644 --- a/autoload/lsp/util.vim +++ b/autoload/lsp/util.vim @@ -150,10 +150,12 @@ tagname: expand('') }]}, 't') enddef -# Jump to the LSP 'location' in file 'fname'. The user specified -# window command modifiers (e.g. topleft) are in 'cmdmods'. -export def JumpToLspLocation(fname: string, location: dict, - cmdmods: string) +# Jump to the LSP 'location'. The 'location' contains the file name, line +# number and character number. The user specified window command modifiers +# (e.g. topleft) are in 'cmdmods'. +export def JumpToLspLocation(location: dict, cmdmods: string) + var fname = LspUriToFile(location.uri) + # jump to the file and line containing the symbol if cmdmods == '' var bnr: number = fname->bufnr() diff --git a/doc/lsp.txt b/doc/lsp.txt index c5678369d58a74f67923c22b0673c349c22de6ee..635f485ad56f0665604d69e3076b3db49d062d04 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -545,9 +545,16 @@ *:LspSuperTypeHierarchy* :LspSuperTypeHierarchy Show the super type hierarchy for the symbol under the cursor in a popup window. The file containing the - type is shown in another popup window. You can jump - to the location where a type is defined by browsing the - popup menu and selecting an entry. + type is shown in another popup window. As the current + entry in the type hierarchy popup menu changes, the + file popup window is updated to show the location + where the type is defined. You can jump to the + location where a type is defined by selecting the + entry in the popup menu. + + Note that the type hierarchy support is based on the + protocol supported by clangd. This is different from + the one specified in the 3.17 of the LSP standard. *:LspSubTypeHierarchy* :LspSubTypeHierarchy Show the sub type hierarchy for the symbol under the