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

Resuscitate / provide VIM support #1

Open
alanz opened this issue Oct 6, 2015 · 12 comments
Open

Resuscitate / provide VIM support #1

alanz opened this issue Oct 6, 2015 · 12 comments

Comments

@alanz
Copy link
Collaborator

alanz commented Oct 6, 2015

Possibly based on https://github.com/alanz/HaRe/tree/master/old/editors/Vim

cc @gibiansky

Originally https://github.com/alanz/HaRe/issues/40

@glittershark
Copy link
Contributor

Hey @alanz! I've been toying around with making this happen as a weekend / new years' holiday project. I've got passable support for ghc-hare rename and ghc-hare liftToTopLevel up at https://github.com/glittershark/vim-hare, and things are moving along pretty well.

The one big issue that I've run into is parsing the elisp output of ghc-hare - currently I have this disgusting mess of tr, regular expressions, and eval, which is obviously far less than optimal. From what I can read, haskell-ide-engine seems to have decided on using JSON as an interface - would there be any support for providing that as an option over here?

Furthermore (and I know I really should open a new issue for this, but hey), I can see a fair amount of cleanup to be done in some of the haskell backend source itself - this block, as an example, could use when instead of several nested if/then/else blocks - is that the kind of thing you'd be willing to accept patches for?

@alanz
Copy link
Collaborator Author

alanz commented Jan 3, 2016

Just a quick comment without looking properly as I am going to bed.

I would definitely recommend going the haskell-ide-engine route, as it already exposes Hare, and you will be able to access other plugins too. See https://cocreature.github.io/haskell-ide-engine/plugins/hare.html

@alanz
Copy link
Collaborator Author

alanz commented Jan 4, 2016

As far as PR's to clean up the code, they are welcome for bits that are already stable (such as renaming)

I am going through a process of porting code from the earlier implementation, and there is a surprising amount of subtlety/detail in it, so I tend to preserve the original as much as possible initially.

And of course a lot of the code is just horrible as I have been learning haskell as I go along. A lifelong experience.

There are some options for your plugin

  • Keep it as it is and deal with the elisp output
  • Modify HaRe to emit a different output format when asked to
  • Integrate with haskell-ide-engine

I am obviously biased toward the latter, but will change format if you prefer/accept a PR for a different format

@glittershark
Copy link
Contributor

I'm definitely with you on integrating with haskell-ide-engine - the only problem is since that's a background process with an HTTP interface (a decision which I support, for the record) dealing with it from pure vimscript becomes all but impossible. That being said, there are plenty of popular vim plugins that do the rpc/ipc + background process approach to great success with things like Python/Lua/what have you.

I think I'd like to go forward with trying to do vim bindings for ghc-hare as a standalone for now, since the shell-out approach is really easy to deal with. In the future, however, I'm super interested in putting the work in to try and get haskell-ide-engine working well with vim

@alanz
Copy link
Collaborator Author

alanz commented Jan 4, 2016

hie also has a stdio/JSON transport, which the emacs integration uses. And is open to others, if required.

@cocreature
Copy link
Contributor

In fact I would probably call the stdio transport the main transport atm, simply because that’s what emacs and I think also leksah use it and those are the only integrations we have so far. I’d be happy to help you with the vim integration where I can (I’m not a vim user). If stdio is not convenient for you just tell us what you need and we’ll try to provide that.

@glittershark
Copy link
Contributor

by stdio do you mean I can pipe JSON to an invocation of hie? like echo {"some:"stuff"} | hie?

@alanz
Copy link
Collaborator Author

alanz commented Jan 4, 2016

@cocreature That sounds like an interesting way of doing it. hie expects to run as a daemon, so we should maybe add base:exit to ask hie to exit when done

@cocreature
Copy link
Contributor

Or we could add an --one-shot option which causes it to only process one command at a time and then exit. However you have to be aware that obviously spawning a new process each time will be slower, especially if you have a plugin which caches things like type info.

@glittershark
Copy link
Contributor

@cocreature that's totally fair. There comes a point where you're sacrificing too much just to get around vim's subpar process management support

@alanz
Copy link
Collaborator Author

alanz commented Jan 4, 2016

See haskell/haskell-ide-engine#154

@alanz
Copy link
Collaborator Author

alanz commented Jan 4, 2016

And if you can't wait: haskell/haskell-ide-engine#158

alanz pushed a commit that referenced this issue Dec 7, 2016
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

3 participants