Browse Source

feat: haskell lsp support (#6141)

Marco 1 month ago
parent
commit
d9f0f58277
2 changed files with 19 additions and 0 deletions
  1. 1 0
      packages/opencode/src/lsp/language.ts
  2. 18 0
      packages/opencode/src/lsp/server.ts

+ 1 - 0
packages/opencode/src/lsp/language.ts

@@ -39,6 +39,7 @@ export const LANGUAGE_EXTENSIONS: Record<string, string> = {
   ".hbs": "handlebars",
   ".handlebars": "handlebars",
   ".hs": "haskell",
+  ".lhs": "haskell",
   ".html": "html",
   ".htm": "html",
   ".ini": "ini",

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

@@ -1892,4 +1892,22 @@ export namespace LSPServer {
       }
     },
   }
+
+  export const HLS: Info = {
+    id: "haskell-language-server",
+    extensions: [".hs", ".lhs"],
+    root: NearestRoot(["stack.yaml", "cabal.project", "hie.yaml", "*.cabal"]),
+    async spawn(root) {
+      const bin = Bun.which("haskell-language-server-wrapper")
+      if (!bin) {
+        log.info("haskell-language-server-wrapper not found, please install haskell-language-server")
+        return
+      }
+      return {
+        process: spawn(bin, ["--lsp"], {
+          cwd: root,
+        }),
+      }
+    },
+  }
 }