-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Rails support #87
Comments
There are a couple of things you can try.
That should get you closer, but it's still far from perfect. Improving Rails support has been on the roadmap for a while. The amount of runtime magic involved makes it challenging, but I have some updates in the works that should help. |
I hope it's fine if I add my thoughts here. First of all, thanks for your work! I've found this thread after noticing that Solargraph wouldn't know how to handle a goto definition click on |
Hi, any news on this? Is there any dedicated branch for Rails where we could help you to implement it? |
Solargraph's YARD support is at a point where some of the missing Rails intellisense can be filled with a small I'm looking for ways to improve it, including ways to make it easy to install and maintain. Any suggestions are welcome. |
@castwide Using the gist above, it works well in many cases... thank you! However, in the 'activesupport' gem, there is a method |
@mathieushopify It works in circumstances where a type can be inferred: obj = Object.new
obj.b # <= suggests blank?
str = 'str'
str.b # <= suggests blank? If those don't work, make sure you have the latest gem version (0.33.0 was released this morning) and run Completion won't work on on unknown types, which is unfortunately the status of most of the Rails API; for example, completion will suggest |
Makes sense, thanks for the prompt reply! :-) |
@castwide Don't most types inherit from Although the lack of completions it can be a useful indicator that the type is in not inferred. "Some completions" is not always better than "no completions". |
@dgutov Yeah, my personal preference is for undefined types to return no completions instead of assuming If anyone finds it more useful to assume |
Version 0.34.0 introduces some new features that should add some improvements to Rails support. Quick Start
How It Works
Known Issues
|
When you intend to fix this issue?
I think it should go to the correct line. |
@castwide thanks for the update! |
Great stuff! Thanks! |
@castwide can you tell me that if that was an ordinary work or it have an issue?? |
@minkir014 I'm sorry, I don't know what you mean. |
Gem 0.34.1 fixes some issues that occurred in certain bundler environments. |
As I know about go to definition that it must go to a certain line that the class or any other thing is defined and you said
That means that some gems have problems with go to definition. So, when do you intend to fix this issue??? |
@minkir014 I don't know when it will be fixed because I don't even know what the root cause is. When the |
You could file an issue against |
Is there a way to manage models values with Solargraph? |
@tvallois I'm working on a Rails convention that should be able to map model attributes from the database schema. Right now the only other option is to document them yourself, e.g., with the class User < ActiveRecord::Base
# @!attribute id
# @return [Integer]
# @!attribute name
# @return [String]
end |
@castwide Hey, I was thinking of building a script that uses annotations built by annotate gem to add types to models. You said that you're working on something similar? Have you pushed any code towards that? I would like to help and start building it myself if you haven't 👨💻 # == Schema Information
#
# Table name: groups
#
# id :bigint(8) not null, primary key
# name :string
# created_at :datetime not null
# updated_at :datetime not null
# namespace_id :bigint(8) indexed
#
class Group < ApplicationRecord
# @!attribute id
# @return [Integer]
# @!attribute name
# @return [String]
# @!attribute created_at
# @return [Date]
# @!attribute updated_at
# @return [Date]
# @!attribute namespace_id
# @return [Integer]
...
end |
@Zeko369 I don't have anything substantial. If you can build something, that would be awesome. I'm not sure how integration will work yet, but we can worry about those details after we have a working implementation. |
100%. In fact just doing a |
Thanks again @iftheshoefritz! |
I've released v0.3.0 of solargraph-rails which brings Rails 7 support and moves association support into the "non-pre-release" versions. I can see that there are still teething issues with association support, particularly with Rails 7 and (separately) #473, but I would rather have people try this and report bugs than it just live in obscurity. |
Nice. Can't wait to try it! |
Thank you so much for working on this <3 |
Thanks a lot! |
For anyone interested, there's also https://github.com/alisnic/solargraph-arc which seems more feature rich than solargraph-rails. |
I'm pleased to announce that See the changelog here for all the new features that this brings. Also: please create issues for the bugs you find and the features you want over in the solargraph-rails project. Let's make this thing work! |
This is exciting, thank you for your hard work! |
|
@iftheshoefritz after upgrading from
|
Hello,
A lot of the output is just errors and warnings for me. I don't know if that's normal. EDIT: Woah! It suddenly started working for me after messing around so much that I can't even describe what exactly I did that made it start working. I'm just gonna leave it this way and not bother about the |
Edit: There is a PR over at iftheshoefritz/solargraph-rails#49 that should be attempting to fix this now, though looks like there may be some issues still to work through r.e testing before it gets landed. |
In case you haven't seen it, solargraph-rails no longer pins the version of solargraph as of 1.1.0. I can confirm the main features work with 0.48.0, although I admit that experiences like @Samuelodan's ("... error... Woah! It suddenly started working") are something I share and want to improve on. |
Integration with Rails doesn't work for me. I am using neovim with Any updates on how to make Rails work with solargraph at this point in time? |
@nimaai have you tried Shopify/ruby-lsp instead? |
@nimaai Have you tried the command |
@Gasol yes, i have. does rails work for you? what setup and versions of the gems are you using? |
@gastonmorixe yes, i have shortly but requires separate setup from coc which i am using for other filetypes. little messy. also the hover action opens a new buffer instead of a popup. |
@nimaai Yes. I have the same setup just like you using Neovim. Except the one I didn't use Coc.
|
@Gasol thanks. i was missing now i get the diagnostics, but the documentation for the methods etc. is still not being displayed. must have something to do with configuration for btw, what autocomplete plugin are you using for neovim? |
@nimaai I use LazyVim. |
@Gasol Can you please show me your LSP config on LazyVim? I'm using a very similar setup to your but not having the desired result here |
Thank you @Gasol . I was expecting to see some configuration specific to Solargraph (specially w/r/t to its |
I know Rails support is only partial at the moment, but I have installed the Solargraph gem, and am using the VSCode extension, and when I am in a Rails application, I am not getting any Rails-related completions/suggestions whatsoever.
I don't even get a suggestion for the "Rails" class. I just want to make sure I am not getting the wrong end of the stick in terms of what amount of Rails support Solargraph actually has? Solargraph itself is working fine - I am getting standard Ruby suggestions no problem.
The text was updated successfully, but these errors were encountered: