Closed2
VSCodeでRubyの定義ジャンプができなくなった

問題
非推奨になった拡張機能 Ruby - Visual Studio Marketplace のときは、VSCodeのsettings.jsonで Intellisense
を false
から rubyLocate
に変更したら定義ジャンプできていました。
非推奨になったので、乗り換え先として推奨されたShopifyの拡張機能 Ruby - Visual Studio Marketplace をインストールしたら、定義ジャンプができなくなりました。
解決方法
VSCode拡張機能Sorbetの公式Doc:
Extension for Visual Studio Code · Sorbet - Go to Definition/Go to Type Definition/Find all References
公式ドキュメントの通り、VSCodeのステータスバーに Sorbet: Idle
と表示されていることを確認します。Sorbet: Idle
になっていない場合は、ステータスバーをクリックして Enable Sorbet
をクリックします。
Watchmanがインストールされていない場合は、Enable Sorbet
クリック時に以下のエラーが出るので、 brew install watchman
でWatchmanをインストールしてください。
Error running Watchman (with `watchman -j -p --no-pretty`). Watchman is required for Sorbet to detect changes to files made outside of your code editor. Don't need Watchman? Run Sorbet with `--disable-watchman`.
これでCmd + Click, F12, 右クリックなどで定義ジャンプができるようになりました。

VSCode FormatOnSave
.vscode/settings.json
{
"rubyLsp.rubyVersionManager": {
"identifier": "rbenv"
},
"rubyLsp.formatter": "rubocop",
"[ruby]": {
"editor.defaultFormatter": "Shopify.ruby-lsp",
"editor.formatOnSave": true
}
}
このスクラップは2023/11/30にクローズされました