From 9ddde17ea56e5d14d6f96f042c06a990f29cf26e Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Fri, 2 Aug 2024 02:18:10 -0400 Subject: [PATCH] Add vscode Ruby LSP config and documentation --- .devcontainer/devcontainer.json | 3 +-- .devcontainer/ubuntu18.04/devcontainer.json | 3 +-- .gitignore | 2 ++ .vscode/extensions.json | 3 +-- .vscode/settings.json | 13 +++++++++++-- Library/Homebrew/Gemfile | 3 +++ Library/Homebrew/Gemfile.lock | 9 +++++++++ Library/Homebrew/vendor/bundle/bundler/setup.rb | 4 ++++ 8 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0c51923f88071..1e51053a73ff4 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -14,8 +14,7 @@ // Taken from: .vscode/extensions.json "extensions": [ "kaiwood.endwise", - "lorankloeze.ruby-rubocop-revived", - "rebornix.ruby", + "Shopify.ruby-lsp", "sorbet.sorbet-vscode-extension", "github.vscode-github-actions", "timonwong.shellcheck", diff --git a/.devcontainer/ubuntu18.04/devcontainer.json b/.devcontainer/ubuntu18.04/devcontainer.json index e2f96d8f5e1c1..d9363db75cb4b 100644 --- a/.devcontainer/ubuntu18.04/devcontainer.json +++ b/.devcontainer/ubuntu18.04/devcontainer.json @@ -14,8 +14,7 @@ // Taken from: .vscode/extensions.json "extensions": [ "kaiwood.endwise", - "lorankloeze.ruby-rubocop-revived", - "rebornix.ruby", + "Shopify.ruby-lsp", "sorbet.sorbet-vscode-extension", "github.vscode-github-actions", "timonwong.shellcheck", diff --git a/.gitignore b/.gitignore index f34c6de65f79d..63ef5b980b1f8 100644 --- a/.gitignore +++ b/.gitignore @@ -107,6 +107,7 @@ **/vendor/bundle/ruby/*/gems/racc-*/ **/vendor/bundle/ruby/*/gems/rainbow-*/ **/vendor/bundle/ruby/*/gems/rbi-*/ +**/vendor/bundle/ruby/*/gems/rbs-*/ **/vendor/bundle/ruby/*/gems/rdoc-*/ **/vendor/bundle/ruby/*/gems/redcarpet-*/ **/vendor/bundle/ruby/*/gems/regexp_parser-*/ @@ -120,6 +121,7 @@ **/vendor/bundle/ruby/*/gems/rspec-support-*/ **/vendor/bundle/ruby/*/gems/rspec-sorbet-*/ **/vendor/bundle/ruby/*/gems/rubocop-*/ +**/vendor/bundle/ruby/*/gems/ruby-lsp-*/ **/vendor/bundle/ruby/*/gems/ruby-prof-*/ **/vendor/bundle/ruby/*/gems/ruby-progressbar-*/ **/vendor/bundle/ruby/*/gems/simplecov-*/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 21ae97330824d..93789d0339e4b 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,8 +1,7 @@ { "recommendations": [ "kaiwood.endwise", - "lorankloeze.ruby-rubocop-revived", - "rebornix.ruby", + "Shopify.ruby-lsp", "sorbet.sorbet-vscode-extension", "github.vscode-github-actions", "timonwong.shellcheck", diff --git a/.vscode/settings.json b/.vscode/settings.json index 1be39bef3d945..12a50f740dc2f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,8 +6,17 @@ "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true, "files.trimFinalNewlines": true, - "ruby.useLanguageServer": true, - "ruby.rubocop.executePath": "Library/Homebrew/shims/gems/", + "rubyLsp.rubyVersionManager": { + "identifier": "custom" + }, + "rubyLsp.customRubyCommand": "PATH=${workspaceFolder}/Library/Homebrew/vendor/portable-ruby/current/bin:$PATH", + "rubyLsp.bundleGemfile": "Library/Homebrew/Gemfile", + "rubyLsp.formatter": "rubocop", + "[ruby]": { + "editor.defaultFormatter": "Shopify.ruby-lsp", + "editor.formatOnSave": true, + "editor.semanticHighlighting.enabled": true, + }, "shellcheck.customArgs": [ "--shell=bash", "--enable=all", diff --git a/Library/Homebrew/Gemfile b/Library/Homebrew/Gemfile index 5a18416398586..03ca1d6111508 100644 --- a/Library/Homebrew/Gemfile +++ b/Library/Homebrew/Gemfile @@ -67,6 +67,9 @@ group :typecheck, optional: true do gem "spoom", require: false gem "tapioca", require: false end +group :vscode, optional: true do + gem "ruby-lsp", require: false +end # shared gems (used by multiple groups) group :audit, :bump_unversioned_casks, :livecheck, optional: true do diff --git a/Library/Homebrew/Gemfile.lock b/Library/Homebrew/Gemfile.lock index f692de352fff3..5b909c1706015 100644 --- a/Library/Homebrew/Gemfile.lock +++ b/Library/Homebrew/Gemfile.lock @@ -25,6 +25,7 @@ GEM kramdown (2.4.0) rexml language_server-protocol (3.17.0.3) + logger (1.6.0) method_source (1.1.0) minitest (5.24.1) netrc (0.11.0) @@ -52,6 +53,8 @@ GEM rbi (0.1.14) prism (>= 0.18.0, < 1.0.0) sorbet-runtime (>= 0.5.9204) + rbs (3.5.2) + logger redcarpet (3.6.0) regexp_parser (2.9.2) rexml (3.3.4) @@ -99,6 +102,11 @@ GEM rubocop (~> 1.61) rubocop-sorbet (0.8.5) rubocop (>= 1) + ruby-lsp (0.17.10) + language_server-protocol (~> 3.17.0) + prism (>= 0.29.0, < 0.31) + rbs (>= 3, < 4) + sorbet-runtime (>= 0.5.10782) ruby-macho (4.1.0) ruby-prof (1.7.0) ruby-progressbar (1.13.0) @@ -177,6 +185,7 @@ DEPENDENCIES rubocop-performance rubocop-rspec rubocop-sorbet + ruby-lsp ruby-macho ruby-prof ruby-progressbar diff --git a/Library/Homebrew/vendor/bundle/bundler/setup.rb b/Library/Homebrew/vendor/bundle/bundler/setup.rb index 6b3d949ebe79b..8ee7c8f6a20c7 100644 --- a/Library/Homebrew/vendor/bundle/bundler/setup.rb +++ b/Library/Homebrew/vendor/bundle/bundler/setup.rb @@ -58,6 +58,7 @@ def self.extension_api_version $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rexml-3.3.4/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/kramdown-2.4.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/language_server-protocol-3.17.0.3/lib") +$:.unshift File.expand_path("#{__dir__}/../../portable-ruby/3.3.4/lib/ruby/gems/3.3.0/gems/logger-1.6.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/method_source-1.1.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/minitest-5.24.1/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/netrc-0.11.0/lib") @@ -75,6 +76,8 @@ def self.extension_api_version $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/prism-0.30.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/pry-0.14.2/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rbi-0.1.14/lib") +$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/arm64-darwin-20/#{Gem.extension_api_version}/rbs-3.5.2") +$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rbs-3.5.2/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/arm64-darwin-20/#{Gem.extension_api_version}/redcarpet-3.6.0") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/redcarpet-3.6.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rspec-support-3.13.1/lib") @@ -94,6 +97,7 @@ def self.extension_api_version $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-performance-1.21.1/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rspec-3.0.3/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-sorbet-0.8.5/lib") +$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-lsp-0.17.10/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-macho-4.1.0/lib") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/arm64-darwin-20/#{Gem.extension_api_version}/ruby-prof-1.7.0") $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-prof-1.7.0/lib")