eagletmt/neco-ghc

What's the recommended way to use on single file with stack?

Closed this issue · 4 comments

Currently I wrap nvim in a shell function in a way such that if its opening a haskell file, then invoke as something like stack exec -- nvim $*. This makes neco-ghc completion in Haskell file outside of project works, otherwise it can't find packages installed "globally" by stack (those packages stack builded without a project). However I noticed that in stack project, neco-ghc completion doesn't work anymore today. And here's the output of NecoGhcDiagnostics:

Current filetype: haskell
ghc-mod is executable: 1
omnifunc: necoghc#omnifunc
neocomplete.vim: 0
neocomplcache.vim: 0
YouCompleteMe: 0
vimproc.vim: 902
ghc-mod: 5.7.0.0
Imported modules: Prelude, Text.Hamlet, Network.Wai, Servant, Data.Proxy
Number of symbols in Prelude: 0

After some digging, I think here's what happens:
when stack exec, STACK_EXE is set to the binary of stack, and when in stack project ghc-mod would output a warning line before the browse command's output: Warning: STACK_EXE set, preferring Stack project, causing s:ghc_mod_caching_async break too early. Removing the break the completion works but this shouldn't be the way to do...

If I invoke nvim directly the completion works fine in stack project, but not outside of project.

So what's the correctly (or recommended) way to use neco-ghc in these two occasions? supposing I want to use a "universal" nvim command.

OK. I will fix it.

Hi,
This seems to work partially, for pragmas and module name it still doesn't work, and the error message is kind of annoying... I guess the ghc-mod warning also shows up on other situations, causing this for similar reason. How about just ignore the warning and only echom error messages?

update: I sent a PR

This unnecessary warning was demoted to an info in the newly released ghc-mod-5.8.0.0 so this shouldn't be necessary any more.

That's good. Closing my PR and waiting for the new release!