ソースを参照

fix: replace ruby-lsp with rubocop for better LSP performance (#4543)

processtrader 3 ヶ月 前
コミット
e7a157ef8f
2 ファイル変更29 行追加29 行削除
  1. 8 8
      packages/opencode/src/lsp/server.ts
  2. 21 21
      packages/web/src/content/docs/lsp.mdx

+ 8 - 8
packages/opencode/src/lsp/server.ts

@@ -250,12 +250,12 @@ export namespace LSPServer {
     },
     },
   }
   }
 
 
-  export const RubyLsp: Info = {
+  export const Rubocop: Info = {
     id: "ruby-lsp",
     id: "ruby-lsp",
     root: NearestRoot(["Gemfile"]),
     root: NearestRoot(["Gemfile"]),
     extensions: [".rb", ".rake", ".gemspec", ".ru"],
     extensions: [".rb", ".rake", ".gemspec", ".ru"],
     async spawn(root) {
     async spawn(root) {
-      let bin = Bun.which("ruby-lsp", {
+      let bin = Bun.which("rubocop", {
         PATH: process.env["PATH"] + ":" + Global.Path.bin,
         PATH: process.env["PATH"] + ":" + Global.Path.bin,
       })
       })
       if (!bin) {
       if (!bin) {
@@ -266,25 +266,25 @@ export namespace LSPServer {
           return
           return
         }
         }
         if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
         if (Flag.OPENCODE_DISABLE_LSP_DOWNLOAD) return
-        log.info("installing ruby-lsp")
+        log.info("installing rubocop")
         const proc = Bun.spawn({
         const proc = Bun.spawn({
-          cmd: ["gem", "install", "ruby-lsp", "--bindir", Global.Path.bin],
+          cmd: ["gem", "install", "rubocop", "--bindir", Global.Path.bin],
           stdout: "pipe",
           stdout: "pipe",
           stderr: "pipe",
           stderr: "pipe",
           stdin: "pipe",
           stdin: "pipe",
         })
         })
         const exit = await proc.exited
         const exit = await proc.exited
         if (exit !== 0) {
         if (exit !== 0) {
-          log.error("Failed to install ruby-lsp")
+          log.error("Failed to install rubocop")
           return
           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,
           bin,
         })
         })
       }
       }
       return {
       return {
-        process: spawn(bin!, ["--stdio"], {
+        process: spawn(bin!, ["--lsp"], {
           cwd: root,
           cwd: root,
         }),
         }),
       }
       }

+ 21 - 21
packages/web/src/content/docs/lsp.mdx

@@ -11,27 +11,27 @@ OpenCode integrates with your Language Server Protocol (LSP) to help the LLM int
 
 
 OpenCode comes with several built-in LSP servers for popular languages:
 OpenCode 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.
 LSP servers are automatically enabled when one of the above file extensions are detected and the requirements are met.