|
@@ -1,5 +1,9 @@
|
|
|
import path from "path"
|
|
import path from "path"
|
|
|
-import { createMessageConnection, StreamMessageReader, StreamMessageWriter } from "vscode-jsonrpc/node"
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ createMessageConnection,
|
|
|
|
|
+ StreamMessageReader,
|
|
|
|
|
+ StreamMessageWriter,
|
|
|
|
|
+} from "vscode-jsonrpc/node"
|
|
|
import type { Diagnostic as VSCodeDiagnostic } from "vscode-languageserver-types"
|
|
import type { Diagnostic as VSCodeDiagnostic } from "vscode-languageserver-types"
|
|
|
import { Log } from "../util/log"
|
|
import { Log } from "../util/log"
|
|
|
import { LANGUAGE_EXTENSIONS } from "./language"
|
|
import { LANGUAGE_EXTENSIONS } from "./language"
|
|
@@ -34,7 +38,11 @@ export namespace LSPClient {
|
|
|
),
|
|
),
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- export async function create(input: { serverID: string; server: LSPServer.Handle; root: string }) {
|
|
|
|
|
|
|
+ export async function create(input: {
|
|
|
|
|
+ serverID: string
|
|
|
|
|
+ server: LSPServer.Handle
|
|
|
|
|
+ root: string
|
|
|
|
|
+ }) {
|
|
|
const l = log.clone().tag("serverID", input.serverID)
|
|
const l = log.clone().tag("serverID", input.serverID)
|
|
|
l.info("starting client")
|
|
l.info("starting client")
|
|
|
|
|
|
|
@@ -62,6 +70,14 @@ export namespace LSPClient {
|
|
|
// Return server initialization options
|
|
// Return server initialization options
|
|
|
return [input.server.initialization ?? {}]
|
|
return [input.server.initialization ?? {}]
|
|
|
})
|
|
})
|
|
|
|
|
+ connection.onRequest("client/registerCapability", async () => {})
|
|
|
|
|
+ connection.onRequest("client/unregisterCapability", async () => {})
|
|
|
|
|
+ connection.onRequest("workspace/workspaceFolders", async () => [
|
|
|
|
|
+ {
|
|
|
|
|
+ name: "workspace",
|
|
|
|
|
+ uri: "file://" + input.root,
|
|
|
|
|
+ },
|
|
|
|
|
+ ])
|
|
|
connection.listen()
|
|
connection.listen()
|
|
|
|
|
|
|
|
l.info("sending initialize")
|
|
l.info("sending initialize")
|
|
@@ -129,7 +145,9 @@ export namespace LSPClient {
|
|
|
},
|
|
},
|
|
|
notify: {
|
|
notify: {
|
|
|
async open(input: { path: string }) {
|
|
async open(input: { path: string }) {
|
|
|
- input.path = path.isAbsolute(input.path) ? input.path : path.resolve(Instance.directory, input.path)
|
|
|
|
|
|
|
+ input.path = path.isAbsolute(input.path)
|
|
|
|
|
+ ? input.path
|
|
|
|
|
+ : path.resolve(Instance.directory, input.path)
|
|
|
const file = Bun.file(input.path)
|
|
const file = Bun.file(input.path)
|
|
|
const text = await file.text()
|
|
const text = await file.text()
|
|
|
const extension = path.extname(input.path)
|
|
const extension = path.extname(input.path)
|
|
@@ -171,13 +189,18 @@ export namespace LSPClient {
|
|
|
return diagnostics
|
|
return diagnostics
|
|
|
},
|
|
},
|
|
|
async waitForDiagnostics(input: { path: string }) {
|
|
async waitForDiagnostics(input: { path: string }) {
|
|
|
- input.path = path.isAbsolute(input.path) ? input.path : path.resolve(Instance.directory, input.path)
|
|
|
|
|
|
|
+ input.path = path.isAbsolute(input.path)
|
|
|
|
|
+ ? input.path
|
|
|
|
|
+ : path.resolve(Instance.directory, input.path)
|
|
|
log.info("waiting for diagnostics", input)
|
|
log.info("waiting for diagnostics", input)
|
|
|
let unsub: () => void
|
|
let unsub: () => void
|
|
|
return await withTimeout(
|
|
return await withTimeout(
|
|
|
new Promise<void>((resolve) => {
|
|
new Promise<void>((resolve) => {
|
|
|
unsub = Bus.subscribe(Event.Diagnostics, (event) => {
|
|
unsub = Bus.subscribe(Event.Diagnostics, (event) => {
|
|
|
- if (event.properties.path === input.path && event.properties.serverID === result.serverID) {
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ event.properties.path === input.path &&
|
|
|
|
|
+ event.properties.serverID === result.serverID
|
|
|
|
|
+ ) {
|
|
|
log.info("got diagnostics", input)
|
|
log.info("got diagnostics", input)
|
|
|
unsub?.()
|
|
unsub?.()
|
|
|
resolve()
|
|
resolve()
|