Skip to content

Instantly share code, notes, and snippets.

@ongaeshi
Last active August 2, 2021 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ongaeshi/b0bd9f66078b7e40435d9cca13068198 to your computer and use it in GitHub Desktop.
Save ongaeshi/b0bd9f66078b7e40435d9cca13068198 to your computer and use it in GitHub Desktop.

Ruby+VSCode+Windowsで必要最低限の開発環境を整える

基本方針

  • Ruby2.7
    • Ruby3自体は安定しているがgem周りの挙動が若干安定していなかった
  • VSCodeから使える機能
    • Linter (standard)
    • Formatter (rufo, Shift+Alt+F9)
    • Debugger (debase, ruby-debug-ide)
  • コマンドラインから使える機能
    • standardrb --fixで自動修正

Install Ruby

https://rubyinstaller.org/downloads/

  • rubyinstaller-devkit-2.7.4-1-x64.exe
    • インストールに時間がかかりそうだったのでRIのインストールはスキップ

Install Gem

$ gem install -N standard rufo debase ruby-debug-ide

VSCodeの設定

https://github.com/testdouble/standard/wiki/IDE:-vscode

  • Language Serverを有効にする
    • ブロックのfold, unfoldなどが有効になる
  • インテリセンスにrubyLocate
    • F12で定義ジャンプができるようになる
  • Linterはstandard
  • Formatterはrufo
  • Debuggerはdebase ruby-debug-ide

settings.json

{
    "ruby.lint": {
        "standard": true,
    },
    "ruby.format": "rufo",
    "ruby.useLanguageServer": true,
    "[ruby]": {
        "editor.tabSize": 2
    },
    "ruby.languageServer": {
        "logLevel": "info"
    },
    "ruby.intellisense": "rubyLocate",
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment