ruby: Add support for "rubocop" language server (#14661)

Hi, this pull request adds support for `rubocop` language server. I
noticed that `ruby-lsp` LS is becoming more popular but it still lacks
diagnostics support in Zed. To cover that missing feature, it could be
good to use `rubocop` LS to show diagnostics alongside with the running
Ruby LSP.

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
Vitaly Slobodin 2024-07-17 23:29:42 +02:00 committed by GitHub
parent 344e315174
commit 75775292b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 76 additions and 3 deletions

View file

@ -16,7 +16,20 @@ To switch to `ruby-lsp`, add the following to your `settings.json`:
{
"languages": {
"Ruby": {
"language_servers": ["ruby-lsp", "!solargraph", "..."]
"language_servers": ["ruby-lsp", "!solargraph", "!rubocop", "..."]
}
}
}
```
The Ruby extension also provides support for `rubocop` language server for offense detection and autocorrection. To enable it, add the following to your
`settings.json`:
```json
{
"languages": {
"Ruby": {
"language_servers": ["rubocop", "ruby-lsp", "!solargraph", "..."]
}
}
}
@ -83,6 +96,30 @@ Ruby LSP uses pull-based diagnostics which Zed doesn't support yet. We can tell
}
```
## Setting up `rubocop` LSP
Zed currently doesn't install `rubocop` automatically. To use `rubocop`, you need to install the gem. Zed just looks for an executable called `rubocop` on your `PATH`.
You can install the gem manually with the following command:
```shell
gem install rubocop
```
Rubocop has unsafe autocorrection disabled by default. We can tell Zed to enable it by adding the following to your `settings.json`:
```json
{
"lsp": {
"rubocop": {
"initialization_options": {
"safeAutocorrect": false
}
}
}
}
```
## Using the Tailwind CSS Language Server with Ruby
It's possible to use the [Tailwind CSS Language Server](https://github.com/tailwindlabs/tailwindcss-intellisense/tree/HEAD/packages/tailwindcss-language-server#readme) in Ruby and ERB files.