Skip to content

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

Open
@codygman

Description

@codygman

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions