# process the 'workspace/symbol' reply from the LSP server
# Result: SymbolInformation[] | null
def s:processWorkspaceSymbolReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
- if reply.result->empty()
- return
- endif
-
var symbols: list<dict<any>> = []
var symbolType: string
var fileName: string
ErrMsg,
lsp_server_trace,
ClearTraceLogs,
- GetLineByteFromPos} from './util.vim'
+ GetLineByteFromPos,
+ PushCursorToTagStack} from './util.vim'
import {LspDiagsUpdated} from './buf.vim'
# Needs Vim 8.2.2342 and higher
popupID->popup_settext('')
if query != ''
lspserver.workspaceQuery(query)
+ else
+ []->setwinvar(popupID, 'LspSymbolTable')
endif
echo 'Symbol: ' .. query
endif
return
endif
- var symTbl: list<dict<any>> = popupID->getwinvar('LspSymbolTable')
+ var symTbl: list<dict<any>> = popupID->getwinvar('LspSymbolTable', [])
+ if symTbl->empty()
+ return
+ endif
try
+ # Save the current location in the tag stack
+ PushCursorToTagStack()
+
# if the selected file is already present in a window, then jump to it
var fname: string = symTbl[result - 1].file
var winList: list<number> = fname->bufnr()->win_findbuf()
TraceLog,
LspUriToFile,
LspBufnrToUri,
- LspFileToUri} from './util.vim'
+ LspFileToUri,
+ PushCursorToTagStack} from './util.vim'
# LSP server standard output handler
def s:output_cb(lspserver: dict<any>, chan: channel, msg: string): void
lspserver.sendMessage(req)
enddef
-# push the current location on to the tag stack
-def s:pushCursorToTagStack()
- settagstack(winnr(), {items: [
- {
- bufnr: bufnr(),
- from: getpos('.'),
- matchnr: 1,
- tagname: expand('<cword>')
- }]}, 'a')
-enddef
-
# Request: "textDocument/definition"
# Param: DefinitionParams
def s:gotoDefinition(lspserver: dict<any>): void
return
endif
- s:pushCursorToTagStack()
+ PushCursorToTagStack()
var req = lspserver.createRequest('textDocument/definition')
# interface DefinitionParams
# interface TextDocumentPositionParams
return
endif
- s:pushCursorToTagStack()
+ PushCursorToTagStack()
var req = lspserver.createRequest('textDocument/declaration')
# interface DeclarationParams
return
endif
- s:pushCursorToTagStack()
+ PushCursorToTagStack()
var req = lspserver.createRequest('textDocument/typeDefinition')
# interface TypeDefinitionParams
return
endif
- s:pushCursorToTagStack()
+ PushCursorToTagStack()
var req = lspserver.createRequest('textDocument/implementation')
# interface ImplementationParams
return col
enddef
+# push the current location on to the tag stack
+export def PushCursorToTagStack()
+ settagstack(winnr(), {items: [
+ {
+ bufnr: bufnr(),
+ from: getpos('.'),
+ matchnr: 1,
+ tagname: expand('<cword>')
+ }]}, 't')
+enddef
+
# vim: shiftwidth=2 softtabstop=2