|
@@ -51,6 +51,7 @@ export namespace LSPClient {
|
|
|
log.info("textDocument/publishDiagnostics", {
|
|
log.info("textDocument/publishDiagnostics", {
|
|
|
path,
|
|
path,
|
|
|
});
|
|
});
|
|
|
|
|
+ console.log(path, params);
|
|
|
diagnostics.set(path, params.diagnostics);
|
|
diagnostics.set(path, params.diagnostics);
|
|
|
Bus.publish(Event.Diagnostics, { path, serverID: input.serverID });
|
|
Bus.publish(Event.Diagnostics, { path, serverID: input.serverID });
|
|
|
});
|
|
});
|
|
@@ -129,7 +130,9 @@ export namespace LSPClient {
|
|
|
},
|
|
},
|
|
|
notify: {
|
|
notify: {
|
|
|
async open(input: { path: string }) {
|
|
async open(input: { path: string }) {
|
|
|
- const text = await Bun.file(input.path).text();
|
|
|
|
|
|
|
+ const file = Bun.file(input.path);
|
|
|
|
|
+ if (!file.exists()) return;
|
|
|
|
|
+ const text = await file.text();
|
|
|
const opened = files.has(input.path);
|
|
const opened = files.has(input.path);
|
|
|
if (!opened) {
|
|
if (!opened) {
|
|
|
log.info("textDocument/didOpen", input);
|
|
log.info("textDocument/didOpen", input);
|
|
@@ -140,8 +143,8 @@ export namespace LSPClient {
|
|
|
textDocument: {
|
|
textDocument: {
|
|
|
uri: `file://` + input.path,
|
|
uri: `file://` + input.path,
|
|
|
languageId,
|
|
languageId,
|
|
|
- version: 1,
|
|
|
|
|
- text: text,
|
|
|
|
|
|
|
+ version: ++version,
|
|
|
|
|
+ text,
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
files.add(input.path);
|
|
files.add(input.path);
|
|
@@ -150,11 +153,10 @@ export namespace LSPClient {
|
|
|
|
|
|
|
|
log.info("textDocument/didChange", input);
|
|
log.info("textDocument/didChange", input);
|
|
|
diagnostics.delete(input.path);
|
|
diagnostics.delete(input.path);
|
|
|
- version++;
|
|
|
|
|
await connection.sendNotification("textDocument/didChange", {
|
|
await connection.sendNotification("textDocument/didChange", {
|
|
|
textDocument: {
|
|
textDocument: {
|
|
|
uri: `file://` + input.path,
|
|
uri: `file://` + input.path,
|
|
|
- version,
|
|
|
|
|
|
|
+ version: ++version,
|
|
|
},
|
|
},
|
|
|
contentChanges: [
|
|
contentChanges: [
|
|
|
{
|
|
{
|
|
@@ -168,7 +170,7 @@ export namespace LSPClient {
|
|
|
return diagnostics;
|
|
return diagnostics;
|
|
|
},
|
|
},
|
|
|
async waitForDiagnostics(input: { path: string }) {
|
|
async waitForDiagnostics(input: { path: string }) {
|
|
|
- log.info("refreshing diagnostics", input);
|
|
|
|
|
|
|
+ log.info("waiting for diagnostics", input);
|
|
|
let unsub: () => void;
|
|
let unsub: () => void;
|
|
|
let timeout: NodeJS.Timeout;
|
|
let timeout: NodeJS.Timeout;
|
|
|
return await Promise.race([
|
|
return await Promise.race([
|
|
@@ -184,7 +186,6 @@ export namespace LSPClient {
|
|
|
resolve();
|
|
resolve();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- await result.notify.open(input);
|
|
|
|
|
}),
|
|
}),
|
|
|
new Promise<void>((resolve) => {
|
|
new Promise<void>((resolve) => {
|
|
|
timeout = setTimeout(() => {
|
|
timeout = setTimeout(() => {
|