|
|
@@ -6,13 +6,13 @@ import path from "path"
|
|
|
import { pathToFileURL, fileURLToPath } from "url"
|
|
|
import * as LSPServer from "./server"
|
|
|
import { Config } from "@/config/config"
|
|
|
-import { Flag } from "@opencode-ai/core/flag/flag"
|
|
|
import { Process } from "@/util/process"
|
|
|
import { spawn as lspspawn } from "./launch"
|
|
|
import { Effect, Layer, Context, Schema } from "effect"
|
|
|
import { InstanceState } from "@/effect/instance-state"
|
|
|
import { containsPath } from "@/project/instance-context"
|
|
|
import { NonNegativeInt } from "@opencode-ai/core/schema"
|
|
|
+import { RuntimeFlags } from "@/effect/runtime-flags"
|
|
|
|
|
|
const log = Log.create({ service: "lsp" })
|
|
|
|
|
|
@@ -98,8 +98,8 @@ const kinds = [
|
|
|
SymbolKind.Enum,
|
|
|
]
|
|
|
|
|
|
-const filterExperimentalServers = (servers: Record<string, LSPServer.Info>) => {
|
|
|
- if (Flag.OPENCODE_EXPERIMENTAL_LSP_TY) {
|
|
|
+const filterExperimentalServers = (servers: Record<string, LSPServer.Info>, flags: RuntimeFlags.Info) => {
|
|
|
+ if (flags.experimentalLspTy) {
|
|
|
if (servers["pyright"]) {
|
|
|
log.info("LSP server pyright is disabled because OPENCODE_EXPERIMENTAL_LSP_TY is enabled")
|
|
|
delete servers["pyright"]
|
|
|
@@ -143,6 +143,7 @@ export const layer = Layer.effect(
|
|
|
Service,
|
|
|
Effect.gen(function* () {
|
|
|
const config = yield* Config.Service
|
|
|
+ const flags = yield* RuntimeFlags.Service
|
|
|
|
|
|
const state = yield* InstanceState.make<State>(
|
|
|
Effect.fn("LSP.state")(function* (ctx) {
|
|
|
@@ -157,7 +158,7 @@ export const layer = Layer.effect(
|
|
|
servers[server.id] = server
|
|
|
}
|
|
|
|
|
|
- filterExperimentalServers(servers)
|
|
|
+ filterExperimentalServers(servers, flags)
|
|
|
|
|
|
if (cfg.lsp !== true) {
|
|
|
for (const [name, item] of Object.entries(cfg.lsp)) {
|
|
|
@@ -217,7 +218,7 @@ export const layer = Layer.effect(
|
|
|
|
|
|
async function schedule(server: LSPServer.Info, root: string, key: string) {
|
|
|
const handle = await server
|
|
|
- .spawn(root, ctx)
|
|
|
+ .spawn(root, ctx, flags)
|
|
|
.then((value) => {
|
|
|
if (!value) s.broken.add(key)
|
|
|
return value
|
|
|
@@ -498,7 +499,7 @@ export const layer = Layer.effect(
|
|
|
}),
|
|
|
)
|
|
|
|
|
|
-export const defaultLayer = layer.pipe(Layer.provide(Config.defaultLayer))
|
|
|
+export const defaultLayer = layer.pipe(Layer.provide(Config.defaultLayer), Layer.provide(RuntimeFlags.defaultLayer))
|
|
|
|
|
|
export * as Diagnostic from "./diagnostic"
|
|
|
|