Shopify / ruby-lsp

An opinionated language server for Ruby
https://shopify.github.io/ruby-lsp/
MIT License
1.33k stars 118 forks source link

Don't suggest fully qualified constants when unnecessary #1983

Closed dgollahon closed 1 week ago

dgollahon commented 2 weeks ago

I have checked that this feature is not already implemented

Use case

I use the auto-completion feature. Unfortunately, it proposes constants like MyApp::Foo::Bar rather than Foo::Bar when I am inside the MyApp module. This is pointless/not preferred in our coding style.

You can get these suggestions in some cases but I predominantly get the fully qualified constant name which greatly reduces the usability of this feature for me.

Description

Prefer the shortened version of the constant when inside the class/module hierarchy.

Implementation

I am guessing it would be possible to track current scope based on how the breadcrumbs in my editor show me which modules/methods i'm inside--it would need to take this context into account.