Skip to content

Commit

Permalink
Start accepting initialize request and setup error as part of server …
Browse files Browse the repository at this point in the history
…instantiation
  • Loading branch information
vinistock committed Oct 22, 2024
1 parent 3d365bd commit 3d2fb25
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/ruby_lsp/base_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ class BaseServer

abstract!

sig { params(options: T::Boolean).void }
sig { params(options: T.untyped).void }
def initialize(**options)
@test_mode = T.let(options[:test_mode], T.nilable(T::Boolean))
@setup_error = T.let(options[:setup_error], T.nilable(StandardError))
@writer = T.let(Transport::Stdio::Writer.new, Transport::Stdio::Writer)
@reader = T.let(Transport::Stdio::Reader.new, Transport::Stdio::Reader)
@incoming_queue = T.let(Thread::Queue.new, Thread::Queue)
Expand All @@ -33,6 +34,11 @@ def initialize(**options)

@global_state = T.let(GlobalState.new, GlobalState)
Thread.main.priority = 1

# We read the initialize request in `exe/ruby-lsp` to be able to determine the workspace URI where Bundler should
# be setup
initialize_request = options[:initialize_request]
process_message(initialize_request) if initialize_request
end

sig { void }
Expand Down
12 changes: 12 additions & 0 deletions lib/ruby_lsp/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@ def run_initialize(message)
begin_progress("indexing-progress", "Ruby LSP: indexing files")

global_state_notifications.each { |notification| send_message(notification) }

if @setup_error
message = <<~MESSAGE
An error occurred while setting up Bundler. This may be due to a failure when installing dependencies.
The Ruby LSP will continue to run, but features related to the missing dependencies will not be available.
Error:
#{@setup_error.full_message}
MESSAGE

send_message(Notification.window_log_message(message, type: Constant::MessageType::ERROR))
end
end

sig { void }
Expand Down

0 comments on commit 3d2fb25

Please sign in to comment.