haskell-ide-engine icon indicating copy to clipboard operation
haskell-ide-engine copied to clipboard

how to invoke hsimport using nvim coc

Open EdmundsEcho opened this issue 5 years ago • 8 comments
trafficstars

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

EdmundsEcho avatar Apr 03 '20 17:04 EdmundsEcho

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

expipiplus1 avatar Apr 04 '20 07:04 expipiplus1

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.

fendor avatar Apr 04 '20 10:04 fendor

@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

EdmundsEcho avatar Apr 04 '20 15:04 EdmundsEcho

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.

fendor avatar Apr 04 '20 16:04 fendor

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

EdmundsEcho avatar Apr 04 '20 16:04 EdmundsEcho

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

fendor avatar Apr 04 '20 16:04 fendor

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

EdmundsEcho avatar Apr 04 '20 16:04 EdmundsEcho

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

fendor avatar Apr 04 '20 19:04 fendor