haskell / haskell-ide-engine

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

how to invoke hsimport using nvim coc #1719

Open EdmundsEcho opened 4 years ago

EdmundsEcho commented 4 years ago

Hello -- Some of the hie features are quite obvious when using nvim with coc... others less so. How would I invoke the hsimport plugin using coc? Is there another way to invoke hie features from nvim outside of coc? (i.e., does coc provide access to all of the hie features?)

expipiplus1 commented 4 years ago

@EdmundsEcho Take a look at my coc.nvim port of @alanz's vscode plugin: https://github.com/expipiplus1/vscode-hie-server/

quickfixes and code actions to add imports have been working very well for me with this.

fendor commented 4 years ago

If you mean to invoke hsimport with your own input, not just the generated code-action, then I think there is currently no way. But it would be a nice feature request to make this possible, if anyone wants to tackle it.

EdmundsEcho commented 4 years ago

@fender @expipiplus1 Thank you both.

@fendor

not just the generated code-action

Can you tell me more about this? My understanding of what hsimport enables is that it will either insert the import line for me when I use a missing def. I assume doing its best with the db/hoogle information... or it may rely on my making sure the packages are included in my package.yaml config. Even there, it might add them??

I don't see any of that capacity in my current coc/hie setup... but, maybe I'm missing something, and thus the question.

- E

fendor commented 4 years ago

Our hsimport plugin uses the local hoogle db. E.g., when you dont see a message in your lsp logs that there is no hoogle db, it should be working. The Quickfix should be generated if there is a compilation error and we can find the identifier in hoogle. E.g. something like this:

main = print $ isJust Nothing

should generate a Quickfix action for isJust. However, I dont know the specifics for nvim.

EdmundsEcho commented 4 years ago

@fender When you say local, do you mean in my project? I ask because during the install of hie it instructs the user to install the hoogle docs for the hie-ghc-version; a global install.

fendor commented 4 years ago

No, with local I mean on your device. So, no remote requests.

EdmundsEcho commented 4 years ago

@fender Great. So, from command line I can search eg., "MonadState" and pull up a bunch of results. However, in my project from within neovim, I'm getting a "Not in scope" error. Should the QuickFix not provide something?

E.g., when you dont see a message in your lsp logs that there is no hoogle db, it should be working.

I have confirmed that I don't see a "missing hoogle db" message.

fendor commented 4 years ago

Yeah, it should provide a quickfix, in vscode this little light bulb. Maybe a bug, can you provide a minimal example, please?