conjure icon indicating copy to clipboard operation
conjure copied to clipboard

Elixir support?

Open aliresool621 opened this issue 11 months ago • 12 comments

https://hexdocs.pm/elixir/introduction.html#interactive-mode

aliresool621 avatar Dec 29 '24 04:12 aliresool621

I'm fiddling with this now (if im honest i vibed it out) and I'm trying to debug it.

It's launching but I'm getting no output so any help would be greatly appreciated of course!

brandonpollack23/conjure in

brandonpollack23 avatar Jul 27 '25 23:07 brandonpollack23

Some suggestions:

  • Rename iex.fnl to stdio.fnl.
    • The naming convention for client modules appears to be conjure.client.<language>.<transport>.
    • For example, the Python client uses stdio for its transport so its module is conjure.client.python.stdio.
    • The configuration items for this client are prefixed with g:conjure#client#python#stdio (vimscript).
    • I don't think that this is the reason that you are having trouble getting your code working.
  • As a first pass, leave out the Mix project use case for starting the Elixir REPL (iex).
    • It seems that the Mix project use case can probably be addressed by changing the g:conjure#client#elixir#stdio#command configuration from "iex" to "iex -S mix". I don't use Elixir but have read https://hexdocs.pm/elixir/introduction-to-mix.html.
  • Create a dev/elixir/sandbox.exs that includes sample Elixir code that someone might typically want to work with.
    • This provides a baseline set of Elixir code that anyone could evaluate and get a sense of how well the Elixir client would work for them.
    • It is not a test suite but a simple and easy way to tell if things are working well enough.

russtoku avatar Jul 28 '25 20:07 russtoku

In fnl/conjure/client/elixir/iex.fnl, this line:

:prompt_pattern "iex(%d+)> "

should be:

:prompt_pattern "iex%(%d+%)> "

The prompt_pattern of the client config is a Lua pattern. So, to get a "(", you need to use "%(". Similarly, to get a ")", you need to use a "%)".

Unfortunately, this little change is not enough to make your client work. You'll also need to fix format-msg.

I tried evaluating some of the examples from:

  • https://hexdocs.pm/elixir/basic-types.html
  • https://hexdocs.pm/elixir/lists-and-tuples.html
  • https://hexdocs.pm/elixir/case-cond-and-if.html

I think some tweaking needs to be done so that error messages are returned without the prompt and the prompt for more is not shown when evaluating multi-line code fragments.

russtoku avatar Aug 01 '25 09:08 russtoku

Using your conjure.client.elixir.iex module, I created a conjure.client.elixir.stdio module using the conjure.client.scheme.stdio client as a base. It also worked once the :prompt_pattern was set correctly. But the error messages and return values need tweaking so that the results more closely mirror the examples from the Elixir docs.

You have a good start for an Elixir client. The format-msg function needs some work for things to start working.

russtoku avatar Aug 01 '25 09:08 russtoku

Wow thanks a ton, sorry was on a plane flying back home to Tokyo when you commented these.

D'oh that is a dumb error! This is our future in a nutshell: people writing languages they dont know well (for me fnl right now) and making small mistakes like this.

Let me see if I can do this tweaking

brandonpollack23 avatar Aug 01 '25 21:08 brandonpollack23

As far as mix projects, this is the vast majority of use cases so I think it is easier to keep the check in rather than have any user have to configure that and add a .exrc

brandonpollack23 avatar Aug 01 '25 22:08 brandonpollack23

@russtoku Just pushed a change with your suggested fixes but I didn't have as much luck as you

brandonpollack23 avatar Aug 01 '25 23:08 brandonpollack23

As far as mix projects, this is the vast majority of use cases so I think it is easier to keep the check in rather than have any user have to configure that and add a .exrc

Sorry, I'm not an Elixir user. That's good to know.

russtoku avatar Aug 02 '25 00:08 russtoku

Thanks again for taking a look, im around but working on some other stuff so I'll get back to it, but if you have any other input just let me know :)

brandonpollack23 avatar Aug 02 '25 01:08 brandonpollack23

I put up my working client at https://github.com/russtoku/conjure/tree/add-elixir-client. I've included a sandbox.ex file that should be able to be evaluated in the client and produce return values that match what's commented in the file. <localleader>ee (evaluate current form), <localleader>er (evaluate root form), and <localleader>E (evaluate selection or motion) should work on the Elixir examples in sandbox.ex. For the most part, <localleader>ee should work on most of them.

Because I started with the Scheme client, my code differs from your in some ways that I couldn't easily point out why mine works. But I've included a few pieces of your code. Please have a look when you get a chance. I'm not saying mine is better but I tried to get it work closely to what it's like in the interactive iex REPL. Feel free to use whatever make sense to you.

russtoku avatar Aug 02 '25 07:08 russtoku

I've moved my add-elixir-client branch to a separate repo. It's now in https://github.com/russtoku/conjurex. The README there tells how to use it.

russtoku avatar Aug 27 '25 01:08 russtoku

@aliresool621 and any Elixir fans,

Would you folks be able to try things out using my repo?

russtoku avatar Oct 12 '25 00:10 russtoku