Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/opencode/src/flag/flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export namespace Flag {
export const OPENCODE_EXPERIMENTAL_OXFMT = OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_OXFMT")
export const OPENCODE_EXPERIMENTAL_LSP_TY = truthy("OPENCODE_EXPERIMENTAL_LSP_TY")
export const OPENCODE_EXPERIMENTAL_LSP_TOOL = OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_LSP_TOOL")
export const OPENCODE_RESPECT_LSP_DIAGNOSTICS = truthy("OPENCODE_RESPECT_LSP_DIAGNOSTICS")
export const OPENCODE_DISABLE_FILETIME_CHECK = truthy("OPENCODE_DISABLE_FILETIME_CHECK")
export const OPENCODE_EXPERIMENTAL_PLAN_MODE = OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_PLAN_MODE")
export const OPENCODE_EXPERIMENTAL_MARKDOWN = truthy("OPENCODE_EXPERIMENTAL_MARKDOWN")
Expand Down
8 changes: 5 additions & 3 deletions packages/opencode/src/lsp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import { NamedError } from "@opencode-ai/util/error"
import { withTimeout } from "../util/timeout"
import { Instance } from "../project/instance"
import { Filesystem } from "../util/filesystem"
import { Flag } from "../flag/flag"

const DIAGNOSTICS_DEBOUNCE_MS = 150
const DIAGNOSTICS_DEBOUNCE_MS = Flag.OPENCODE_RESPECT_LSP_DIAGNOSTICS ? 0 : 150

export namespace LSPClient {
const log = Log.create({ service: "lsp.client" })
Expand Down Expand Up @@ -57,7 +58,7 @@ export namespace LSPClient {
})
const exists = diagnostics.has(filePath)
diagnostics.set(filePath, params.diagnostics)
if (!exists && input.serverID === "typescript") return
if (!Flag.OPENCODE_RESPECT_LSP_DIAGNOSTICS && !exists && input.serverID === "typescript") return
Bus.publish(Event.Diagnostics, { path: filePath, serverID: input.serverID })
})
connection.onRequest("window/workDoneProgress/create", (params) => {
Expand Down Expand Up @@ -214,6 +215,7 @@ export namespace LSPClient {
log.info("waiting for diagnostics", { path: normalizedPath })
let unsub: () => void
let debounceTimer: ReturnType<typeof setTimeout> | undefined
const timeoutMs = Flag.OPENCODE_RESPECT_LSP_DIAGNOSTICS ? 30000 : 3000
return await withTimeout(
new Promise<void>((resolve) => {
unsub = Bus.subscribe(Event.Diagnostics, (event) => {
Expand All @@ -228,7 +230,7 @@ export namespace LSPClient {
}
})
}),
3000,
timeoutMs,
)
.catch(() => {})
.finally(() => {
Expand Down
Loading