今までVSCodeでRubyを使うときにはrebornix.ruby
を使うことが多かったと思うのですが、
現状は非推奨となっており、
Shopify's ruby-lsp and associated vscode-ruby-lsp are recommended alternatives to this extension. It is substantially easier to produce a high-quality LSP implementation using Ruby itself vs relying on another language such as TypeScript. GitHub - rubyide/vscode-ruby: Provides Ruby language and debugging support for Visual Studio Code
推奨されているshopify.ruby-lsp
に乗り換えてみたのでメモ📝
乗り換えは簡単でVSCodeの拡張機能からinstallした後にGemfileにruby-lsp
を追加してbundle installすれば大丈夫でした🙆♂️
group :development do gem "ruby-lsp"
Gemfileに入れないとエラーになったのでGemfileに入れましたが、公式のReadme的には起動時に.ruby-lsp
配下にGemfileが追加されてよしなに利用されるため不要なようです。(自分はなぜか動かなかった・・・)
NOTE: starting with v0.7.0, it is no longer recommended to add the ruby-lsp to the bundle. The gem will generate a custom bundle in .ruby-lsp/Gemfile which is used to identify the versions of dependencies that should be used for the application (e.g.: the correct RuboCop version).
GitHub - Shopify/ruby-lsp: An opinionated language server for Ruby
あとは私はrubocopじゃなくてstarndardrbを利用しているのですが、Ruby LSPが出すrubocopの警告は不要のためdiagnostics
をfalse
にしました。
"rubyLsp.enabledFeatures": { "diagnostics": false,
これでいい感じにコードジャンプ等が動くようになりました💎
あとrails用のもあるらしい。
ShopfyこういったRubyの基盤的な技術もOSSで提供してくれていてありがたい🙏
参考)