eagletmt/neco-ghc

Only Prelude module imported

Closed this issue · 9 comments

Hi. I am trying very simple Turtle tutorial, and I noticed only Prelude functions are offered for the autocompletition.
However, when autocompleting the import statement, module Turtle is offered in the list.

This is the part of my .vimrc that configures the neco-ghc:

" Haskell
let g:necoghc_enable_detailed_browse = 1
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
let g:ycm_semantic_triggers = {'haskell' : ['.']}

This is the code I'm testing on:

#!/usr/bin/env stack
-- stack --resolver lts-6.25 script --package turtle
import Turtle

main = echo "hello world"

And the output of NecoGhcDiagnostics:

Current filetype: haskell
ghc-mod is executable: 1
omnifunc: necoghc#omnifunc
neocomplete.vim: 0
neocomplcache.vim: 0
YouCompleteMe: 2
vimproc.vim: 902
ghc-mod: 5.8.0.0
Imported modules: Prelude
Number of symbols in Prelude: 253
Press ENTER or type command to continue`

I don't know if the issue is with neco-ghc, but I am stumped at how to pinpoint what the problem is, and would love some guidance.
Thanks.

You should check ghc-mod can recognize Turtle by ghc-mod directly.
I think it is not recognized.
It is not neco-ghc problem.

Hi. Thank you for the prompt response and for trying to help :-)

I tried these three things:

  • [OK] ghc-mod browse Turtle -> got the list of identifiers without problems
  • [OK] ghc-mod list | grep Turtle -> got Turtle listed and all its submodules
  • [OK] ghc-mod info test_script.hs echo -> got data type of Turtle.echo, like this:
~$ ghc-mod info test_script.hs echo
echo :: MonadIO io => Line -> io ()     -- Defined in ‘Turtle.Prelude’

Is this what you meant?

Edit:
please correct me if I'm wrong, but IIRC while looking at neco-ghc code and trying to figure out what am I doing wrong, it seems to me that Imported modules stat is a result of s:extract_modules function, which creates an internal dictionary? Also, there's parsing code that tries to find import statements, so is it perhaps the parsing that doesn't complete properly?
Prelude is added to the dictionary statically (hardcoded), so that's why it ends up in the list.

Hi, sorry for doubleposting.

I 'hacked' the Turtle module into the `b:necoghc_modules_cache', like this:

let b:necoghc_modules_cache.Turtle = {'export': 0, 'qualified': 0}

Now autocompletition works for identifiers from turtle module as well:
2017-07-05-110331_1140x1068_scrot

This lasts until the next time dictionary is rewritten. I'm nearly certain parsing the imports is the issue.

OK. I will check the implementation.

@ashyslashy Please execute NecoGhcCaching manually. Doe it fix the problem?

Please upload the video by https://asciinema.org.

Hi. Executing the NecoGhcCaching didn't fix it.
Link to the video: https://asciinema.org/a/W8EYAqxQJpZgelWE5dX2qN1gy

Thanks for the asciinema tip, this is a very cool software!

You'll notice that around 0:50, I executed the let command I mentioned, and that all of the sudden Turtle module is recognized in semantic completition list.

OK. I get it. It is the bug.

Thank you sir. If you need some help or more info, I'll be glad.
P.S. I did few tests and it seems that the initial line throws it off. If I remove #!/usr/bin/env stack from the top, it works!