Ruby
Rails
RSpec
RuboCop
VSCode
0

VSCodeでRuby On Railsを快適に書きたい

VSCodeでRuby On Railsを快適に書くために行っている設定。1
現在いろいろ模索中なので、アドバイスあればコメント下さい:bow_tone1:

定義へのジャンプや補完機能などなどは実現できています。

Ruby/Rails専用の拡張機能

Ruby

強力。必須。
ドキュメントに従って各種gemを入れれば一通りそろう!!

endwise

自動でendを挿入してくれる
endwise_gif

ruby-rubocop

ファイル保存のタイミングでrubocopを自動で走らせることができる
ruby_rubocop_gif

Rails

Rails用のスニペットやナビゲーションなどを提供してくれる
rails_gif

Rails Run Specs

開いているspecファイルや直近のテストをパッと実行できる。
直近のを即再実行できるの大事。

Rails Go to Spec

specファイルへの移動をショートカットできる

ruby-symbols

シンボルの自動補完をしてくれる

Slim

Slimファイルを使っているので。ERBの人はそっちを。

Ruby専用の設定

Rubyのみに適応するためには、以下の {}内に設定項目を追加すればOKです。

"[ruby]": {
},

タブのサイズ

"editor.tabSize": 2

その他

今のところ、タブサイズ以外はデフォルトのままです。
設定ファイルの検索で「ruby」と打つと、↓のようにたくさんあります。


   // Filepath to the configuration file for Rubocop
  "ruby.rubocop.configFilePath": "",

  // execution path of rubocop.
  "ruby.rubocop.executePath": "",

  // execute rubocop on save.
  "ruby.rubocop.onSave": true,

  // Defines if it should clear the terminal on each spec run
  "ruby.specClearTerminal": true,

  // Defines a custom command to run for specs (i.e. 'spring rspec')
  "ruby.specCommand": "",

  // Defines if it should focus on terminal on each spec run
  "ruby.specFocusTerminal": true,

  // Defines the type of tool used for testing
  "ruby.specGem": "rspec",

  // Defines the pattern for seaching test files
  "ruby.specPattern": "spec",

  // Auto Save file before running spec test
  "ruby.specSaveFile": false,

  // Zeus gem needs a certain time to start. Defined in ms
  "ruby.zeusStartTimeout": 2000,

  // Method to use for code completion. Use `false` to disable or if another extension provides this feature.
  "ruby.codeCompletion": false,

  // Which system to use for formatting. Use `false` to disable or if another extension provides this feature.
  "ruby.format": false,

  // Method to use for intellisense (go to definition, etc.). Use `false` to disable or if another extension provides this feature.
  "ruby.intellisense": false,

  // Path to the Ruby interpreter.  Set this to an absolute path to select from multiple installed Ruby versions.
  "ruby.interpreter.commandPath": "ruby",

  // Set individual ruby linters to use
  "ruby.lint": {},

  // Time (ms) to wait after keypress before running enabled linters. Ensures linters are only run when typing has finished and not for every keypress
  "ruby.lintDebounceTime": 500,

  // Defines where the Ruby extension will look to find Modules, Classes and methods.
  "ruby.locate": {
    "exclude": "{**/@(test|spec|tmp|.*),**/@(test|spec|tmp|.*)/**,**/*_spec.rb}",
    "include": "**/*.rb"
  },

  // Path to the bundler executable (used if useBundler is true)
  "ruby.pathToBundler": "bundle",

  // Path to the rct-complete command.  Set this to an absolute path to select from multiple installed Ruby versions.
  "ruby.rctComplete.commandPath": "rct-complete",

  // Whether ruby tools should be started using Bundler
  "ruby.useBundler": false

  1. 汎用的なオススメの拡張機能はこちらを参照して下さい