The open source coding agent.
TypeScript
fix: replace ruby-lsp with rubocop for better LSP performance (#4543)
processtradere7a157ef8f57
diff --git a/packages/opencode/src/lsp/server.ts b/packages/opencode/src/lsp/server.tsindex efecd087910..79a2a408bfc 100644--- a/packages/opencode/src/lsp/server.ts+++ b/packages/opencode/src/lsp/server.ts@@ -250,12 +250,12 @@ export namespace LSPServer {},}- export const RubyLsp: Info = {+ export const Rubocop: Info = {id: "ruby-lsp",root: NearestRoot(["Gemfile"]),extensions: [".rb", ".rake", ".gemspec", ".ru"],async spawn(root) {- let bin = Bun.which("ruby-lsp", {+ let bin = Bun.which("rubocop", {PATH: process.env["PATH"] + ":" + Global.Path.bin,})if (!bin) {@@ -266,25 +266,25 @@ export namespace LSPServer {return}if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return- log.info("installing ruby-lsp")+ log.info("installing rubocop")const proc = Bun.spawn({- cmd: ["gem", "install", "ruby-lsp", "--bindir", Global.Path.bin],+ cmd: ["gem", "install", "rubocop", "--bindir", Global.Path.bin],stdout: "pipe",stderr: "pipe",stdin: "pipe",})const exit = await proc.exitedif (exit !== 0) {- log.error("Failed to install ruby-lsp")+ log.error("Failed to install rubocop")return}- bin = path.join(Global.Path.bin, "ruby-lsp" + (process.platform === "win32" ? ".exe" : ""))- log.info(`installed ruby-lsp`, {+ bin = path.join(Global.Path.bin, "rubocop" + (process.platform === "win32" ? ".exe" : ""))+ log.info(`installed rubocop`, {bin,})}return {- process: spawn(bin!, ["--stdio"], {+ process: spawn(bin!, ["--lsp"], {cwd: root,}),}diff --git a/packages/web/src/content/docs/lsp.mdx b/packages/web/src/content/docs/lsp.mdxindex cdbea7867b0..5c12f03f698 100644--- a/packages/web/src/content/docs/lsp.mdx+++ b/packages/web/src/content/docs/lsp.mdx@@ -11,27 +11,27 @@ OpenCode integrates with your Language Server Protocol (LSP) to help the LLM intOpenCode comes with several built-in LSP servers for popular languages:-| LSP Server | Extensions | Requirements |-| ---------------- | ---------------------------------------------------- | ------------------------------------------------------------ |-| typescript | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts | `typescript` dependency in project |-| deno | .ts, .tsx, .js, .jsx, .mjs | `deno` command available (auto-detects deno.json/deno.jsonc) |-| eslint | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts, .vue | `eslint` dependency in project |-| gopls | .go | `go` command available |-| ruby-lsp | .rb, .rake, .gemspec, .ru | `ruby` and `gem` commands available |-| pyright | .py, .pyi | `pyright` dependency installed |-| elixir-ls | .ex, .exs | `elixir` command available |-| zls | .zig, .zon | `zig` command available |-| csharp | .cs | `.NET SDK` installed |-| vue | .vue | Auto-installs for Vue projects |-| rust | .rs | `rust-analyzer` command available |-| clangd | .c, .cpp, .cc, .cxx, .c++, .h, .hpp, .hh, .hxx, .h++ | Auto-installs for C/C++ projects |-| svelte | .svelte | Auto-installs for Svelte projects |-| astro | .astro | Auto-installs for Astro projects |-| yaml-ls | .yaml, .yml | Auto-installs Red Hat yaml-language-server |-| jdtls | .java | `Java SDK (version 21+)` installed |-| lua-ls | .lua | Auto-installs for Lua projects |-| sourcekit-lsp | .swift, .objc, .objcpp | `swift` installed (`xcode` on macOS) |-| php intelephense | .php | Auto-installs for PHP projects |+| LSP Server | Extensions | Requirements |+| ------------------ | ---------------------------------------------------- | ------------------------------------------------------------ |+| typescript | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts | `typescript` dependency in project |+| deno | .ts, .tsx, .js, .jsx, .mjs | `deno` command available (auto-detects deno.json/deno.jsonc) |+| eslint | .ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts, .vue | `eslint` dependency in project |+| gopls | .go | `go` command available |+| ruby-lsp (rubocop) | .rb, .rake, .gemspec, .ru | `ruby` and `gem` commands available |+| pyright | .py, .pyi | `pyright` dependency installed |+| elixir-ls | .ex, .exs | `elixir` command available |+| zls | .zig, .zon | `zig` command available |+| csharp | .cs | `.NET SDK` installed |+| vue | .vue | Auto-installs for Vue projects |+| rust | .rs | `rust-analyzer` command available |+| clangd | .c, .cpp, .cc, .cxx, .c++, .h, .hpp, .hh, .hxx, .h++ | Auto-installs for C/C++ projects |+| svelte | .svelte | Auto-installs for Svelte projects |+| astro | .astro | Auto-installs for Astro projects |+| yaml-ls | .yaml, .yml | Auto-installs Red Hat yaml-language-server |+| jdtls | .java | `Java SDK (version 21+)` installed |+| lua-ls | .lua | Auto-installs for Lua projects |+| sourcekit-lsp | .swift, .objc, .objcpp | `swift` installed (`xcode` on macOS) |+| php intelephense | .php | Auto-installs for PHP projects |LSP servers are automatically enabled when one of the above file extensions are detected and the requirements are met.