-
-
Notifications
You must be signed in to change notification settings - Fork 389
Completions from non-imported modules #1327
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
Comments
Agreed. If I remember correctly, we once had this feature when the automatic import-list extension had been implemented. |
#1266 implements auto extending import lists - that is, for identifiers in modules that are already imported. Providing completions from non-imported modules is a related but different feature. |
Now we produce completion items (with auto extending mechanism) from module's import declarations, which means that the completion only works if the source module has already been imported. As @michaelpj said, Java IDE, in particular IntelliJ IDEA, is doing a great job in this. In this case users even don't have to focus on the imports. But name clashes in Haskell are extremely common: imagine that we input an unqualified identifer -- |
Personally, I would like:
If we paired this with a code action to "unqualify this module import if there are no name clashes", I think that would be a fairly nice flow. Complete a bunch of |
Just out of curiosity, why not? |
Because ghcide reuses stale completions. A stale completion is usually still valid, a stale text edit is not. Commands offer a solution to this, as the textedit is calculated when the completion is applied instead of when the completion is generated. |
That seem a nice workflow to me too. The completion list could be filtered by the type (hey, this is haskell, right?), as requested in other issue: #754. That would give us the exact match for the |
You can still do this, but then use |
A feature I remember from Java IDEs that was very nice was that completion would offer options from modules that were not (yet) imported, but were available. Selecting that completion would also insert the appropriate import. When combined with auto-organizing imports this lets you almost ignore imports and just work from the completion prompt.
I think we could do this, although there's a risk that we might end up returning a really large number of completions! Completions from other modules in the package, would be nice, but doing it for dependencies too would be great. I would love to be able to just complete
Map
and have it imported!(The LSP protocol supports this:
CompletionItem
s have a list ofadditionalTextEdit
s which even calls out "adding an additional import at the top of the file" as a example usecase.)The text was updated successfully, but these errors were encountered: