]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Use sync RPC for SwitchSourceHeader
authorYegappan Lakshmanan <yegappan@yahoo.com>
Sat, 8 Oct 2022 22:26:47 +0000 (15:26 -0700)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Sat, 8 Oct 2022 22:26:47 +0000 (15:26 -0700)
autoload/lsp/handlers.vim
autoload/lsp/lspserver.vim

index 79efc0aeb4213eb8ef03aaa5c471ca98e173f943..f30e14ce04731d8a67f44f76c90d333dfb603759 100644 (file)
@@ -60,23 +60,6 @@ def ProcessShutdownReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>)
   return
 enddef
 
-# process the 'textDocument/switchSourceHeader' reply from the LSP server
-# Clangd specific extension
-# Result: URI | null
-def ProcessSwitchHeaderReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>): 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<any>, req: dict<any>, reply: dict<any>): void
@@ -628,7 +611,6 @@ export def ProcessReply(lspserver: dict<any>, req: dict<any>, reply: dict<any>):
     {
       'initialize': ProcessInitializeReply,
       'shutdown': ProcessShutdownReply,
-      'textDocument/switchSourceHeader': ProcessSwitchHeaderReply,
       'textDocument/signatureHelp': ProcessSignaturehelpReply,
       'textDocument/completion': ProcessCompletionReply,
       'textDocument/hover': ProcessHoverReply,
index dfa48860e6a5c68bc1a1b2d83c0c1425764ee324..3aeba0f73faa7fda4034d46450eb9828e7cc1f85 100644 (file)
@@ -538,11 +538,23 @@ enddef
 # Param: TextDocumentIdentifier
 # Clangd specific extension
 def SwitchSourceHeader(lspserver: dict<any>)
-  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.