Browse Source

feat: add Biome LSP support (#5290)

ry2009 2 months ago
parent
commit
16c4b02b69
2 changed files with 431 additions and 89 deletions
  1. 54 0
      packages/opencode/src/lsp/server.ts
  2. 377 89
      packages/sdk/js/openapi.json

+ 54 - 0
packages/opencode/src/lsp/server.ts

@@ -209,6 +209,60 @@ export namespace LSPServer {
     },
     },
   }
   }
 
 
+  export const Biome: Info = {
+    id: "biome",
+    root: NearestRoot(["biome.json", "biome.jsonc", "package-lock.json", "bun.lockb", "bun.lock", "pnpm-lock.yaml", "yarn.lock"]),
+    extensions: [
+      ".ts",
+      ".tsx",
+      ".js",
+      ".jsx",
+      ".mjs",
+      ".cjs",
+      ".mts",
+      ".cts",
+      ".json",
+      ".jsonc",
+      ".vue",
+      ".astro",
+      ".svelte",
+      ".css",
+      ".graphql",
+      ".gql",
+      ".html",
+    ],
+    async spawn(root) {
+      const localBin = path.join(root, "node_modules", ".bin", "biome")
+      let bin: string | undefined
+      if (await Bun.file(localBin).exists()) bin = localBin
+      if (!bin) {
+        const found = Bun.which("biome")
+        if (found) bin = found
+      }
+
+      let args = ["lsp-proxy", "--stdio"]
+
+      if (!bin) {
+        const resolved = await Bun.resolve("biome", root).catch(() => undefined)
+        if (!resolved) return
+        bin = BunProc.which()
+        args = ["x", "biome", "lsp-proxy", "--stdio"]
+      }
+
+      const proc = spawn(bin, args, {
+        cwd: root,
+        env: {
+          ...process.env,
+          BUN_BE_BUN: "1",
+        },
+      })
+
+      return {
+        process: proc,
+      }
+    },
+  }
+
   export const Gopls: Info = {
   export const Gopls: Info = {
     id: "gopls",
     id: "gopls",
     root: async (file) => {
     root: async (file) => {

File diff suppressed because it is too large
+ 377 - 89
packages/sdk/js/openapi.json


Some files were not shown because too many files changed in this diff