Skip to content

Commit

Permalink
Update to work with latest ruby-lsp changes
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Mar 30, 2024
1 parent e21b791 commit c7b77d2
Show file tree
Hide file tree
Showing 13 changed files with 844 additions and 595 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ gem "sorbet-static-and-runtime", platforms: :ruby
gem "tapioca", "~> 0.12", require: false, platforms: :ruby
gem "psych", "~> 5.1", require: false
gem "rails"
gem "ruby-lsp", github: "Shopify/ruby-lsp", branch: "main" # temporary until release
17 changes: 12 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@ GIT
rdoc (6.6.3.1)
psych (>= 4.0.0)

GIT
remote: https://github.com/Shopify/ruby-lsp.git
revision: d33df8ae28d537f93b7fbfaff6e12ddb2598caaa
branch: main
specs:
ruby-lsp (0.15.1)
language_server-protocol (~> 3.17.0)
prism (>= 0.22.0, < 0.25)
sorbet-runtime (>= 0.5.10782)

PATH
remote: .
specs:
ruby-lsp-rails (0.3.3)
actionpack (>= 6.0)
activerecord (>= 6.0)
railties (>= 6.0)
ruby-lsp (>= 0.14.2, < 0.15.0)
ruby-lsp
sorbet-runtime (>= 0.5.9897)

GEM
Expand Down Expand Up @@ -227,10 +237,6 @@ GEM
rubocop (~> 1.51)
rubocop-sorbet (0.8.0)
rubocop (>= 0.90.0)
ruby-lsp (0.14.6)
language_server-protocol (~> 3.17.0)
prism (>= 0.22.0, < 0.25)
sorbet-runtime (>= 0.5.10782)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sorbet (0.5.11305)
Expand Down Expand Up @@ -292,6 +298,7 @@ DEPENDENCIES
rubocop-rake (~> 0.6.0)
rubocop-shopify (~> 2.15)
rubocop-sorbet (~> 0.8)
ruby-lsp!
ruby-lsp-rails!
sorbet-static-and-runtime
sqlite3
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/Gemfile-rails-main
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ gem "sorbet-static-and-runtime", platforms: :ruby
gem "tapioca", "~> 0.11", require: false, platforms: :ruby
gem "psych", "~> 5.1", require: false
gem "rails", github: "rails/rails", branch: "main"

# TODO: remove this entry once the release is done
gem "ruby-lsp", github: "Shopify/ruby-lsp", branch: "main"
15 changes: 8 additions & 7 deletions lib/ruby_lsp/ruby_lsp_rails/addon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ def initialize
@client = T.let(NullClient.new, RunnerClient)
end

sig { override.params(message_queue: Thread::Queue).void }
def activate(message_queue)
$stderr.puts("Activating Ruby LSP Rails addon v#{VERSION}")
sig { override.params(global_state: GlobalState, message_queue: Thread::Queue).void }
def activate(global_state, message_queue)
@global_state = T.let(global_state, T.nilable(RubyLsp::GlobalState))
$stderr.puts("Activating Ruby LSP Rails addon v#{VERSION}") unless ENV["RAILS_ENV"] == "test"
# Start booting the real client in a background thread. Until this completes, the client will be a NullClient
Thread.new { @client = RunnerClient.create_client }
end
Expand All @@ -53,11 +54,11 @@ def create_code_lens_listener(response_builder, uri, dispatcher)
override.params(
response_builder: ResponseBuilders::Hover,
nesting: T::Array[String],
index: RubyIndexer::Index,
dispatcher: Prism::Dispatcher,
).void
end
def create_hover_listener(response_builder, nesting, index, dispatcher)
def create_hover_listener(response_builder, nesting, dispatcher)
index = T.must(@global_state).index
Hover.new(@client, response_builder, nesting, index, dispatcher)
end

Expand All @@ -76,11 +77,11 @@ def create_document_symbol_listener(response_builder, dispatcher)
response_builder: ResponseBuilders::CollectionResponseBuilder[Interface::Location],
uri: URI::Generic,
nesting: T::Array[String],
index: RubyIndexer::Index,
dispatcher: Prism::Dispatcher,
).void
end
def create_definition_listener(response_builder, uri, nesting, index, dispatcher)
def create_definition_listener(response_builder, uri, nesting, dispatcher)
index = T.must(@global_state).index
Definition.new(response_builder, nesting, index, dispatcher)
end

Expand Down
6 changes: 3 additions & 3 deletions lib/ruby_lsp/ruby_lsp_rails/runner_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def initialize
@stdin.binmode # for Windows compatibility
@stdout.binmode # for Windows compatibility

$stderr.puts("Ruby LSP Rails booting server")
$stderr.puts("Ruby LSP Rails booting server") unless ENV["RAILS_ENV"] == "test"
read_response
$stderr.puts("Finished booting Ruby LSP Rails server")
$stderr.puts("Finished booting Ruby LSP Rails server") unless ENV["RAILS_ENV"] == "test"

unless ENV["RAILS_ENV"] == "test"
at_exit do
Expand All @@ -85,7 +85,7 @@ def model(name)

sig { void }
def trigger_reload
$stderr.puts("Reloading Rails application")
$stderr.puts("Reloading Rails application") unless ENV["RAILS_ENV"] == "test"
send_notification("reload")
rescue IncompleteMessageError
$stderr.puts("Ruby LSP Rails failed to trigger reload")
Expand Down
2 changes: 1 addition & 1 deletion ruby-lsp-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ Gem::Specification.new do |spec|
spec.add_dependency("actionpack", ">= 6.0")
spec.add_dependency("activerecord", ">= 6.0")
spec.add_dependency("railties", ">= 6.0")
spec.add_dependency("ruby-lsp", ">= 0.14.2", "< 0.15.0")
spec.add_dependency("ruby-lsp") # TODO: bump, ">= 0.14.2", "< 0.15.0")
spec.add_dependency("sorbet-runtime", ">= 0.5.9897")
end
Loading

0 comments on commit c7b77d2

Please sign in to comment.