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

ghc-modi integration #2

Closed
KasperJanssens opened this issue Nov 13, 2014 · 24 comments
Closed

ghc-modi integration #2

KasperJanssens opened this issue Nov 13, 2014 · 24 comments

Comments

@KasperJanssens
Copy link

I think there's an issue with the way you interact with ghc-modi. For example, if I create a module, called A, and I unfortunately put my cursor in the first line, the same line as mentions

module A where

you seem to call ghc-modi with the instruction

info A.hs A

Ghc-modi will then answer 'Cannot find info' (tried this directly on ghc-modi, command line) to inform the user that it didn't find this information. However, the plugin interprets this 'cannot find info' as if there's something wrong with ghc-modi, it seems to get interpreted as a Future that timed out and ghc-modi will not be called for 5 seconds. (Error in communication with ghc-modi: Futures timed out after [1 second]. Check if GHC SDK is set and ghc-modi is okay. ghc-modi will not be called for 5 seconds). This makes the plugin not having any type information anymore for the next 5s.

@rikvdkleij
Copy link
Owner

I can not reproduce this issue on Ubuntu. Which OS are you using?

Do you normally get type info in Haskell files?

@KasperJanssens
Copy link
Author

Ubuntu 14.04. No, it might be that I didn't get your plugin running correctly yet. Although if I hover my cursor over another expression it seems not to show this error message at the very least. The ghc-modi version is 5.1.0.2 by the way. Is there some way I can verify whether I didn't activate something in the IDE or so?

@rikvdkleij
Copy link
Owner

Checks paths in Settings\Haskell

Did you create sandbox for your Haskell project? If not, I advice you to create sandbox.

I used latest version of ghc-mod (5.2.1.1) but that can not be the problem.

@rikvdkleij
Copy link
Owner

Btw, can you start ghc-modi in root directory of your project?

@KasperJanssens
Copy link
Author

Yes, I can, like I said if I throw the commands that are reported as
failing into ghc-modi I get an answer from ghc-modi. Sometimes the answer
is that it cannot find something, but it doesn't time out like the error
message suggests.

Might it have something to do with subfolders? I have a subfolder in my
project and if I comment out the import B.C in my module A it stops
complaining about the ghc-modi stuff, seems to work (well, I get a warning
that it cannot find source code for System.Random in this case and to add
the source code of the package to Project Settings/LIbraries, I just point
it to my cabal sandbox to fix this?)

2014-11-13 17:33 GMT+01:00 Rik notifications@github.com:

Btw, can you start ghc-modi in root of your project?


Reply to this email directly or view it on GitHub
#2 (comment)
.

@KasperJanssens
Copy link
Author

Can it have something to do with the fact that my ghc-mod is installed in
my ~/.cabal and the other stuff is in my cabal-sandbox in my project folder?

2014-11-14 9:12 GMT+01:00 Kasper Janssens <kasper.janssens.android@gmail.com

:

Yes, I can, like I said if I throw the commands that are reported as
failing into ghc-modi I get an answer from ghc-modi. Sometimes the answer
is that it cannot find something, but it doesn't time out like the error
message suggests.

Might it have something to do with subfolders? I have a subfolder in my
project and if I comment out the import B.C in my module A it stops
complaining about the ghc-modi stuff, seems to work (well, I get a warning
that it cannot find source code for System.Random in this case and to add
the source code of the package to Project Settings/LIbraries, I just point
it to my cabal sandbox to fix this?)

2014-11-13 17:33 GMT+01:00 Rik notifications@github.com:

Btw, can you start ghc-modi in root of your project?


Reply to this email directly or view it on GitHub
#2 (comment)
.

@rikvdkleij
Copy link
Owner

Is your project on github? So I can try to reproduce issue?

About the warning. Yes, add source code directory to Project Settings/Libraries. Tip: to see library source code in navigation window, put source codes of libraries inside project root.

@rikvdkleij
Copy link
Owner

I have ghc-mod and ghc-modi in ~/cabal/bin.

In Settings/Haskell I have set paths to ghc-mod and ghc-modi.

@KasperJanssens
Copy link
Author

jip, it's on my github, it's a toy project
:git@github.com:KasperJanssens/talisman-haskell.git
to checkout some haskell stuff like lenses and so on, do a checkout of the
Board branch (that one has a cabal file :-)).

About adding source, it's for example complaining about the source to
system.random, how do I best go about putting the source of this library in
my project root? Next to that, IntelliJ only show my the possibility to add
jar files or stuff from maven in Project Settings/Libraries, expected or a
sign that the plugin didn't get correctly installed?

Concerning ghc-mod and ghc-modi, same thing for me. I now tried with the
latest version of ghc-mod as well, doesn't change anything.

Thanks for the responsiveness up until now already, I would really like to
use intellij for my haskell development and haven't managed to get one
haskell plugin working in a decent way, all my hope is on your plugin ;-).

