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

Make auto-connect watch the repl port file and connect when it changes/appears #2639

Open
PEZ opened this issue Sep 29, 2024 · 0 comments
Open

Comments

@PEZ
Copy link
Collaborator

PEZ commented Sep 29, 2024

Today the auto-connect setting makes Calva attempt a connect when a workspace is opened. So a workflow like:

  1. Start a repl for a project
  2. Open the project workspace -> Calva connects the repl

works, including:

  1. Keep a repl running for a project
  2. Every time you open the project workspace, Calva connects the repl

However, it would be nice to also support this workflow:

  1. Open a project workspace
  2. Start a repl for the project -> Calva connects the repl

And also:

  1. Calva is connected to the repl
  2. The repl is restarted
  3. Calva reconnects the repl

This can be achieved with Joyride (of course). Something like this workspace script will do it (assuming the template workspace script that ships with Joyride):

(defn- my-main []
  (clear-disposables!)
  ...
  (println "Creating .nrepl-port watcher")
  (let [absolute-path (str vscode/workspace.rootPath "/.nrepl-port")
        watcher (vscode/workspace.createFileSystemWatcher absolute-path false false true)
        callback (fn [_uri]
                   (println ".nrepl-port file changed, reconnecting...")
                   (vscode/commands.executeCommand "calva.connect"))]
    (push-disposable watcher)
    (.onDidCreate watcher callback)
    (.onDidChange watcher callback))
  ...
  )

But I think it makes sense to offer it to Calva users without resorting to Joyride scripting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant