-
Notifications
You must be signed in to change notification settings - Fork 178
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
Go to definition not working with custom Gemfile #1706
Comments
Thank you for the report. When say, "doesn't work most of the time", are you talking about go to definition for methods? We haven't finished adding support for methods yet (#899). However, it should be working properly for classes, modules and constants. Are you able to go to definition on those? Also, you can always find details about our supported features in the documentation. |
Thanks for your answer, @vinistock. Yes, I was mostly talking about go to definition for methods, although I've found some unexpected behavior (for me, of course) with some classes/modules. I need to check it again so I can provide with some examples. Anyway, I've checked the list of supported features included in the documentation link you provided and I can confirm that completion doesn't work for me with code such as the one in the image (obviously requiring classes from my project): Additionally, I'd like to confirm some details:
|
I don't understand what's not working on that GIF. Completion is showing all classes available in the LOAD_PATH. You're seeing results from gems and standard libraries that are present in the LOAD_PATH. Do you mean that you expected to only see results for the one file you required? If that's the case, that is really hard to do in Ruby. Requiring any file makes all constants defined in it available globally everywhere in the project. To accurately determine if a constant is present in an exact point in the code would require typechecking the entire codebase in the exact order files are required - which would most definitely be extremely slow. We might be able to do better sorting of the completion results. Are you looking for constants defined in your app and then finding gem results appear before them?
Not yet. We still need to add support for those, which will likely require our indexer to consume RBS files so that we know which declarations exist in C code.
Because you're using a custom Gemfile. In that case, there's no need to create the |
Sorry, I didn't make myself clear. Let me show you what is currently present in my LOAD_PATH, inside the Docker container where my code is running: (hanami console) puts $LOAD_PATH
/usr/app/lib
/usr/local/bundle/gems/bundler-2.4.22/lib
/usr/local/bundle/gems/rubocop-rspec-2.25.0/lib
/usr/local/bundle/gems/rubocop-performance-1.19.1/lib
/usr/local/bundle/gems/rubocop-factory_bot-2.24.0/lib
/usr/local/bundle/gems/rubocop-capybara-2.19.0/lib
/usr/local/bundle/gems/rubocop-1.57.2/lib
/usr/local/bundle/gems/unicode-display_width-2.5.0/lib
/usr/local/bundle/gems/ruby-progressbar-1.13.0/lib
/usr/local/bundle/gems/rubocop-ast-1.30.0/lib
/usr/local/bundle/gems/rom-sql-3.6.1/lib
/usr/local/bundle/gems/rom-factory-0.11.0/lib
/usr/local/bundle/gems/rom-5.3.0/lib
/usr/local/bundle/gems/rom-repository-5.3.0/lib
/usr/local/bundle/gems/rom-changeset-5.3.0/lib
/usr/local/bundle/gems/rom-core-5.3.0/lib
/usr/local/bundle/gems/transproc-1.1.1/lib
/usr/local/bundle/gems/rexml-3.2.6/lib
/usr/local/bundle/gems/regexp_parser-2.8.2/lib
/usr/local/bundle/gems/rainbow-3.1.1/lib
/usr/local/bundle/gems/rack-test-2.1.0/lib
/usr/local/bundle/gems/pg-1.5.4/lib
/usr/local/bundle/extensions/x86_64-linux-musl/3.2.0/pg-1.5.4
/usr/local/bundle/gems/parser-3.2.2.4/lib
/usr/local/bundle/gems/racc-1.7.3/lib
/usr/local/bundle/extensions/x86_64-linux-musl/3.2.0/racc-1.7.3
/usr/local/bundle/gems/parallel-1.23.0/lib
/usr/local/bundle/gems/language_server-protocol-3.17.0.3/lib
/usr/local/lib/ruby/gems/3.2.0/gems/json-2.6.3/lib
/usr/local/lib/ruby/gems/3.2.0/extensions/x86_64-linux-musl/3.2.0/json-2.6.3
/usr/local/bundle/gems/hanami-validations-2.0.1/lib
/usr/local/bundle/gems/hanami-rspec-2.0.1/lib
/usr/local/bundle/gems/rspec-3.12.0/lib
/usr/local/bundle/gems/rspec-mocks-3.12.6/lib
/usr/local/bundle/gems/rspec-expectations-3.12.3/lib
/usr/local/bundle/gems/rspec-core-3.12.2/lib
/usr/local/bundle/gems/rspec-support-3.12.1/lib
/usr/local/bundle/gems/hanami-router-2.0.2/lib
/usr/local/bundle/gems/mustermann-contrib-3.0.0/lib
/usr/local/bundle/gems/hansi-0.2.1/lib
/usr/local/bundle/gems/mustermann-3.0.0/lib
/usr/local/lib/ruby/gems/3.2.0/gems/ruby2_keywords-0.0.5/lib
/usr/local/bundle/gems/hanami-reloader-2.0.2/lib
/usr/local/bundle/gems/hanami-controller-2.0.2/lib
/usr/local/bundle/gems/rack-2.2.8/lib
/usr/local/bundle/gems/hanami-2.0.3/lib
/usr/local/bundle/gems/hanami-utils-2.0.3/lib
/usr/local/bundle/gems/hanami-cli-2.0.3/lib
/usr/local/bundle/gems/guard-puma-0.8.1/lib
/usr/local/bundle/gems/puma-6.4.0/lib
/usr/local/bundle/extensions/x86_64-linux-musl/3.2.0/puma-6.4.0
/usr/local/bundle/gems/nio4r-2.5.9/lib
/usr/local/bundle/extensions/x86_64-linux-musl/3.2.0/nio4r-2.5.9
/usr/local/bundle/gems/guard-compat-1.2.1/lib
/usr/local/bundle/gems/guard-2.18.1/lib
/usr/local/bundle/gems/thor-1.3.0/lib
/usr/local/bundle/gems/pry-0.14.2/lib
/usr/local/bundle/gems/method_source-1.0.0/lib
/usr/local/bundle/gems/notiffany-0.1.3/lib
/usr/local/bundle/gems/shellany-0.0.1/lib
/usr/local/bundle/gems/nenv-0.3.0/lib
/usr/local/bundle/gems/lumberjack-1.2.9/lib
/usr/local/bundle/gems/listen-3.8.0/lib
/usr/local/bundle/gems/rb-inotify-0.10.1/lib
/usr/local/bundle/gems/rb-fsevent-0.11.2/lib
/usr/local/bundle/gems/formatador-1.1.0/lib
/usr/local/bundle/gems/ffi-1.16.3/lib
/usr/local/bundle/extensions/x86_64-linux-musl/3.2.0/ffi-1.16.3
/usr/local/bundle/gems/faker-2.23.0/lib
/usr/local/bundle/gems/i18n-1.14.1/lib
/usr/local/bundle/gems/dry-validation-1.10.0/lib
/usr/local/bundle/gems/dry-transformer-1.0.1/lib
/usr/local/bundle/gems/dry-system-1.0.1/lib
/usr/local/bundle/gems/dry-struct-1.6.0/lib
/usr/local/bundle/gems/ice_nine-0.11.2/lib
/usr/local/bundle/gems/dry-schema-1.13.3/lib
/usr/local/bundle/gems/dry-types-1.7.1/lib
/usr/local/bundle/gems/dry-monitor-1.0.1/lib
/usr/local/bundle/gems/dry-logic-1.5.0/lib
/usr/local/bundle/gems/dry-logger-1.0.3/lib
/usr/local/bundle/gems/dry-initializer-3.1.1/lib
/usr/local/bundle/gems/dry-inflector-1.0.0/lib
/usr/local/bundle/gems/dry-files-1.1.0/lib
/usr/local/bundle/gems/dry-events-1.0.1/lib
/usr/local/bundle/gems/dry-configurable-1.1.0/lib
/usr/local/bundle/gems/dry-cli-1.0.0/lib
/usr/local/bundle/gems/dry-auto_inject-1.0.1/lib
/usr/local/bundle/gems/dry-core-1.0.1/lib
/usr/local/bundle/gems/zeitwerk-2.6.12/lib
/usr/local/bundle/gems/dotenv-2.8.1/lib
/usr/local/bundle/gems/diff-lcs-1.5.0/lib
/usr/local/lib/ruby/gems/3.2.0/gems/debug-1.7.1/lib
/usr/local/lib/ruby/gems/3.2.0/extensions/x86_64-linux-musl/3.2.0/debug-1.7.1
/usr/local/lib/ruby/gems/3.2.0/gems/irb-1.6.2/lib
/usr/local/lib/ruby/gems/3.2.0/gems/reline-0.3.2/lib
/usr/local/lib/ruby/gems/3.2.0/gems/io-console-0.6.0/lib
/usr/local/lib/ruby/gems/3.2.0/extensions/x86_64-linux-musl/3.2.0/io-console-0.6.0
/usr/local/bundle/gems/database_cleaner-sequel-2.0.2/lib
/usr/local/bundle/gems/sequel-5.74.0/lib
/usr/local/bundle/gems/database_cleaner-core-2.0.1/lib
/usr/local/bundle/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby
/usr/local/bundle/gems/coderay-1.1.3/lib
/usr/local/bundle/gems/bigdecimal-3.1.4/lib
/usr/local/bundle/extensions/x86_64-linux-musl/3.2.0/bigdecimal-3.1.4
/usr/local/bundle/gems/ast-2.4.2/lib
/usr/local/bundle/gems/rake-13.1.0/lib
/usr/local/lib/ruby/site_ruby/3.2.0
/usr/local/lib/ruby/site_ruby/3.2.0/x86_64-linux-musl
/usr/local/lib/ruby/site_ruby
/usr/local/lib/ruby/vendor_ruby/3.2.0
/usr/local/lib/ruby/vendor_ruby/3.2.0/x86_64-linux-musl
/usr/local/lib/ruby/vendor_ruby
/usr/local/lib/ruby/3.2.0
/usr/local/lib/ruby/3.2.0/x86_64-linux-musl The application code is located in /usr/app/lib/fintech/merchants/application/create_merchant_use_case.rb
/usr/app/lib/fintech/merchants/domain/merchant_entity.rb
/usr/app/lib/fintech/merchants/infrastructure/postgres_merchant_repository.rb
...
/usr/app/lib/types.rb What I meant before is that I cannot see any of those files when I type Not sure if ruby-lsp is able to recognize when a file is autoloaded or not, but I'm thinking that maybe is because the code within https://guides.hanamirb.org/v2.0/app/autoloading/#autoloading-in-the-lib-directory Zeitwerk is used under the hood.
I don't think so.
Great. Thanks for your answer. |
Oh, you mean the require path completion not the constant completion. Yeah, we noticed it stopped working suddenly and submitted a report to the LSP VS Code package. It might be a bug in VS Code itself given that we're returning proper completion items and it just never shows the selection to the user. Still trying to figure that one out. |
Operating System
Ubuntu MATE 22.04
Ruby version
3.2.2
Project has a bundle
Ruby version manager being used
rvm
Description
Some notes:
.ruby-lsp
does not exist in my working directory. Maybe is the expected behavior?And that last point is the one that I'm trying to solve or at least understand how to benefit from that feature.
VSCodium version
1.84.2
VSCodium extension version
0.4.13
VSCodium settings
ruby-lsp gem version
0.12.3
Custom Gemfile content
Ruby LSP output in VSCodium
Project's Gemfile
Only some gems present in the custom Gemfile seems to be recorgnized. For instance, only
hanami-rspec
from all Hanami-related gems used in the project.The text was updated successfully, but these errors were encountered: