iquiw / company-ghc

Company-mode completion back-end for haskell-mode via ghc-mod
125 stars 6 forks source link

nil and 0 candidates #5

Closed MichaelXavier closed 10 years ago

MichaelXavier commented 10 years ago

Hi!

I've been unable to successfully use company-ghci. Running company-ghc-diagnose shows nil and 0 completions:

company-ghc backend found: company-ghc
automatic scan module is enabled

Module                                  Alias               Candidates
-------------------------------------------------------------------------------
Seraph.Types                            -                        nil
Debug.Trace                             -                        nil
MVC                                     -                        nil
Data.Set                                S                        nil
Data.Maybe                              -                        0
Data.Map                                M                        nil
Control.Monad.Writer.Strict             -                        nil
Control.Monad.State.Strict              -                        nil
Control.Lens                            -                        nil
Prelude                                 -                        0

Before you invite me to RTFM, I have read the troubleshooting steps on this: M-: (setq ghc-debug t) and then M-x ghc-debug. Nothing jumps out me as erroneous:

% ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.3
% ghc-mod version
ghc-mod version 5.0.1 compiled by GHC 7.8.3
% ghc-modi version
ghc-modi version 5.0.1 compiled by GHC 7.8.3

I'm using flycheck-haskell and haskell-mode. I'm happy to provide any additional details you find necessary and thankk you in advance for any help you can provide with debugging.

iquiw commented 10 years ago

Hi, thank you for trying company-ghc. Instead of M-x ghc-debug, check *GHC Debug* buffer. (You need to set ghc-debug before visiting the haskell file)

The most likely cause is failure of cabal configure (invoked by ghc-mod), due to e.g. missing dependency. What happens if run ghc-mod boot from shell or command prompt in the project directory?

MichaelXavier commented 10 years ago

Thanks for the fast respones! Ah yes, I forgot to take that out. The buffer I was looking at was indeed GHC Debug

You were onto something about booting ghc-mod. It didn't work, because I forgot that I had upgraded ghc versions which invalidated my sandbox. I tore it down and rebuilt it. Now, when I boot, I get a massive list of modules, functions, etc (which I assume is what I want).

However, it doesn't appear to be working. I'm testing it out by adding language pragmas and it fails to complete the pragma. Diagnose still shows all 0s and nils. The output in GHC Debug seems useless:

% ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.3
% ghc-mod version
ghc-mod version 5.0.1 compiled by GHC 7.8.3
% ghc-modi version
ghc-modi version 5.0.1 compiled by GHC 7.8.3
% ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.8.3
% ghc-mod version
ghc-mod version 5.0.1 compiled by GHC 7.8.3
% ghc-modi version
ghc-modi version 5.0.1 compiled by GHC 7.8.3
iquiw commented 10 years ago

Now, when I boot, I get a massive list of modules, functions, etc (which I assume is what I want).

So it seems ghc-mod boot is working.

However, it doesn't appear to be working. I'm testing it out by adding language pragmas and it fails to complete the pragma. Diagnose still shows all 0s and nils. The output in GHC Debug seems useless:

You are using flycheck (me too), so you don't call ghc-init in haskell-mode-hook, do you? (which enables ghc-mod own error checker) If ghc-init is not called, then at least ghc-comp-init (and ghc-import-module optionally) needs to be called for company-ghc to work.

My hook is like the following.

  (defun my-ghc-haskell-mode-hook ()
    (ghc-abbrev-init)
    (ghc-type-init)
    (unless my-ghc-initialized
      (ghc-comp-init)
      ;; (snip) misc keybinding here..
      (setq my-ghc-initialized t))
    (ghc-import-module))

I will update README and possibly company-ghc-diagnose function.

iquiw commented 10 years ago

I will update README and possibly company-ghc-diagnose function.

Done.

MichaelXavier commented 10 years ago

I went down the path of investigating ghc-mod from this and ended up working it out. Thanks!

iquiw commented 10 years ago

You're welcome.

BTW, I'm using Angel on my server. Thank you!

freeman42x commented 9 years ago

@iquiw Having a similar problem. Reading about this: http://stackoverflow.com/a/28049104/750216 I downgraded cabal-install to 1.20.0.6 and rebuilt the packages but that did not solve the problem. I will try upgrading to GHC 7.10.1, maybe that solves the problem.

freeman42x commented 9 years ago

ghc-mod does not build with 7.10.1 yet https://github.com/kazu-yamamoto/ghc-mod/issues/437

iquiw commented 9 years ago

@razvan-panda It is probably ghc-mod issue.

ghc-mod#437 is marked as "Fixed in master", so you can install it from github.