Sources: https://stackoverflow.com/a/78071275 & https://nrogap.medium.com/install-ruby-lsp-in-vs-code-128f02571ea0
Outside your main project, create a folder :
Make sure to install a ruby version >= 3.0.0
with YJIT (I'm using rbenv):
$ RUBY_CONFIGURE_OPTS="--enable-yjit" rbenv install 3.2.2
Add the .ruby-version
file :
3.2.2
Add the Gemfile
file :
# frozen_string_literal: true
source 'https://rubygems.org'
ruby '3.2.2'
gem 'ruby-lsp'
# ...Any other lsp gems you want
Install the gems with bundler
$ bundle install
If you're using rbenv don't forget to run rbenv rehash
Source: https://zed.dev/docs/languages/ruby#configuring-a-language-server
In the directory you have to create a binstub
$ bundle binstubs ruby-lsp
In your Ruby project, create a Zed settings file .zed/settings.json
{
"languages": {
"Ruby": {
"language_servers": ["ruby-lsp", "!solargraph", "!rubocop", "..."]
}
},
"lsp": {
"ruby-lsp": {
"binary": {
"path": "../../path/to/the/directory/bin/ruby-lsp"
}
}
}
}
Install Ruby extension and you're good to go.
Source: https://github.com/Shopify/ruby-lsp/blob/main/vscode/README.md#using-a-custom-gemfile
In your Ruby project, create a VSCode settings file .vscode/settings.json
{
"rubyLsp.bundleGemfile": "../../path/to/the/directory/Gemfile",
}
Install Ruby LSP plugin and restart VSCode.