Closed4
ruby-lspでrubocopを使いたい。でも、プロジェクトのGemfileは汚したくない時
VS Codeでの利用を想定している。
ちょっと試行錯誤したので、メモを残しておく。
rubyはパスが通っていてどこでも実行できる前提。
拡張機能の概要 の、Using a custom Gemfile を設定すればOK。
どこか適当な場所に、ディレクトリを用意する。
pwd /Users/foo
mkdir ruby-lsp
Gemfileを生成する
touch Gemfile
Gemfileに下記を記述する
source "https://rubygems.org"
gem "ruby-lsp"
gem "rubocop"
gem "rubocop-packaging"
gem "rubocop-performance"
gem "rubocop-rspec"
gem "rubocop-shopify"
gem "rubocop-thread_safety"
bundle install実施
bundle install
VS Codeに下記の拡張機能をインストール。
VS Codeのsetting.jsonを開いて、下記を追記する。
"rubyLsp.bundleGemfile": "/Users/foo/ruby-lsp/Gemfile",
ホームディレクトリ配下に、.rubocop.yml ファイルを用意しておけばそれも読み取ってくれる。
このスクラップは4ヶ月前にクローズされました