Skip to content

Commit e7a157e

Browse files
fix: replace ruby-lsp with rubocop for better LSP performance (anomalyco#4543)
1 parent 3989b9f commit e7a157e

2 files changed

Lines changed: 29 additions & 29 deletions

File tree

packages/opencode/src/lsp/server.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,12 @@ export namespace LSPServer {
250250
},
251251
}
252252

253-
export const RubyLsp: Info = {
253+
export const Rubocop: Info = {
254254
id: "ruby-lsp",
255255
root: NearestRoot(["Gemfile"]),
256256
extensions: [".rb", ".rake", ".gemspec", ".ru"],
257257
async spawn(root) {
258-
let bin = Bun.which("ruby-lsp", {
258+
let bin = Bun.which("rubocop", {
259259
PATH: process.env["PATH"] + ":" + Global.Path.bin,
260260
})
261261
if (!bin) {
@@ -266,25 +266,25 @@ export namespace LSPServer {
266266
return
267267
}
268268
if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
269-
log.info("installing ruby-lsp")
269+
log.info("installing rubocop")
270270
const proc = Bun.spawn({
271-
cmd: ["gem", "install", "ruby-lsp", "--bindir", Global.Path.bin],
271+
cmd: ["gem", "install", "rubocop", "--bindir", Global.Path.bin],
272272
stdout: "pipe",
273273
stderr: "pipe",
274274
stdin: "pipe",
275275
})
276276
const exit = await proc.exited
277277
if (exit !== 0) {
278-
log.error("Failed to install ruby-lsp")
278+
log.error("Failed to install rubocop")
279279
return
280280
}
281-
bin = path.join(Global.Path.bin, "ruby-lsp" + (process.platform === "win32" ? ".exe" : ""))
282-
log.info(`installed ruby-lsp`, {
281+
bin = path.join(Global.Path.bin, "rubocop" + (process.platform === "win32" ? ".exe" : ""))
282+
log.info(`installed rubocop`, {
283283
bin,
284284
})
285285
}
286286
return {
287-
process: spawn(bin!, ["--stdio"], {
287+
process: spawn(bin!, ["--lsp"], {
288288
cwd: root,
289289
}),
290290
}

packages/web/src/content/docs/lsp.mdx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@ OpenCode integrates with your Language Server Protocol (LSP) to help the LLM int
1111

1212
OpenCode comes with several built-in LSP servers for popular languages:
1313

14-
| LSP Server | Extensions | Requirements |
15-
| ---------------- | ---------------------------------------------------- | ------------------------------------------------------------ |
16-
| typescript | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts | `typescript` dependency in project |
17-
| deno | .ts, .tsx, .js, .jsx, .mjs | `deno` command available (auto-detects deno.json/deno.jsonc) |
18-
| eslint | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts, .vue | `eslint` dependency in project |
19-
| gopls | .go | `go` command available |
20-
| ruby-lsp | .rb, .rake, .gemspec, .ru | `ruby` and `gem` commands available |
21-
| pyright | .py, .pyi | `pyright` dependency installed |
22-
| elixir-ls | .ex, .exs | `elixir` command available |
23-
| zls | .zig, .zon | `zig` command available |
24-
| csharp | .cs | `.NET SDK` installed |
25-
| vue | .vue | Auto-installs for Vue projects |
26-
| rust | .rs | `rust-analyzer` command available |
27-
| clangd | .c, .cpp, .cc, .cxx, .c++, .h, .hpp, .hh, .hxx, .h++ | Auto-installs for C/C++ projects |
28-
| svelte | .svelte | Auto-installs for Svelte projects |
29-
| astro | .astro | Auto-installs for Astro projects |
30-
| yaml-ls | .yaml, .yml | Auto-installs Red Hat yaml-language-server |
31-
| jdtls | .java | `Java SDK (version 21+)` installed |
32-
| lua-ls | .lua | Auto-installs for Lua projects |
33-
| sourcekit-lsp | .swift, .objc, .objcpp | `swift` installed (`xcode` on macOS) |
34-
| php intelephense | .php | Auto-installs for PHP projects |
14+
| LSP Server | Extensions | Requirements |
15+
| ------------------ | ---------------------------------------------------- | ------------------------------------------------------------ |
16+
| typescript | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts | `typescript` dependency in project |
17+
| deno | .ts, .tsx, .js, .jsx, .mjs | `deno` command available (auto-detects deno.json/deno.jsonc) |
18+
| eslint | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts, .vue | `eslint` dependency in project |
19+
| gopls | .go | `go` command available |
20+
| ruby-lsp (rubocop) | .rb, .rake, .gemspec, .ru | `ruby` and `gem` commands available |
21+
| pyright | .py, .pyi | `pyright` dependency installed |
22+
| elixir-ls | .ex, .exs | `elixir` command available |
23+
| zls | .zig, .zon | `zig` command available |
24+
| csharp | .cs | `.NET SDK` installed |
25+
| vue | .vue | Auto-installs for Vue projects |
26+
| rust | .rs | `rust-analyzer` command available |
27+
| clangd | .c, .cpp, .cc, .cxx, .c++, .h, .hpp, .hh, .hxx, .h++ | Auto-installs for C/C++ projects |
28+
| svelte | .svelte | Auto-installs for Svelte projects |
29+
| astro | .astro | Auto-installs for Astro projects |
30+
| yaml-ls | .yaml, .yml | Auto-installs Red Hat yaml-language-server |
31+
| jdtls | .java | `Java SDK (version 21+)` installed |
32+
| lua-ls | .lua | Auto-installs for Lua projects |
33+
| sourcekit-lsp | .swift, .objc, .objcpp | `swift` installed (`xcode` on macOS) |
34+
| php intelephense | .php | Auto-installs for PHP projects |
3535

3636
LSP servers are automatically enabled when one of the above file extensions are detected and the requirements are met.
3737

0 commit comments

Comments
 (0)