autoload/lsp/handlers.vim | 18 ------------------ autoload/lsp/lspserver.vim | 20 ++++++++++++++++---- diff --git a/autoload/lsp/handlers.vim b/autoload/lsp/handlers.vim index 79efc0aeb4213eb8ef03aaa5c471ca98e173f943..f30e14ce04731d8a67f44f76c90d333dfb603759 100644 --- a/autoload/lsp/handlers.vim +++ b/autoload/lsp/handlers.vim @@ -60,23 +60,6 @@ def ProcessShutdownReply(lspserver: dict, req: dict, reply: dict): void return enddef -# process the 'textDocument/switchSourceHeader' reply from the LSP server -# Clangd specific extension -# Result: URI | null -def ProcessSwitchHeaderReply(lspserver: dict, req: dict, reply: dict): void - if reply.result->empty() - return - endif - var fname = util.LspUriToFile(reply.result) - if (&modified && !&hidden) || &buftype != '' - # if the current buffer has unsaved changes and 'hidden' is not set, - # or if the current buffer is a special buffer, then ask to save changes - exe $'confirm edit {fname}' - else - exe $'edit {fname}' - endif -enddef - # process the 'textDocument/signatureHelp' reply from the LSP server # Result: SignatureHelp | null def ProcessSignaturehelpReply(lspserver: dict, req: dict, reply: dict): void @@ -628,7 +611,6 @@ var lsp_reply_handlers: dict = { 'initialize': ProcessInitializeReply, 'shutdown': ProcessShutdownReply, - 'textDocument/switchSourceHeader': ProcessSwitchHeaderReply, 'textDocument/signatureHelp': ProcessSignaturehelpReply, 'textDocument/completion': ProcessCompletionReply, 'textDocument/hover': ProcessHoverReply, diff --git a/autoload/lsp/lspserver.vim b/autoload/lsp/lspserver.vim index dfa48860e6a5c68bc1a1b2d83c0c1425764ee324..3aeba0f73faa7fda4034d46450eb9828e7cc1f85 100644 --- a/autoload/lsp/lspserver.vim +++ b/autoload/lsp/lspserver.vim @@ -538,11 +538,23 @@ # Request: "textDocument/switchSourceHeader" # Param: TextDocumentIdentifier # Clangd specific extension def SwitchSourceHeader(lspserver: dict) - var req = lspserver.createRequest('textDocument/switchSourceHeader') - req.params->extend({uri: util.LspFileToUri(@%)}) - lspserver.sendMessage(req) + var param = {} + param.uri = util.LspFileToUri(@%) + var resp = lspserver.rpc('textDocument/switchSourceHeader', param) + if resp->empty() || resp.result->empty() + return + endif - lspserver.waitForResponse(req) + # process the 'textDocument/switchSourceHeader' reply from the LSP server + # Result: URI | null + var fname = util.LspUriToFile(resp.result) + if (&modified && !&hidden) || &buftype != '' + # if the current buffer has unsaved changes and 'hidden' is not set, + # or if the current buffer is a special buffer, then ask to save changes + exe $'confirm edit {fname}' + else + exe $'edit {fname}' + endif enddef # get symbol signature help.