Skip to content

Instantly share code, notes, and snippets.

@serradura
Last active July 4, 2025 14:38
Show Gist options
  • Save serradura/8b385551092fd3212013a4aebcd891d7 to your computer and use it in GitHub Desktop.
Save serradura/8b385551092fd3212013a4aebcd891d7 to your computer and use it in GitHub Desktop.
How to use Ruby LSP in projects using old Ruby (<3)

1. Install a modern version of Ruby

asdf install ruby 3.4.4

2. Create a ruby-lsp folder in your home directory

mkdir ~/ruby-lsp

3. Access the ruby-lsp folder

cd ~/ruby-lsp

4. Create a .tool-versions file in the ruby-lsp folder

echo "ruby 3.4.4" > .tool-versions

5. Create a Gemfile file in the ruby-lsp folder

source "https://rubygems.org"

ruby "3.4.4"

gem "rubocop"
gem "rubocop-performance"
gem "rubocop-rails"
gem "rubocop-rspec"
gem "rubocop-thread_safety"
gem "ruby-lsp"

6. Install the gems

bundle install

7. Install the ruby-lsp VSCode extension

code --install-extension Shopify.ruby-lsp

8. Update your VSCode user settings with these configs

"rubyLsp.bundleGemfile": "~/ruby-lsp/Gemfile",
"rubyLsp.rubyVersionManager": {
    "identifier": "asdf"
},
"rubyLsp.enabledFeatures": {
    "codeActions": true,
    "diagnostics": true,
    "documentHighlights": true,
    "documentLink": true,
    "documentSymbols": true,
    "foldingRanges": true,
    "formatting": false,
    "hover": true,
    "inlayHint": true,
    "onTypeFormatting": true,
    "selectionRanges": true,
    "semanticHighlighting": true,
    "completion": true,
    "codeLens": true,
    "definition": true,
    "workspaceSymbol": true,
    "signatureHelp": true,
    "typeHierarchy": true
},

9. (Optional) Using a different ruby version manager

If you are using a different ruby version manager, like rbenv. Please update the rubyLsp.rubyVersionManager config to match your version manager. And set .ruby-version file in the ruby-lsp folder with the ruby version you want to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment