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

Can't connect to new REPL if VSCode was started first #2

Closed
trevor-brandt opened this issue Mar 27, 2018 · 8 comments
Closed

Can't connect to new REPL if VSCode was started first #2

trevor-brandt opened this issue Mar 27, 2018 · 8 comments

Comments

@trevor-brandt
Copy link
Contributor

trevor-brandt commented Mar 27, 2018

I really enjoy using the integrated terminal in VSCode, so I tend to start my repl using lein repl from there.

I've noticed that clojure4vscode allows you to connect to a new REPL port if it was able to connect to some REPL at startup. But if you start VSCode first, there's no way to connect to a newly started REPL.

This is what I have to do to get it to work, which isn't ideal:

  • Start a REPL on your clojure project from a terminal somewhere
  • Open your clojure project in VSCode
  • Notice that clojure4vscode connects to the REPL successfully
  • Start a REPL from VSCode's integrated terminal
  • Click on the nrepl address in the task bar and it pops up a text box that allows you to connect to the REPL in the integrated terminal

This is what I would like to work:

  • Open your clojure project in VSCode
  • Start a REPL from VSCode's integrated terminal
  • Click on the nrepl - trying to connect label in the task bar, which pops up the text box that allows you to put in your newly-started REPL address

If this is supposed to work already and I'm doing something wrong, please let me know!

Really liking what you've done with this plugin so far. Nice work!

@PEZ
Copy link
Collaborator

PEZ commented Mar 28, 2018

Hello! Very nice to hear from you. I have been dying to get some feedback on how the extension works out there.

I am not sure I understand the process described completely, so please bear with me if I seem to answer it with nonsense. =) This is the process I have intended to support:

  1. Start the REPL from a terminal somewhere.
  2. Open the project in VS Code
  3. Notice that clojure4vscode connects to the REPL.
  4. Start bending reality with the power of Clojure.

The reason I've not put effort into starting the real from VS Code is that the project I work most on takes a while to start, and if I need to restart VS Code I don't like the penalty to wait for it to start the REPL again.

I think your desired process is almost supported if you use the Reconnect command. And I can certainly make it so that if no .nrepl-port file is found, the connection label in the status bar is clickable.

This all said. Just a few hours before you filed this issue I updated the plugin so that it automatically starts a REPL in the terminal connected to the REPL started from a terminal somewhere. And I am thinking that maybe you haven't/hadn't seen that update yet? With this version you get some more commands that helps working with the terminal REPL together with the code being edited, such as switching to the edited namespace, and evaluating code being edited in the terminal REPL.

Please let me know if you have tried version 1.2 yet and what you think about it, if so.

Hoping you will keep finding this extension useful. And will put in work to make it so. 🤠

@trevor-brandt
Copy link
Contributor Author

Hi Peter! Thanks for the reply. You're right that I hadn't seen the update before I filed the issue.

After updating and coming back to the plugin, the Reconnect command does indeed do what I'm looking for, so I'm a happy camper! I'll close this issue out.

I've been considering abandoning VSCode for my Clojure work because it seems to miss some important features that Atom supports, but I don't like Atom nearly as much as an editor. However, the inline evaluation of forms and the "evaluate and send to REPL" functions of your extension help tremendously with my VSCode satisfaction!

If I were to choose the one big thing that bothers me about Clojure in VSCode (besides the fact that the parinfer extension is a little buggy and isn't actively supported), it would be auto-indent support that follows the style-guide. Maybe something you could potentially put on your to-do list if you're taking requests 😄

@PEZ
Copy link
Collaborator

PEZ commented Mar 28, 2018

Glad your workflow is working again! Still curious about you think of the integrated Terminal REPL support, please feel invited to file more issues or just comment on that in this thread.

I haven't noticed the auto-indent thing. Can you tell a way or two it fails? (I mostly use Paredit to get things indented, and haven't studied the style guide very closely.)

Didn't know the parinfer extension was abandonware. That is not good and explains some of the pain it deals out, but it still is delivering much more bliss so still using it. Maybe you should make ourself available as the maintainer? 🤠

@PEZ
Copy link
Collaborator

PEZ commented Mar 29, 2018

One more thing. I think your way of starting the REPL would benefit from configuring the extension to not autoconnect to the REPL:

"clojure4vscode.autoConnect": false

(I also think starting the REPL from the internal terminal will get a bit confusing with the internal terminal REPL that the extension starts upon connecting, but anyway. 😀)

@trevor-brandt
Copy link
Contributor Author

trevor-brandt commented Mar 29, 2018

Oh yeah, turning off autoConnect does work for me. Thanks for that tip!

For formatting/identing, a good example is using a let form.

Consider the following snippet:

(let [x :first-val
      y :second-val]
  (println x y))

As you're typing that out, hitting the return key after :first-val should, if honoring the style guide, put your cursor directly below x, so that when you then type y, the x and y should be vertically aligned. However, VSCode instead either puts you back at the beginning of the next line (if auto-indent is off) or indents you only 2 spaces (if auto-indent is on).

But then, hitting return after typing the closing bracket ] after :second-val, the cursor should then be placed on the next line and indented two spaces, according to the style guide. But VSCode "intelligently" decides that you're trying to indent everything at the same indentation as the last couple variables, so it then puts you directly under the y, even though this time that's not what you wanted.

I think the parinfer plugin takes care of some of this if you're using the right setting, but I type pretty fast, and parinfer becomes very unpredictable with fast typing because it has slow response time. And personally, I'd rather have to manually format stuff than have to manually undo unpredictable plugin behavior.

Being a maintainer is a good suggestion, but I'm already struggling to finish projects I'm already committed to :(

@PEZ
Copy link
Collaborator

PEZ commented Mar 30, 2018

Thanks. I'll have a look at how these things are determined in VS Code. The responsibilities among the different plugins and core VS Code are unclear to me. But it makes some sense that this plugin should try take care of autoindenting.

@trevor-brandt
Copy link
Contributor Author

And just to follow-up about the parinfer extension... suddenly it's working a lot better, even though there hasn't been any updates. I wonder if something about VSCode got updated or maybe turning paredit back on somehow makes it interact and work better, though I don't see how. But it's suddenly feeling very usable to me, which is awesome! Honestly, if all this keeps working in conjunction with your plugin, the only Clojure integration that I would really feel like VSCode is missing is the auto-indentation issue. That would be amazing. If you decide to tackle it sometime, I'd be happy to help you test and give suggestions for different indentation cases. (Least I could do, of course, given that you're doing the heavy lifting.)

@PEZ
Copy link
Collaborator

PEZ commented Mar 31, 2018

Hello. Started a new issue, #3, for this auto-indentation business. Please feel invited to add more examples.

See also #4.

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