从Visual Studio Code编辑器到IDE的代码示例

93 阅读1分钟

Visual Studio Code本身就是一个功能强大的编辑器,但是通过添加一些扩展,我们可以将其变成一个更智能的IDE。

# Terminal
gem install solargraph
gem install ruby-debug-ide
gem install rubocop
# test/test_helper.rb
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
require 'rails/test_help'

class ActiveSupport::TestCase
  # Run tests in parallel with specified workers
  parallelize(workers: 1)

  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all

  # Add more helper methods to be used by all tests here...
end

.vscode/launch.json

# .vscode/launch.json
{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Rails server",
      "type": "Ruby",
      "request": "launch",
      "program": "${workspaceRoot}/bin/rails",
      "args": [
        "server"
      ]
    }
  ]
}

.rubocop.yml

# .rubocop.yml
Style/Documentation:
  Enabled: false
Style/FrozenStringLiteralComment:
  Enabled: false
Style/EmptyMethod:
  Enabled: false