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

Obscure error message when no nREPL is running #41

Closed
daveyarwood opened this issue Mar 23, 2019 · 11 comments
Closed

Obscure error message when no nREPL is running #41

daveyarwood opened this issue Mar 23, 2019 · 11 comments

Comments

@daveyarwood
Copy link
Contributor

This is just a little thing I noticed where the experience could be a bit nicer:

If I don't have a REPL running, and I run :AcidRequire, I get this uncaught error:

E5105: Error while calling lua chunk: /home/dave/.vim/bundle/acid.nvim//lua/acid/core.lua:31: Unexpected type

It would be nice if acid could recognize this scenario and say "No REPL found" or something.

@hkupty
Copy link
Member

hkupty commented Mar 26, 2019

Previous version was relying on a .nrepl-port file on the local directory. This is still available on the server server side as a fallback, but I probably should move that to lua or remove it completely.

@hkupty
Copy link
Member

hkupty commented Mar 26, 2019

(to make my previous comment clearer)
After preparing the message to be sent to the nrepl, I send it to python which then sends through the socket. If I don't provide a connection (a tuple of [ip, port]), it will look for a local .nrepl-port, but on python side.

@daveyarwood
Copy link
Contributor Author

That's interesting. How are you finding the nrepl port when there is no .nrepl-port?

@daveyarwood
Copy link
Contributor Author

I phrased that poorly. I mean, how do you find the nrepl port before looking for the .nrepl-port?

@hkupty
Copy link
Member

hkupty commented Mar 26, 2019

There are two functions on acid.connections to add a connection and to connect to it. I'll add a command to invoke both functions so that's transparent.

Another, much simpler way is to use acid.nrepl.start, as described in the docs here. For example:

"This will start a nrepl server with default arguments and cider and refactor-nrepl middlewares.
lua require("acid.nrepl").start{} 

"This will start a nrepl server with only the piggieback middleware. 
lua require("acid.nrepl").start{middlewares = {"cider/piggieback"}}

@hkupty
Copy link
Member

hkupty commented Mar 26, 2019

Also, one can use jazz.nvim, which is a set of extensions of acid that make use of impromptu.nvim to have interactive menus.

I splitted that from acid since I didn't want to impose another extra dependency, so the menus are opt-in.

@daveyarwood
Copy link
Contributor Author

Oh, cool -- I didn't realize that you can use acid to start an nREPL. I'll have to play around with that.

My typical workflow is usually to start my own nREPL in another terminal, so that I can have more control over the environment, dependencies, etc. There will often be old .nrepl-port files laying around from previous REPL sessions, so if I'm understanding correctly, acid is trying to connect on those old ports and bombing out.

In that case, maybe a good error message would be something like "Unable to connect to nREPL on port 12345."

@hkupty
Copy link
Member

hkupty commented Mar 26, 2019

That is possible to happening, yes. I think it's safe to assume that either way I should stop doing that on python and try to find my way through with lua, so one could auto-connect if a .nrepl-port file is found and a connection is active.

I'll look into it. :)

hkupty added a commit that referenced this issue Mar 27, 2019
* #41: Add .nrepl-port from lua if it's found

* Add single log fn

* Clear output before result
@hkupty
Copy link
Member

hkupty commented Mar 27, 2019

I believe this one is fixed now by 9667705, but I'll keep this open so I remember to refactor the python end.

@daveyarwood
Copy link
Contributor Author

The issue is fixed from my perspective. 👍

BTW, I discovered something interesting. At least with Boot, when you quit the REPL by either running (quit) or pressing Ctrl-D, it actually removes the .nrepl-port file! So I think my theory about acid trying to connect to previous REPL sessions because there are old .nrepl-port files laying around was incorrect.

At any rate, things are feeling much nicer now. Much appreciated!

@hkupty
Copy link
Member

hkupty commented Mar 27, 2019

Awesome! I'm really glad those issues are being solved and the experience of using acid is getting nicer :)

Please don't refrain from opening issues and let me know if you have any other problems or suggestions!

I'll close this now, but, as always, feel free to reopen if needed.

Cheers,
Henry

@hkupty hkupty closed this as completed Mar 27, 2019
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