Skip to content

Improve support for hovering over a gem in Gemfile #3344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andyw8
Copy link
Contributor

@andyw8 andyw8 commented Mar 22, 2025

Motivation

Currently you can hover over an entry in the Gemfile to reveal information about a gem, but this works only for the gem call and not the string containing the gem name.

Implementation

Added behaviour to the on_string_node_enter callback.

Automated Tests

Included

Manual Tests

Can be verified with Ruby LSP's own Gemfile, using this branch.

Copy link

graphite-app bot commented Mar 22, 2025

How to use the Graphite Merge Queue

Add the label graphite-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@@ -92,6 +92,14 @@ def initialize(response_builder, global_state, uri, node_context, dispatcher, so

#: (Prism::StringNode node) -> void
def on_string_node_enter(node)
if @path && File.basename(@path) == GEMFILE_NAME
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same check as in on_call_node_enter. It could be extracted out, e.g. is_gemfile?.

@andyw8 andyw8 marked this pull request as ready for review March 22, 2025 18:41
@andyw8 andyw8 requested a review from a team as a code owner March 22, 2025 18:41
@andyw8 andyw8 force-pushed the andyw8/gemfile-hover-over-name branch from a5fb4df to fd32e5d Compare March 22, 2025 22:35
@andyw8 andyw8 force-pushed the andyw8/gemfile-hover-over-name branch from fd32e5d to f1de537 Compare March 22, 2025 22:47
source = <<~RUBY
gem 'rake'
RUBY

# We need to pretend that Sorbet is not a dependency or else we can't properly test
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, I think these were leftover from a copy and paste.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant