Skip to content

Commit

Permalink
Prevent workspace dependencies from failing on missing bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Feb 2, 2024
1 parent e7dd90b commit 6bd90cb
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions lib/ruby_lsp/executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,7 @@ def run(request)
when "rubyLsp/textDocument/showSyntaxTree"
show_syntax_tree(uri, request.dig(:params, :range))
when "rubyLsp/workspace/dependencies"
dep_keys = Bundler.definition.locked_deps.keys.to_set
Bundler.definition.specs.map do |spec|
{
name: spec.name,
version: spec.version,
path: spec.full_gem_path,
dependency: dep_keys.include?(spec.name),
}
end
workspace_dependencies
else
VOID
end
Expand Down Expand Up @@ -262,6 +254,21 @@ def did_change_watched_files(changes)
VOID
end

def workspace_dependencies
definition = Bundler.definition
dep_keys = definition.locked_deps.keys.to_set
definition.specs.map do |spec|
{
name: spec.name,
version: spec.version,
path: spec.full_gem_path,
dependency: dep_keys.include?(spec.name),
}
end
rescue Bundler::GemfileNotFound
[]
end

sig { void }
def perform_initial_indexing
# The begin progress invocation happens during `initialize`, so that the notification is sent before we are
Expand Down

0 comments on commit 6bd90cb

Please sign in to comment.