Lawrence Sarpong 2 месяцев назад
Родитель
Сommit
e6a0a005d6

+ 9 - 0
packages/opencode/src/format/formatter.ts

@@ -284,3 +284,12 @@ export const latexindent: Info = {
     return Bun.which("latexindent") !== null
     return Bun.which("latexindent") !== null
   },
   },
 }
 }
+
+export const gleam: Info = {
+  name: "gleam",
+  command: ["gleam", "format", "$FILE"],
+  extensions: [".gleam"],
+  async enabled() {
+    return Bun.which("gleam") !== null
+  },
+}

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

@@ -34,6 +34,7 @@ export const LANGUAGE_EXTENSIONS: Record<string, string> = {
   ".gitrebase": "git-rebase",
   ".gitrebase": "git-rebase",
   ".go": "go",
   ".go": "go",
   ".groovy": "groovy",
   ".groovy": "groovy",
+  ".gleam": "gleam",
   ".hbs": "handlebars",
   ".hbs": "handlebars",
   ".handlebars": "handlebars",
   ".handlebars": "handlebars",
   ".hs": "haskell",
   ".hs": "haskell",

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

@@ -1509,4 +1509,22 @@ export namespace LSPServer {
       }
       }
     },
     },
   }
   }
+
+  export const Gleam: Info = {
+    id: "gleam",
+    extensions: [".gleam"],
+    root: NearestRoot(["gleam.toml"]),
+    async spawn(root) {
+      const gleam = Bun.which("gleam")
+      if (!gleam) {
+        log.info("gleam not found, please install gleam first")
+        return
+      }
+      return {
+        process: spawn(gleam, ["lsp"], {
+          cwd: root,
+        }),
+      }
+    },
+  }
 }
 }

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

@@ -29,6 +29,7 @@ OpenCode comes with several built-in formatters for popular languages and framew
 | dart           | .dart                                                                                                    | `dart` command available                                       |
 | dart           | .dart                                                                                                    | `dart` command available                                       |
 | ocamlformat    | .ml, .mli                                                                                                | `ocamlformat` command available and `.ocamlformat` config file |
 | ocamlformat    | .ml, .mli                                                                                                | `ocamlformat` command available and `.ocamlformat` config file |
 | terraform      | .tf, .tfvars                                                                                             | `terraform` command available                                  |
 | terraform      | .tf, .tfvars                                                                                             | `terraform` command available                                  |
+| gleam          | .gleam                                                                                                   | `gleam` command available                                      |
 
 
 So if your project has `prettier` in your `package.json`, OpenCode will automatically use it.
 So if your project has `prettier` in your `package.json`, OpenCode will automatically use it.
 
 

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

@@ -36,6 +36,7 @@ OpenCode comes with several built-in LSP servers for popular languages:
 | ocaml-lsp          | .ml, .mli                                            | `ocamllsp` command available                                 |
 | ocaml-lsp          | .ml, .mli                                            | `ocamllsp` command available                                 |
 | terraform          | .tf, .tfvars                                         | Auto-installs from GitHub releases                           |
 | terraform          | .tf, .tfvars                                         | Auto-installs from GitHub releases                           |
 | bash               | .sh, .bash, .zsh, .ksh                               | Auto-installs bash-language-server                           |
 | bash               | .sh, .bash, .zsh, .ksh                               | Auto-installs bash-language-server                           |
+| gleam              | .gleam                                               | `gleam` command available                                    |
 
 
 LSP servers are automatically enabled when one of the above file extensions are detected and the requirements are met.
 LSP servers are automatically enabled when one of the above file extensions are detected and the requirements are met.