Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The type info doesn't show up in the :command line, but only in GHCi #68

Open
Eugleo opened this issue Jul 19, 2017 · 12 comments
Open

The type info doesn't show up in the :command line, but only in GHCi #68

Eugleo opened this issue Jul 19, 2017 · 12 comments

Comments

@Eugleo
Copy link

Eugleo commented Jul 19, 2017

Steps to reproduce:

  1. Open a file which is a part of Stack project, or a standalone file.
  2. Open GHCi using :InteroOpen.
  3. Invoke :InteroType or :InteroGenericType -> both only print the type in the terminal, not at the bottom line of nvim (where you type the commands)

My init.vim.

@parsonsmatt
Copy link
Owner

Thanks for the report and init.vim! I tried it with most of your non-plugin settings and couldn't replicate. Can you try disabling plugins one-by-one to identify which one might be causing the issue?

@Eugleo
Copy link
Author

Eugleo commented Jul 20, 2017

Well, I stripped down my init.vim to this and it still didn't work:

syntax on
set background=dark

" Plugins
call plug#begin('~/.local/share/nvim/plugged')

" Haskell plugins
Plug 'parsonsmatt/intero-neovim',    { 'for': 'haskell' }

call plug#end()

I open my standalone file, :InteroLoadCurrentFile, :InteroType and nothing happens. Only when I run :InteroOpen can I see the type was printed out to GHCi.

EDIT: If it helps: I'm on MacOS (beta) and have the nvim from homebrew (0.2.0).

@parsonsmatt
Copy link
Owner

I can't replicate this on Ubuntu with nvim-0.2.1 :\

@Eugleo
Copy link
Author

Eugleo commented Jul 21, 2017

I tried latest nvim nightly with my simplified init.vim and it still doesn't work... In what else could the problem be?
Just to be sure, what should be the exact step-by-step procedure, the one that works for you? (from opening the file to eventually getting the type)

@jez
Copy link
Collaborator

jez commented Jul 21, 2017 via email

@decentral1se
Copy link
Contributor

Yep, this is happening to me now :|

@rdnetto
Copy link
Collaborator

rdnetto commented Jul 30, 2017

@Eugleo , can you check if g:intero_started is defined and set to 1? I suspect that it's not detecting the prompt correctly, and therefore not firing the event handler.

rdnetto added a commit that referenced this issue Jul 30, 2017
This should make it more obvious if we're not parsing the prompt
correctly. See #68, #69, #74 for context.
@rdnetto
Copy link
Collaborator

rdnetto commented Jul 30, 2017

Actually, just pull master and try running :InteroInfo - it'll fail pretty obviously if intero_started is false.

@Eugleo
Copy link
Author

Eugleo commented Aug 2, 2017

Yes, it seems Intero is still starting up.

@Utagai
Copy link

Utagai commented Nov 7, 2019

Chiming in here as I also have this problem, but my :InteroInfo does not fail and :echo intero_started gives back 1, but I still only see the type information in the REPL and not in the :command line.

What is interesting that I've found is that errors with doing :InteroGenericType show up in the :command line... (e.g. trying a :interoGenericType on a keyword like import).

@Utagai
Copy link

Utagai commented Nov 7, 2019

I think I found the fix for this, at least for my situation... It is getting late here but I'll put up what should be a small patch here or a PR soon, and see what people think. It may be incorrect but should at least shed some light on what's going on...

@Utagai
Copy link

Utagai commented Nov 9, 2019

So the root issue seems to be that not everyone's Intero REPL behaves the same. Here's mine after a :InteroGenericType:

*Main Lib> getInt :: IO Int
*Main Lib>

So, we care about getInt :: IO Int. The code previously did the work of extracting that via a substitute() and a regex for the prompt, but was echo'ing the rest of the response (usually empty). Instead, we want to echo the extracted part, which is a:cmd. Here's the patch:

diff --git a/autoload/intero/process.vim b/autoload/intero/process.vim
index abe1d0f..33ea315 100644
--- a/autoload/intero/process.vim
+++ b/autoload/intero/process.vim
@@ -256,7 +256,7 @@ function! s:new_response(cmd, response) abort
 
     " These handlers are used for all events
     if g:intero_echo_next
-        echo join(a:response, "\n")
+       echo a:cmd
         let g:intero_echo_next = 0
     endif

(Technically, we actually want to output the rest of the response too since in the case of errors, a:cmd is actually empty and the rest of the response is not, but this patch doesn't handle it. I'm only including the patch to show what's going on here. It's not a perfect "fix".)

However, this is not actually always correct, since the ASCII demo in the README shows that for some people, the prompt actually includes the command e.g. :type-at. For example, this is from the ASCII demo:

λ> :type-at Text.Pandoc.SideNote 61 42 61 42 attrs                                        
attrs :: [(String, String)]

But as you can see, in my case, I don't have the command printed out to the REPL line, I have the response printed there. Perhaps its a difference in Intero version or something?

Also #132, which I'm also facing, is probably related to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants