summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdán <[email protected]>2025-12-11 23:28:39 +0100
committerGitHub <[email protected]>2025-12-11 16:28:39 -0600
commitffec52a17ce610ad21fb63782650410db90e6b79 (patch)
treec18c66c3c8f139bb1387adba9f41cbad46f04d06
parent342595e0f7cce3b27f7f4e44b206128663df083e (diff)
downloadopencode-ffec52a17ce610ad21fb63782650410db90e6b79.tar.gz
opencode-ffec52a17ce610ad21fb63782650410db90e6b79.zip
fix: Windows LSP URIs using backslashes (Biome initialization failure) (#5317)
-rw-r--r--packages/opencode/src/config/config.ts3
-rw-r--r--packages/opencode/src/lsp/client.ts13
-rw-r--r--packages/opencode/src/lsp/index.ts3
3 files changed, 11 insertions, 8 deletions
diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts
index be1949c3b..42f6b11e9 100644
--- a/packages/opencode/src/config/config.ts
+++ b/packages/opencode/src/config/config.ts
@@ -1,5 +1,6 @@
import { Log } from "../util/log"
import path from "path"
+import { pathToFileURL } from "url"
import os from "os"
import z from "zod"
import { Filesystem } from "../util/filesystem"
@@ -297,7 +298,7 @@ export namespace Config {
dot: true,
cwd: dir,
})) {
- plugins.push("file://" + item)
+ plugins.push(pathToFileURL(item).href)
}
return plugins
}
diff --git a/packages/opencode/src/lsp/client.ts b/packages/opencode/src/lsp/client.ts
index 31b8ff711..ce426cf62 100644
--- a/packages/opencode/src/lsp/client.ts
+++ b/packages/opencode/src/lsp/client.ts
@@ -1,6 +1,7 @@
import { BusEvent } from "@/bus/bus-event"
import { Bus } from "@/bus"
import path from "path"
+import { pathToFileURL, fileURLToPath } from "url"
import { createMessageConnection, StreamMessageReader, StreamMessageWriter } from "vscode-jsonrpc/node"
import type { Diagnostic as VSCodeDiagnostic } from "vscode-languageserver-types"
import { Log } from "../util/log"
@@ -46,7 +47,7 @@ export namespace LSPClient {
const diagnostics = new Map<string, Diagnostic[]>()
connection.onNotification("textDocument/publishDiagnostics", (params) => {
- const path = new URL(params.uri).pathname
+ const path = fileURLToPath(params.uri)
l.info("textDocument/publishDiagnostics", {
path,
})
@@ -68,7 +69,7 @@ export namespace LSPClient {
connection.onRequest("workspace/workspaceFolders", async () => [
{
name: "workspace",
- uri: "file://" + input.root,
+ uri: pathToFileURL(input.root).href,
},
])
connection.listen()
@@ -76,12 +77,12 @@ export namespace LSPClient {
l.info("sending initialize")
await withTimeout(
connection.sendRequest("initialize", {
- rootUri: "file://" + input.root,
+ rootUri: pathToFileURL(input.root).href,
processId: input.server.process.pid,
workspaceFolders: [
{
name: "workspace",
- uri: "file://" + input.root,
+ uri: pathToFileURL(input.root).href,
},
],
initializationOptions: {
@@ -154,7 +155,7 @@ export namespace LSPClient {
})
await connection.sendNotification("textDocument/didChange", {
textDocument: {
- uri: `file://` + input.path,
+ uri: pathToFileURL(input.path).href,
version: next,
},
contentChanges: [{ text }],
@@ -166,7 +167,7 @@ export namespace LSPClient {
diagnostics.delete(input.path)
await connection.sendNotification("textDocument/didOpen", {
textDocument: {
- uri: `file://` + input.path,
+ uri: pathToFileURL(input.path).href,
languageId,
version: 0,
text,
diff --git a/packages/opencode/src/lsp/index.ts b/packages/opencode/src/lsp/index.ts
index 096c57a6d..764c91fcc 100644
--- a/packages/opencode/src/lsp/index.ts
+++ b/packages/opencode/src/lsp/index.ts
@@ -3,6 +3,7 @@ import { Bus } from "@/bus"
import { Log } from "../util/log"
import { LSPClient } from "./client"
import path from "path"
+import { pathToFileURL } from "url"
import { LSPServer } from "./server"
import z from "zod"
import { Config } from "../config/config"
@@ -270,7 +271,7 @@ export namespace LSP {
return run((client) => {
return client.connection.sendRequest("textDocument/hover", {
textDocument: {
- uri: `file://${input.file}`,
+ uri: pathToFileURL(input.file).href,
},
position: {
line: input.line,