zed icon indicating copy to clipboard operation
zed copied to clipboard

Switch from solargraph to ruby-lsp

Open mrnugget opened this issue 1 year ago • 3 comments

This PR changes the default Ruby language server from solargraph to ruby-lsp.

As of right now, it boots up successfully and it works to a certain degree: it gives completions for constants.

What works:

  • auto-detection of ruby-lsp installation (if it's in $PATH we will use it)
  • Some completions (in require "..." statements for example). But ruby-lsp does not offer a lot of the completions we know from other language servers: https://github.com/microsoft/vscode-languageserver-node/issues/1342 Instead, the vscode-ruby-lsp extension makes heavy use of textDocument/documentSymbols, which we do not support yet.
  • Some jump-to-definitions. It works for class and module names and constants. But ruby-lsp doesn't reply with a textDocument/definition in a lot of cases (local vars, methods, ...). VS Code has a lot of fallbacks implemented for that: we think it looks at the document symbols to find a possible definition and use that if it doesn't get a reply
  • Formatting (if the project has rubocop in their gemfile)

What doesn't work:

  • ~file updates. We do send textDocument/didChange messages on change, but when I add a new class to a document and then reference it a textDocument/definition request gets an empty response. But after a restart it works.~ works now
  • diagnostics. ruby-lsp uses pull-based diagnostics (client requests from server when to show diagnostics, vs. server pushing to client).
  • document symbol completions. It works in vscode-ruby-lsp because VS Code falls back to documentSymbols completion when there are no completions returned from LSP.

So, in essence: it starts, it works (except for file watching and diagnostics), but it doesn't feel like in VS Code, mainly because (a) we don't support the fallbacks that VS Code uses (look at document symbols if no completions are provided) and (b) we don't support diagnostics.

Release Notes:

Optionally, include screenshots / media showcasing your addition that can be included in the release notes.

or

  • N/A

mrnugget avatar Feb 29 '24 15:02 mrnugget

ruby-lsp just released(twitter link) first iteration in the direction of supporting go to definition for methods. I was wondering if it means it will work in zed as well?

Vagab avatar Apr 25 '24 17:04 Vagab

@mrnugget (or anyone else interested in ruby-lsp support):

Ruby support was just moved out into an extension in https://github.com/zed-industries/zed/pull/11360.

As part of this, we can now provide both solargraph and ruby-lsp and allow selecting which one to use via the language_servers setting. The Ruby extension is already structured in such a way that it should be easy to add in ruby-lsp.

There's prior art in the Elixir extension that can be referred to: https://github.com/zed-industries/zed/blob/400e938997029e2c4fa943a43a7a3b3af1134b78/extensions/elixir/src/elixir.rs

maxdeviant avatar May 10 '24 16:05 maxdeviant

Okay, I can add it then and people can chose which one they want to use and then we can make support better, bit by bit.

mrnugget avatar May 11 '24 06:05 mrnugget

ruby-lsp was added as an available language server in https://github.com/zed-industries/zed/pull/11768.

maxdeviant avatar May 13 '24 21:05 maxdeviant