1
0

More than 1 year has passed since last update.

【VSCode】Solargraphの導入【Ruby】

Posted at

拡張機能をインストールする

solargaphの拡張機能をVSCodeにインストールします。

gemをインストールする

solargraphをグローバルインストールする場合には以下のとおりインストールします。

ターミナル
$ gem install solargraph

# グローバルなgemのdocumentを生成。
$ yard gems

bundle execしないようにsettings.jsonに以下のように記述します。

settings.json
"solargraph.useBundler": false

bundlerでinstallする場合には以下のとおりインストールします。

Gemfile
group :development do
  gem "solargraph"
end
$ bundle install

# プロジェクトにインストールしているgemのdocumentを生成
$ bundle exec yard gems

bundle execしないようにsettings.jsonは以下のように記述します。

setting.json
"solargraph.useBundler": true

また、rubocopを使用してファイル保存時にフォーマットしたい場合には以下のように記述します。
solargraph.useBundlerはインストール方法に合わせて変更してください。

setting.json
{ 
  "editor.defaultFormatter": "castwide.solargraph",
  "solargraph.useBundler": true, 
  "solargraph.diagnostics": true,
  "solargraph.formatting": true,
}

設定ファイルを作成

以下のコマンドを実行してsolargraphの設定ファイルを作成します。

ターミナル
$ solargraph config .

設定の詳細については以下のページをご参照ください。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0