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

Ruby: Code Completion not working #7819

Closed
1 task done
odedharth opened this issue Feb 15, 2024 · 6 comments
Closed
1 task done

Ruby: Code Completion not working #7819

odedharth opened this issue Feb 15, 2024 · 6 comments
Labels
bug [core label] language An umbrella label for all programming languages syntax behaviors ruby Ruby programming language support

Comments

@odedharth
Copy link

odedharth commented Feb 15, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

Even though code completion is enabled, it's not working for me on any file types that I tested (.rb, .html.erb).

Environment

Zed: v0.122.2 (Zed)
OS: macOS 13.4.0
Memory: 64 GiB
Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

Zed.-.reviews_controller.rb.MDAcne.-.15.February.2024.mp4

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

No response

@odedharth odedharth added admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue labels Feb 15, 2024
@mrnugget
Copy link
Member

Hey! Did you follow the instructions here to install solargraph manually? https://github.com/zed-industries/zed/blob/main/docs/src/languages/ruby.md#setup

@mrnugget mrnugget changed the title Code Completion not working Ruby: Code Completion not working Feb 15, 2024
@mrnugget mrnugget added the ruby Ruby programming language support label Feb 15, 2024
@odedharth
Copy link
Author

Hey @mrnugget,

I just installed Solargraph and I see there are some auto-completions now, but it's still not properly auto-completing:

  1. Variable names. For example in the video below, you can see it didn't complete "@products".
  2. All functions. For example in the video below, you can see it's not completing the most common model functions such as "find" and "where.

See here:

Zed.-.flow_controller.rb.MDAcne.-.15.February.2024.mp4

@mrnugget
Copy link
Member

  1. Variable names. For example in the video below, you can see it didn't complete "@products".

Yeah, that's a bug on our side, I think. I saw solargraph returning that completion but us throwing it away.

2. All functions. For example in the video below, you can see it's not completing the most common model functions such as "find" and "where.

That matches what solargraph extension in VS Code does, though. So I think something like https://github.com/iftheshoefritz/solargraph-rails might be the solution here? Although I haven't tried that yet.

@odedharth
Copy link
Author

  1. Got it, yes, I just noticed that as well, it looks like a bug.
  2. I just installed solargraph-rails and followed the instructions adding it to .solargraph.yml, but it still doesn't work.

mrnugget added a commit that referenced this issue Feb 15, 2024
In Ruby `_$=@!:?` can all be part of an identifier. If we don't have them
in this list, autocomplete doesn't work as expected.

See: https://gist.github.com/misfo/1072693

This fixes one part of #7819 but not the whole ticket.
@mrnugget
Copy link
Member

  1. Got it, yes, I just noticed that as well, it looks like a bug.

Alright, I got a fix for this here: #7824

  1. I just installed solargraph-rails and followed the instructions adding it to .solargraph.yml, but it still doesn't work.

Same here. I also couldn't get it to work in VS Code. I do have some ideas for how we could make launching language-servers more reliable, but this seems like we first need to find out how to get solargraph running in Rails.

mrnugget added a commit that referenced this issue Feb 15, 2024
In Ruby `_$=@!:?` can all be part of an identifier. If we don't have
them in this list, autocomplete doesn't work as expected.

See: https://gist.github.com/misfo/1072693

This fixes one part of #7819 but not the whole ticket.

Release Notes:

- Fixed completions in Ruby not working for identifiers that start or
end with special characters (e.g.: `@`)
@JosephTLyons JosephTLyons added language An umbrella label for all programming languages syntax behaviors and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Feb 15, 2024
mrnugget added a commit that referenced this issue Mar 11, 2024
…Ruby word chars (#9170)

This fixes #9069 by

1. reverting #7819 
2. fixing completion filtering with regards to word boudaries

For (2) see explanation in commit message:

> Previously, this would only split words on upper-lower boundaries or
> on `_`/`-`.
> 
> The result was that we would filter out completions too aggressively.
> The filter works by taking a suggested completion, say `foo_bar_lol`,
split
> it up into words - `foo`, `bar, `lol` - and check whether any of the
words
> start with the same characters as what the user already typed: `fo`,
or `bar`,
> ...
> 
> In the case of Ruby, though, `:` wasn't considered a word boundary. If
the
> LSP would return `:foobar` when the user typed `:foo`, we'd check if
there are
> any completions that match `foo` (because that's the current word) but
> we'd compare against `foobar`, not `:` or `:foobar`.
> 
> With this change, we get more match candidates and thus more
completions in Ruby.

With that we can do (1) because we don't need these characters as word
characters anymore to trigger completions.

Release Notes:

- Fixed word boundaries in Ruby by restoring old behavior (`@`, `:`, ...
are no longer considered word characters)
([#9069](#9069))
- Fixed completions being filtered out when they happened at word
boundaries on special characters (e.g. `:`)

---------

Co-authored-by: Max <[email protected]>
@mrnugget
Copy link
Member

I'm going to close this because I think it's fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] language An umbrella label for all programming languages syntax behaviors ruby Ruby programming language support
Projects
None yet
Development

No branches or pull requests

3 participants