Switch from solargraph to ruby-lsp
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-lspinstallation (if it's in$PATHwe will use it) - Some completions (in
require "..."statements for example). Butruby-lspdoes not offer a lot of the completions we know from other language servers: https://github.com/microsoft/vscode-languageserver-node/issues/1342 Instead, thevscode-ruby-lspextension makes heavy use oftextDocument/documentSymbols, which we do not support yet. - Some jump-to-definitions. It works for class and module names and constants. But
ruby-lspdoesn't reply with atextDocument/definitionin 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
rubocopin their gemfile)
What doesn't work:
- ~file updates. We do send
textDocument/didChangemessages on change, but when I add a new class to a document and then reference it atextDocument/definitionrequest gets an empty response. But after a restart it works.~ works now - diagnostics.
ruby-lspuses pull-based diagnostics (client requests from server when to show diagnostics, vs. server pushing to client). - document symbol completions. It works in
vscode-ruby-lspbecause VS Code falls back todocumentSymbolscompletion 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:
- Added/Fixed/Improved ... (#<public_issue_number_if_exists>).
Optionally, include screenshots / media showcasing your addition that can be included in the release notes.
or
- N/A
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?
@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
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.
ruby-lsp was added as an available language server in https://github.com/zed-industries/zed/pull/11768.