haskell / haskell-ide-engine

The engine for haskell ide-integration. Not an IDE
BSD 3-Clause "New" or "Revised" License
2.38k stars 211 forks source link

Imports autocomplete #746

Closed pengstrom closed 6 years ago

pengstrom commented 6 years ago

When specifying imports import Data.<cursor> no modules are suggested. Forcing completions using ctrl+space gives only local suggestions.

Is this not supported?

mkYYY commented 6 years ago

I have the same problem too though I added a module name to dependencies in a file, package.yaml. Has anybody succeeded to use auto completion with the recent version of HIE in neovim? nvim

lorenzo commented 6 years ago

@mkYYY I don't think module autocompletion is implemented yet. Other than that, autocompletion on functions and other symbols is working great in a recent neovim installation.

lorenzo commented 6 years ago

@Bubba @alanz If you can offer me any guidance on this one, I'd love to implement autocomplete for imports

lukel97 commented 6 years ago

This would be really nice addition, you'll probably want to look into HieExtras.hs, mainly in these two functions https://github.com/haskell/haskell-ide-engine/blob/38d27a270ec1a7d7f43faa6763a8062731998633/src/Haskell/Ide/Engine/Plugin/HieExtras.hs#L250-L251 https://github.com/haskell/haskell-ide-engine/blob/38d27a270ec1a7d7f43faa6763a8062731998633/src/Haskell/Ide/Engine/Plugin/HieExtras.hs#L131-L132

But these are kind of "dumb" completions that don't really take into account the position of the cursor. The ModuleCache instance builds up all the suggestions based off everything in global scope, and getCompletions filters it down to what matches the word that the cursor is at. My first guess would be maybe to find and cache the modules that can be imported, and then populate them in getCompletions whenever you detect that the user has written "import x"

lorenzo commented 6 years ago

Great, I'll make this a project for the week. Will ask questions if I get stuck

lorenzo commented 6 years ago

@Bubba is there a place we can chat? I'm stuck in several fronts and could use some guidance

lukel97 commented 6 years ago

@Lorenzo We're on the #haskell-ide-engine IRC channel on freenode!