Shoubhit Dash 2 месяцев назад
Родитель
Сommit
20530104ce

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

@@ -103,6 +103,8 @@ export const LANGUAGE_EXTENSIONS: Record<string, string> = {
   ".zig": "zig",
   ".zon": "zig",
   ".astro": "astro",
+  ".ml": "ocaml",
+  ".mli": "ocaml",
   ".tf": "terraform",
   ".tfvars": "terraform-vars",
   ".hcl": "hcl",

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

@@ -1185,6 +1185,23 @@ export namespace LSPServer {
     },
   }
 
+  export const Ocaml: Info = {
+    id: "ocaml-lsp",
+    extensions: [".ml", ".mli"],
+    root: NearestRoot(["dune-project", "dune-workspace", ".merlin", "opam"]),
+    async spawn(root) {
+      const bin = Bun.which("ocamllsp")
+      if (!bin) {
+        log.info("ocamllsp not found, please install ocaml-lsp-server")
+        return
+      }
+      return {
+        process: spawn(bin, {
+          cwd: root,
+        }),
+      }
+    },
+  }
   export const BashLS: Info = {
     id: "bash",
     extensions: [".sh", ".bash", ".zsh", ".ksh"],

+ 1 - 0
packages/web/src/content/docs/lsp.mdx

@@ -33,6 +33,7 @@ OpenCode comes with several built-in LSP servers for popular languages:
 | sourcekit-lsp      | .swift, .objc, .objcpp                               | `swift` installed (`xcode` on macOS)                         |
 | php intelephense   | .php                                                 | Auto-installs for PHP projects                               |
 | dart               | .dart                                                | `dart` command available                                     |
+| ocaml-lsp          | .ml, .mli                                            | `ocamllsp` command available                                 |
 | terraform          | .tf, .tfvars                                         | Auto-installs from GitHub releases                           |
 | bash               | .sh, .bash, .zsh, .ksh                               | Auto-installs bash-language-server                           |