Skip to content

Add support for qualified import Completions from non-imported modules #2570

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

Open
codygman opened this issue Jan 7, 2022 · 0 comments
Open
Labels

Comments

@codygman
Copy link

codygman commented Jan 7, 2022

Related to #2040. It would also be nice to have a setting to choose one of:

  • show unqualified imports only
  • show qualified imports only
  • show both qualified and unqualified imports (this might be annoying for packages like Data.Vector)

I know that qualified import completions are more difficult since the qualifier name can be subjective, but I'd say a simple first step could be just reusing the module name:

Data.Vector -> import qualified Data.Vector as Vector

I'm a little biased though, since that's the format my work codebase uses 😉

Then future work could easily have some configuration that lets you choose QualifiedImportStyle and maybe provides:

  • WholeWord
  • FirstLetter

Where FirstLetter provides the popular variant (though it has more edge cases than WholeWord):

Data.Vector -> import qualified Data.Vector as V

Then other ideas include seeing how other modules in the codebase import that module and importing it the same way. For instance this option would be like:

  • User types take with QualifiedOnlyImportStyle configured and QualifiedImportStyle of Auto.
  • One module already imports Data.Vector as import qualified Data.Vector as V
  • Another module imports Data.Vector as import qualified Data.Vector as Vect

The user sees these completions:

V.drop (Data.Vector)
Vec.drop (Data.Vector)
List.drop (Data.List)

Dreaming further, perhaps those completions are annotated with instances of the imports?

V.drop (Data.Vector) (135 instances)
Vec.drop (Data.Vector) (1 instance)
List.drop (Data.List) (300 instances)

Anyway, I just wanted to get my thoughts out fully but in the short term my only hope is for the initial qualified imports feature to be added with the WholeWord style since that meets my use case. The rest of the thoughts are mainly geared towards solving the problem more generally in hopes of satisfying more users use cases.

Thanks for implementing this feature at all, it really makes everything so much nicer. In my own codebases I don't use qualified imports much and this saves me so much annoyance (and a little bit of time).

@codygman codygman changed the title Add support for qualified import Completions from other modules Add support for qualified import Completions from non-imported modules Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants