I want to implement a VSCode extension that uses the Language Server Protocol , but I want the server component to be on an actual server (in the cloud), and not a part of the VSCode extension.
Can I set the client extension to connect to a server via websockets or HTTP?
I am not sure if you can control the location of the language server, but there is another option. You do not need to implement the Language Server Protocol to, for example, provide parsing help. In that case you can implement your own convenient parsing service API (tailored to the nature of the language you want to support).
workspace.onDidChangeTextDocument
DiagnosticCollection
using https://code.visualstudio.com/api/references/vscode-api#languages.createDiagnosticCollection and replace populate it with the warnings/errors/hints resulting from the parsing server in the cloud.workspace
events, eg workspace.onDidOpenTextDocument
or workspace.onDidCloseTextDocument
in order to keep the DiagnosticCollection
content relevantMultiple ServerOptions are supported when you initialize a LanguageClient
according to the signature of ServerOptions
.
you can use the StreamInfo
if you want to use a real remove server as your language server. Here is a sample code to connect to your server via WebSocket
and initialize a LanguageClient
.
const connection = connectToServer(hostname, path);
const client = new LanguageClient(
"docfxLanguageServer",
"Docfx Language Server",
() => Promise.resolve<StreamInfo>({
reader: connection,
writer: connection,
}),
{});
private connectToServer(hostname: string, path: string): Duplex {
const ws = new WebSocket(`ws://${hostname}/${path}`);
return WebSocket.createWebSocketStream(ws);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.