2014-11-14 9:39 GMT+01:00 Rik notifications@github.com:

I have ghc-mod and ghc-modi in ~/cabal/bin.

In Settings/Haskell I have set paths to ghc-mod and ghc-modi.


Reply to this email directly or view it on GitHub
#2 (comment)
.

@rikvdkleij
Copy link
Owner

About source code. What I do is:

  • Create in project root directory lib (or other name)
  • Inside lib do: cabal get random
  • Go to Projects settings/Libraries.
  • New project library
  • Add random directory (as sources)

No problem :-)

@rikvdkleij
Copy link
Owner

Which version of IntelliJ are you using?

@KasperJanssens
Copy link
Author

13.1.5. Wrong version? (that would be very very very silly of me).

2014-11-14 9:57 GMT+01:00 Rik notifications@github.com:

Which version of IntelliJ are you using?


Reply to this email directly or view it on GitHub
#2 (comment)
.

@rikvdkleij
Copy link
Owner

13.1.5 is okay. I asked question because 14 is just released.

@rikvdkleij
Copy link
Owner

I found the problem. Future time-out was too short. Because your project has more dependencies than projects I used, I did not notice this problem (ghc-modi is a slower in startup).

I will release new version today.

Thanks for reporting.

@KasperJanssens
Copy link
Author

No probs, thanks for the help. I'll try to keep hammering on your plugin
from within my little pet project, you'll hear more from me most likely,
I'm extremely demanding on an IDE ;-P. Is there somewhere a list of
intellij-shortcuts that your plugin supports? I can see lots of stuff
that's supported, but I can't for example seem to find the inferred type
signature, doesn't show up when I hover, I don't seem to find a shortcut
that shows the inferred type, ... Being blind?

2014-11-14 11:10 GMT+01:00 Rik notifications@github.com:

I found the problem. Future time-out was too short. Because your project
has more dependencies than projects I used, I did not notice this problem
(ghc-modi is a slower in startup).

I will release new version today.

Thanks for reporting.


Reply to this email directly or view it on GitHub
#2 (comment)
.

@rikvdkleij
Copy link
Owner

Alt+Equals shows type

In View (of menu bar) you can see all actions (with short-cuts).

Btw, if you do not define type signature at top level, you can use Alt+Enter to put type signature above definition (derived by ghc-modi).

@rikvdkleij
Copy link
Owner

You also select expression and ask for type.

@rikvdkleij
Copy link
Owner

You can try version 0.4. It's already in Jetbrains repo and approved.

@KasperJanssens
Copy link
Author

Fantastic, I'll try as soon as possible!

2014-11-14 11:48 GMT+01:00 Rik notifications@github.com:

You can try version 0.4. It's already in Jetbrains repo and approved.


Reply to this email directly or view it on GitHub
#2 (comment)
.

@KasperJanssens
Copy link
Author

Works, thanks!

@KasperJanssens
Copy link
Author

Rik,

I'm going to abuse this (closed) issue to ask a question. First of all, I'm very happy with the plugin, it works nice and fast, I guess I didn't discover everything yet, but navigating into the libraries and getting type info and such works really nicely. However, is there a way to run tests from within IntelliJ? I know this borders on cabal integration, but just asking. Also, is there a way to open modules by starting to type their name (like Ctrl-N for Java)? If these features aren't there, are they planned?
I'm open to start creating pull requests, but I haven't really made an intellij plugin yet (did some scala already, so the language should be okay), and I don't really know where to start in your source code if I would want to change functionality.

Kasper

@rikvdkleij
Copy link
Owner

No, at the moment I do not have plans to run tests in IntelliJ. I do not see a reason for that because if you use hspec (http://hspec.github.io/), you get already nice output in terminal.

To open a module, I use open file with (Ctrl+Shift+N). If you exclude directories like .cabal-sandbox,dist and so on, this way works fine for me because name of module is name of file. So no special feature planned for that.

You can checkout plugin code and try to understand it. If you have question let me know. Maybe we should use gtalk for helping you.
Take a look at:
http://confluence.jetbrains.com/display/IDEADEV/Developing+Custom+Language+Plugins+for+IntelliJ+IDEA
http://confluence.jetbrains.com/display/IntelliJIDEA/Custom+Language+Support

@KasperJanssens
Copy link
Author

Ah, indeed, thanks for the tip about Ctrl Shift N, satisfies my needs indeed.

About the tests, you then use the terminal to talk to cabal/the compiled test binary and run tests like that, I take it? Okay, also possible indeed.

Oh, by the way, (I know I should stop hijacking this issue, it's the last thing), is there a place where you can see all the build issues? Crtl-F9 shows me build problems in the file I have open, but I don't seem to find a place where all the build issues are gathered.

@rikvdkleij
Copy link
Owner

No, because I do not build Haskell code inside IntelliJ. Could be a new feature :-) Normally I just do cabal build in terminal.

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

No branches or pull requests

2 participants