Skip to content

Commit e1d22ad

Browse files
committed
fix: yaml-ls initialization issues
1 parent b7b2eae commit e1d22ad

File tree

1 file changed

+25
-32
lines changed

1 file changed

+25
-32
lines changed

packages/opencode/src/lsp/server.ts

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,39 +1322,22 @@ export namespace LSPServer {
13221322
export const YamlLS: Info = {
13231323
id: "yaml-ls",
13241324
extensions: [".yaml", ".yml"],
1325-
root: NearestRoot(["package-lock.json", "bun.lockb", "bun.lock", "pnpm-lock.yaml", "yarn.lock"]),
1325+
root: NearestRoot([
1326+
"package-lock.json",
1327+
"bun.lockb",
1328+
"bun.lock",
1329+
"pnpm-lock.yaml",
1330+
"yarn.lock",
1331+
".yamllint",
1332+
".yamllint.yml",
1333+
".yamllint.yaml",
1334+
"kustomization.yaml",
1335+
"kustomization.yml",
1336+
"docker-compose.yaml",
1337+
"docker-compose.yml",
1338+
]),
13261339
async spawn(root) {
1327-
let binary = Bun.which("yaml-language-server")
1328-
const args: string[] = []
1329-
if (!binary) {
1330-
const js = path.join(
1331-
Global.Path.bin,
1332-
"node_modules",
1333-
"yaml-language-server",
1334-
"out",
1335-
"server",
1336-
"src",
1337-
"server.js",
1338-
)
1339-
const exists = await Bun.file(js).exists()
1340-
if (!exists) {
1341-
if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
1342-
await Bun.spawn([BunProc.which(), "install", "yaml-language-server"], {
1343-
cwd: Global.Path.bin,
1344-
env: {
1345-
...process.env,
1346-
BUN_BE_BUN: "1",
1347-
},
1348-
stdout: "pipe",
1349-
stderr: "pipe",
1350-
stdin: "pipe",
1351-
}).exited
1352-
}
1353-
binary = BunProc.which()
1354-
args.push("run", js)
1355-
}
1356-
args.push("--stdio")
1357-
const proc = spawn(binary, args, {
1340+
const proc = spawn(BunProc.which(), ["x", "yaml-language-server", "--stdio"], {
13581341
cwd: root,
13591342
env: {
13601343
...process.env,
@@ -1363,6 +1346,16 @@ export namespace LSPServer {
13631346
})
13641347
return {
13651348
process: proc,
1349+
initialization: {
1350+
yaml: {
1351+
completion: true,
1352+
validate: true,
1353+
hover: true,
1354+
schemaStore: {
1355+
enable: true,
1356+
},
1357+
},
1358+
},
13661359
}
13671360
},
13681361
}

0 commit comments

Comments
 (0)