def s:processDefDeclReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
if reply.result->empty()
util.WarnMsg("Error: definition is not found")
- if !lspserver.peekDefDecl
+ if !lspserver.peekDefDeclRef
# pop the tag stack
var tagstack: dict<any> = gettagstack()
if tagstack.length > 0
settagstack(winnr(), {curidx: tagstack.length}, 't')
endif
endif
- lspserver.peekDefDecl = false
+ lspserver.peekDefDeclRef = false
return
endif
location = reply.result
endif
var fname = util.LspUriToFile(location.uri)
- if lspserver.peekDefDecl
+ if lspserver.peekDefDeclRef
# open the definition/declaration in the preview window and highlight the
# matching symbol
exe 'pedit ' .. fname
location.range.start.character + 1)
endif
redraw!
- lspserver.peekDefDecl = false
+ lspserver.peekDefDeclRef = false
enddef
# process the 'textDocument/signatureHelp' reply from the LSP server
def s:processReferencesReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): void
if reply.result->empty()
util.WarnMsg('Error: No references found')
+ lspserver.peekDefDeclRef = false
return
endif
col: util.GetLineByteFromPos(bnr, loc.range.start) + 1,
text: text})
endfor
- setloclist(0, [], ' ', {title: 'Symbol Reference', items: qflist})
+
var save_winid = win_getid()
- :lopen
+ if lspserver.peekDefDeclRef
+ silent! pedit
+ wincmd P
+ endif
+ setloclist(0, [], ' ', {title: 'Symbol Reference', items: qflist})
+ :belowright vert lopen
+ :30wincmd |
save_winid->win_gotoid()
+ lspserver.peekDefDeclRef = false
enddef
# process the 'textDocument/documentHighlight' reply from the LSP server
enddef
# show symbol references
-def lsp#showReferences()
+def lsp#showReferences(peek: bool)
var ftype = &filetype
if ftype == ''
return
return
endif
- lspserver.showReferences()
+ lspserver.showReferences(peek)
enddef
# highlight all the places where a symbol is referenced
if !peek
util.PushCursorToTagStack()
endif
- lspserver.peekDefDecl = peek
+ lspserver.peekDefDeclRef = peek
var req = lspserver.createRequest('textDocument/definition')
# interface DefinitionParams
# interface TextDocumentPositionParams
if !peek
util.PushCursorToTagStack()
endif
- lspserver.peekDefDecl = peek
+ lspserver.peekDefDeclRef = peek
var req = lspserver.createRequest('textDocument/declaration')
# interface DeclarationParams
if !peek
util.PushCursorToTagStack()
endif
- lspserver.peekDefDecl = peek
+ lspserver.peekDefDeclRef = peek
var req = lspserver.createRequest('textDocument/typeDefinition')
# interface TypeDefinitionParams
if !peek
util.PushCursorToTagStack()
endif
- lspserver.peekDefDecl = peek
+ lspserver.peekDefDeclRef = peek
var req = lspserver.createRequest('textDocument/implementation')
# interface ImplementationParams
# Request: "textDocument/references"
# Param: ReferenceParams
-def s:showReferences(lspserver: dict<any>): void
+def s:showReferences(lspserver: dict<any>, peek: bool): void
# Check whether LSP server supports getting reference information
if !lspserver.caps->has_key('referencesProvider')
|| !lspserver.caps.referencesProvider
req.params->extend(s:getLspTextDocPosition())
req.params->extend({context: {includeDeclaration: true}})
+ lspserver.peekDefDeclRef = peek
lspserver.sendMessage(req)
enddef
diagsMap: {},
workspaceSymbolPopup: 0,
workspaceSymbolQuery: '',
- peekDefDecl: false
+ peekDefDeclRef: false
}
# Add the LSP server functions
lspserver->extend({
:LspDiagCurrent Display the diagnostic message for the current line.
:LspShowReferences Display the list of references to the keyword under
cursor in a new location list.
+:LspPeekReferences Display the list of references to the keyword under
+ cursor in a location list associated with the preview
+ window.
:LspHighlight Highlight all the matches for the keyword under cursor
:LspHighlightClear Clear all the matches highlighted by :LspHighlight
:LspOutline Show the list of symbols defined in the current file
where the symbol under the cursor is referenced and
opens the location window.
+ *:LspPeekReferences*
+:LspPeekReferences Opens the preview window and creates a new location
+ list with the list of locations where the symbol under
+ the cursor is referenced and opens the location window.
+
*:LspHighlight*
:LspHighlight Highlights all the matches for the symbol under
cursor. The text, read and write references to the
command! -nargs=0 -bar LspDiagFirst call lsp#jumpToDiag('first')
command! -nargs=0 -bar LspDiagNext call lsp#jumpToDiag('next')
command! -nargs=0 -bar LspDiagPrev call lsp#jumpToDiag('prev')
-command! -nargs=0 -bar LspShowReferences call lsp#showReferences()
+command! -nargs=0 -bar LspShowReferences call lsp#showReferences(v:false)
+command! -nargs=0 -bar LspPeekReferences call lsp#showReferences(v:true)
command! -nargs=0 -bar LspHighlight call lsp#docHighlight()
command! -nargs=0 -bar LspHighlightClear call lsp#docHighlightClear()
command! -nargs=0 -bar LspOutline call lsp#outline()
anoremenu <silent> L&sp.Goto.TypeDef :call lsp#gotoTypedef(v:false)<CR>
anoremenu <silent> L&sp.Show\ Signature :call lsp#showSignature()<CR>
- anoremenu <silent> L&sp.Show\ References :call lsp#showReferences()<CR>
+ anoremenu <silent> L&sp.Show\ References :call lsp#showReferences(v:false)<CR>
anoremenu <silent> L&sp.Show\ Detail :call lsp#hover()<CR>
anoremenu <silent> L&sp.Outline :call lsp#outline()<CR>
anoremenu <silent> PopUp.L&sp.Go\ to\ Declaration
\ :call lsp#gotoDeclaration(v:false)<CR>
anoremenu <silent> Popup.L&sp.Find\ All\ References
- \ :call lsp#showReferences()<CR>
+ \ :call lsp#showReferences(v:false)<CR>
anoremenu <silent> PopUp.L&sp.Show\ Detail
\ :call lsp#hover()<CR>
anoremenu <silent> PopUp.L&sp.Highlight\ Symbol