summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-07-03 19:29:42 -0400
committerDax Raad <[email protected]>2025-07-03 19:29:51 -0400
commitcf83e31f231436dacc5a729abaff7a0e66a111c6 (patch)
tree75a9e997ce5851057a17bddd359051ff6d41cb78
parent3bc238b58bfe26909ff6854276053e817af69e53 (diff)
downloadopencode-cf83e31f231436dacc5a729abaff7a0e66a111c6.tar.gz
opencode-cf83e31f231436dacc5a729abaff7a0e66a111c6.zip
add elixir lsp support
-rw-r--r--packages/opencode/src/lsp/server.ts58
-rw-r--r--packages/opencode/src/tool/edit.ts8
2 files changed, 62 insertions, 4 deletions
diff --git a/packages/opencode/src/lsp/server.ts b/packages/opencode/src/lsp/server.ts
index ce7972f52..39a23f0ff 100644
--- a/packages/opencode/src/lsp/server.ts
+++ b/packages/opencode/src/lsp/server.ts
@@ -4,6 +4,8 @@ import path from "path"
import { Global } from "../global"
import { Log } from "../util/log"
import { BunProc } from "../bun"
+import { $ } from "bun"
+import fs from "fs/promises"
export namespace LSPServer {
const log = Log.create({ service: "lsp.server" })
@@ -144,4 +146,60 @@ export namespace LSPServer {
}
},
}
+
+ export const ElixirLS: Info = {
+ id: "elixir-ls",
+ extensions: [".ex", ".exs"],
+ async spawn() {
+ let binary = Bun.which("elixir-ls")
+ if (!binary) {
+ const elixirLsPath = path.join(Global.Path.bin, "elixir-ls")
+ binary = path.join(
+ Global.Path.bin,
+ "elixir-ls-master",
+ "release",
+ process.platform === "win32"
+ ? "language_server.bar"
+ : "language_server.sh",
+ )
+
+ if (!(await Bun.file(binary).exists())) {
+ const elixir = Bun.which("elixir")
+ if (!elixir) {
+ log.error("elixir is required to run elixir-ls")
+ return
+ }
+
+ log.info("downloading elixir-ls from GitHub releases")
+
+ const response = await fetch(
+ "https://github.com/elixir-lsp/elixir-ls/archive/refs/heads/master.zip",
+ )
+ if (!response.ok) return
+ const zipPath = path.join(Global.Path.bin, "elixir-ls.zip")
+ await Bun.file(zipPath).write(response)
+
+ await $`unzip -o -q ${zipPath}`.cwd(Global.Path.bin).nothrow()
+
+ await fs.rm(zipPath, {
+ force: true,
+ recursive: true,
+ })
+
+ await $`mix deps.get && mix compile && mix elixir_ls.release2 -o release`
+ .quiet()
+ .cwd(path.join(Global.Path.bin, "elixir-ls-master"))
+ .env({ MIX_ENV: "prod", ...process.env })
+
+ log.info(`installed elixir-ls`, {
+ path: elixirLsPath,
+ })
+ }
+ }
+
+ return {
+ process: spawn(binary),
+ }
+ },
+ }
}
diff --git a/packages/opencode/src/tool/edit.ts b/packages/opencode/src/tool/edit.ts
index fb02a536c..8c9043e64 100644
--- a/packages/opencode/src/tool/edit.ts
+++ b/packages/opencode/src/tool/edit.ts
@@ -489,10 +489,10 @@ export function replace(
BlockAnchorReplacer,
WhitespaceNormalizedReplacer,
IndentationFlexibleReplacer,
- EscapeNormalizedReplacer,
- TrimmedBoundaryReplacer,
- ContextAwareReplacer,
- MultiOccurrenceReplacer,
+ // EscapeNormalizedReplacer,
+ // TrimmedBoundaryReplacer,
+ // ContextAwareReplacer,
+ // MultiOccurrenceReplacer,
]) {
for (const search of replacer(content, oldString)) {
const index = content.indexOf(search)