iocaml icon indicating copy to clipboard operation
iocaml copied to clipboard

Completion doesn't find local bindings

Open jaredly opened this issue 9 years ago • 11 comments

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 avatar Jul 01 '16 00:07 jaredly

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

jaredly avatar Jul 01 '16 14:07 jaredly

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 avatar Jul 01 '16 14:07 andrewray

(great minds and all that!)

andrewray avatar Jul 01 '16 14:07 andrewray

: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

jaredly avatar Jul 01 '16 14:07 jaredly

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.

rgrinberg avatar Aug 22 '16 14:08 rgrinberg

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

jaredly avatar Aug 22 '16 17:08 jaredly

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

rgrinberg avatar Aug 22 '16 19:08 rgrinberg

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.

let-def avatar Aug 23 '16 15:08 let-def

@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

jaredly avatar Aug 23 '16 23:08 jaredly

@let-def any update with the Merlin then?

XVilka avatar Jun 09 '17 05:06 XVilka

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 :/.

let-def avatar Jun 09 '17 06:06 let-def