Skip to content
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

Add completion for require relative #1211

Closed
vinistock opened this issue Nov 24, 2023 · 2 comments · Fixed by #1403
Closed

Add completion for require relative #1211

vinistock opened this issue Nov 24, 2023 · 2 comments · Fixed by #1403
Assignees
Labels
enhancement New feature or request good-first-issue Good for newcomers pinned This issue or pull request is pinned and won't be marked as stale

Comments

@vinistock
Copy link
Member

We currently have completion for regular requires, which search the indexed files based on require paths. We can also provide require_relative completion, which would be a nice improvement.

I think the implementation would be something like this:

  • First, refactor the current completion so that we're handling CallNode instead of StringNode
    def on_string_node_enter(node)
  • Then, check if the method call is require and execute the current implementation
  • If it's require_relative, then we want to
    • Expand the path given as argument. For example, if we have require_relative "../something/", we need to expand it to the absolute path using Pathname
    • After we have the absolute path, we need to list all Ruby files available that path to provide as completion suggestions. Likely doing something along the lines of Dir.glob("#{absolute_path}/**/*.rb")
@vinistock vinistock added enhancement New feature or request good-first-issue Good for newcomers pinned This issue or pull request is pinned and won't be marked as stale labels Nov 24, 2023
@namrata18s
Copy link

hi @vinistock , can I work on this issue?

@vinistock
Copy link
Member Author

Of course! Assigning it to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good-first-issue Good for newcomers pinned This issue or pull request is pinned and won't be marked as stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants