First, avoid including editor-specific configuration files in the project.
# .gitignore OR .git/info/exclude
.vscode
Next, prepare a Gemfile for ruby-lsp in the gitignored directory. If .ruby-lsp/Gemfile already exists, you can copy and paste and edit it. In this example, I will introduce a new plugin called ruby-lsp-rspec.
# .vscode/Gemfile
eval_gemfile(
File.expand_path(
'../Gemfile',
__dir__
)
)
group :development do
gem "ruby-lsp", require: false
gem "ruby-lsp-rails", require: false
gem "ruby-lsp-rspec", require: false
end
Finally, change the configuration of ruby-lsp to specify the path to the Gemfile. This may be set from the GUI.
// .vscode/settings.json
{
"rubyLsp.bundleGemfile": ".vscode/Gemfile"
}
Reloading the workspace will reflect the settings; you can also use VSCode's reloadWindow command. Currently, ruby-lsp seems to have a bug that an error occurs if this setting is changed at startup, in which case you can reload it twice.
Top comments (0)