]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
When jumping to a LSP location, retrieve the file name from the location itself
authorYegappan Lakshmanan <yegappan@yahoo.com>
Sun, 20 Nov 2022 17:31:13 +0000 (09:31 -0800)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Sun, 20 Nov 2022 17:31:13 +0000 (09:31 -0800)
autoload/lsp/symbol.vim
autoload/lsp/typehierarchy.vim
autoload/lsp/util.vim
doc/lsp.txt

index 17db79404afe1d57d883e9fd3f30e3d7634ab969..41d0b4dc0136ab9bd7f613fbcb5d064b8ff08cc7 100644 (file)
@@ -267,9 +267,10 @@ export def ShowReferences(lspserver: dict<any>, refs: list<dict<any>>, peekSymbo
   endif
 enddef
 
-# Display the symbol in file 'fname' at 'location' in a popup window.
-def PeekSymbolLocation(lspserver: dict<any>, fname: string,
-                      location: dict<any>)
+# Display the file specified by LSP 'location' in a popup window and highlight
+# the range in 'location'.
+def PeekSymbolLocation(lspserver: dict<any>, location: dict<any>)
+  var fname = util.LspUriToFile(location.uri)
   var bnum = fname->bufadd()
   if bnum == 0
     # Failed to create or find a buffer
@@ -314,13 +315,12 @@ enddef
 # symbol.
 export def GotoSymbol(lspserver: dict<any>, location: dict<any>,
                      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
 
index ee5d72e88c6f0c2df05e8c446ddf048bdc944f20..faedaae5832f32e97482d0864cb2851daa60e688 100644 (file)
@@ -129,11 +129,9 @@ def TypeHierPopupCallback(lspserver: dict<any>, typeUriMap: list<dict<any>>,
     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
index 1af97b9bae03329b5c81653c80bcca1db20797f9..a3d72db60bb984d2176a0846b9787093b1704a8d 100644 (file)
@@ -150,10 +150,12 @@ export def PushCursorToTagStack()
                         }]}, '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<any>,
-                            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<any>, cmdmods: string)
+  var fname = LspUriToFile(location.uri)
+
   # jump to the file and line containing the symbol
   if cmdmods == ''
     var bnr: number = fname->bufnr()
index c5678369d58a74f67923c22b0673c349c22de6ee..635f485ad56f0665604d69e3076b3db49d062d04 100644 (file)
@@ -545,9 +545,16 @@ To get a particular option value you can use the following: >
                                                *: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