andrewray / iocaml

An OCaml kernel for the IPython notebook
MIT License
193 stars 20 forks source link

Completion doesn't find local bindings #50

Open jaredly opened 8 years ago

jaredly commented 8 years ago

If I define let something, and then execute it, I would expect that typing som<tab> would autocomplete to something

image

It looks like you'd need access to toplevel_value_bindings, which is private :( Would we be able to just grab the toploop.ml file and copy it into this project?

jaredly commented 8 years ago

utop does this right -- I'm looking into what they're doing, seeing if we can use it. https://github.com/diml/utop/blob/master/src/lib/uTop_complete.cppo.ml

andrewray commented 8 years ago

That might be dangerous (theres some properly weird stuff going on in translmod around setvalue/getvalue).

It shouldn't be too hard to interpret the output of parsing and maintain our own table.

One thing I have been wondering about is whether it is possible to use utop (as a library) to control the top level. It tends to follow the ocaml compiler releases and features a bit better than iocaml (ie I would love to have ppx in iocaml, but it doesnt work at the moment).

andrewray commented 8 years ago

(great minds and all that!)

jaredly commented 8 years ago

:D yup. it would require forking utop (it doesn't currently expose all we would want it to), unless we pretend to be emacs and connect to utop over a socket

rgrinberg commented 8 years ago

How come you've decided to use utop rather than merlin?

merlin also has a completion API and its already available for general use through its RPC.

jaredly commented 8 years ago

merlin has a completion api that works with a running repl context? this isn't just for statically analyzable completions, this is for a repl

rgrinberg commented 8 years ago

I see. I did not appreciate this difference at first. Isn't an ipython notebook more like a buffer rather than a true repl though? And with OCaml, you shouldn't need to actually run any of the source code to generate all completions. So I'm not sure what a non "statically analyzable completion" would be.

In any case, @let-def could you please comment on this?

On 08/22, Jared Forsyth wrote:

merlin has a completion api that works with a running repl context? this isn't just for statically analyzable completions, this is for a repl

You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/andrewray/iocaml/issues/50#issuecomment-241492004

let-def commented 8 years ago

In its current state Merlin is not compatible with a REPL because of the patches applied on compiler-libs.

We are looking into making it usable for a REPL, that should happen early 2017 and will probably be exposed as a library to use on top of compiler-libs.

jaredly commented 8 years ago

@rgrinberg ipython is a true repl, with a live context that you can interact with and manipulate. though you're right that you could probably figure everything out statically, utop was built for the kind of interaction that people expect from ipython

XVilka commented 7 years ago

@let-def any update with the Merlin then?

let-def commented 7 years ago

I didn't implement anything directly on Merlin side yet, but @SanderSpies extracted relevant code and made a proof of concept 👍 . I have some ideas on how to improve the integration to toplevel, but I haven't had time to look at that :/.