haskell / haskell/haskell-language-server
Add support for qualified import Completions from non-imported modules
- Dominant language
- Haskell
- Stars
- 3k
- Forks
- 455
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 13
Description
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 :wink:
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).
Contributor guide
No contributing guide indexed for this repository
Research direction
Read related issue #2040 first, then locate the existing import-completion entry point. Define the initial WholeWord qualified-import behavior and limit the configuration scope; done means completions can add qualified imports from non-imported modules with coverage for the selected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100