endif
enddef
-# process the 'textDocument/references' reply from the LSP server
-# Result: Location[] | null
-def ProcessReferencesReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
- if reply.result->empty()
- util.WarnMsg('Error: No references found')
- lspserver.peekSymbol = false
- return
- endif
-
- symbol.ShowReferences(lspserver, reply.result)
-enddef
-
# process the 'textDocument/documentHighlight' reply from the LSP server
# Result: DocumentHighlight[] | null
def ProcessDocHighlightReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
'textDocument/signatureHelp': ProcessSignaturehelpReply,
'textDocument/completion': ProcessCompletionReply,
'textDocument/hover': ProcessHoverReply,
- 'textDocument/references': ProcessReferencesReply,
'textDocument/documentHighlight': ProcessDocHighlightReply,
'textDocument/documentSymbol': ProcessDocSymbolReply,
'textDocument/codeAction': ProcessCodeActionReply,
return
endif
- var req = lspserver.createRequest('textDocument/references')
# interface ReferenceParams
# interface TextDocumentPositionParams
- req.params->extend(GetLspTextDocPosition())
- req.params->extend({context: {includeDeclaration: true}})
+ var param: dict<any>
+ param = GetLspTextDocPosition()
+ param.context = {includeDeclaration: true}
+ var reply = lspserver.rpc('textDocument/references', param)
- lspserver.peekSymbol = peek
- lspserver.sendMessage(req)
- if exists('g:LSPTest') && g:LSPTest
- # When running LSP tests, make this a synchronous call
- lspserver.waitForResponse(req)
+ # Result: Location[] | null
+ if reply->empty()
+ return
endif
+
+ if reply.result->empty()
+ util.WarnMsg('Error: No references found')
+ return
+ endif
+
+ symbol.ShowReferences(lspserver, reply.result, peek)
enddef
# Request: "textDocument/documentHighlight"
diagsMap: {},
workspaceSymbolPopup: 0,
workspaceSymbolQuery: '',
- peekSymbol: false,
callHierarchyType: '',
selection: {}
}
enddef
# Display or peek symbol references in a location list
-export def ShowReferences(lspserver: dict<any>, refs: list<dict<any>>)
+export def ShowReferences(lspserver: dict<any>, refs: list<dict<any>>, peekSymbol: bool)
if refs->empty()
util.WarnMsg('Error: No references found')
- lspserver.peekSymbol = false
return
endif
endfor
var save_winid = win_getid()
- if lspserver.peekSymbol
+ if peekSymbol
silent! pedit
wincmd P
endif
setloclist(0, [], ' ', {title: 'Symbol Reference', items: qflist})
var mods: string = ''
- if lspserver.peekSymbol
+ if peekSymbol
# When peeking the references, open the location list in a vertically
# split window to the right and make the location list window 30% of the
# source window width
if !opt.lspOptions.keepFocusInReferences
save_winid->win_gotoid()
endif
- lspserver.peekSymbol = false
enddef
# Jump to the definition, declaration or implementation of a symbol.