lspserver.showReferences(peek)
enddef
+# send custom locations request
+def g:LspFindLocations(server_name: string, peek: bool, method: string, args: dict<any> = {})
+ var lspserver: dict<any> = buf.CurbufGetServerByName(server_name)
+ if lspserver->empty()
+ return
+ endif
+ if !lspserver.running
+ util.ErrMsg($'Language server "{server_name}" is not running')
+ return
+ endif
+ if !lspserver.ready
+ util.ErrMsg($'Language server "{server_name}" is not ready')
+ return
+ endif
+
+ lspserver.findLocations(peek, method, args)
+enddef
+
# highlight all the places where a symbol is referenced
def g:LspDocHighlight(bnr: number = bufnr(), cmdmods: string = '')
var lspserver: dict<any> = buf.CurbufGetServerChecked('documentHighlight')
symbol.ShowLocations(lspserver, reply.result, peek, 'Symbol References')
enddef
+# send custom locations request
+def FindLocations(lspserver: dict<any>, peek: bool, method: string, args: dict<any>): void
+ var param: dict<any>
+ param = lspserver.getTextDocPosition(true)->extend(args)
+ var reply = lspserver.rpc(method, param)
+
+ # Result: Location[] | null
+ if reply->empty() || reply.result->empty()
+ util.WarnMsg('No references found')
+ return
+ endif
+
+ if lspserver.needOffsetEncoding
+ # Decode the position encoding in all the reference locations
+ reply.result->map((_, loc) => {
+ lspserver.decodeLocation(loc)
+ return loc
+ })
+ endif
+
+ symbol.ShowLocations(lspserver, reply.result, peek, 'Symbol References')
+enddef
+
# process the 'textDocument/documentHighlight' reply from the LSP server
# Result: DocumentHighlight[] | null
def DocHighlightReply(lspserver: dict<any>, docHighlightReply: any,
didSaveFile: function(DidSaveFile, [lspserver]),
hover: function(ShowHoverInfo, [lspserver]),
showReferences: function(ShowReferences, [lspserver]),
+ findLocations: function(FindLocations, [lspserver]),
docHighlight: function(DocHighlight, [lspserver]),
getDocSymbols: function(GetDocSymbols, [lspserver]),
textDocFormat: function(TextDocFormat, [lspserver]),