Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Changelog

## master (unreleased)
- new command `cider-start-server` which does the same as `cider-jack-in` but without trying to connect to the started nREPL server


## 1.9.0 (2023-10-24)

### New features

- [#3529](https://github.com/clojure-emacs/cider/issues/3529): CIDER inspector: introduce `cider-inspector-previous-sibling`, `cider-inspector-next-sibling` commands ([doc](https://docs.cider.mx/cider/debugging/inspector.html#usage)).
- [#3548](https://github.com/clojure-emacs/cider/issues/3548): CIDER inspector: introduce `cider-inspector-tap-current-val` command ([doc](https://docs.cider.mx/cider/debugging/inspector.html#usage)).

Expand Down
40 changes: 34 additions & 6 deletions cider.el
Original file line number Diff line number Diff line change
Expand Up @@ -1326,23 +1326,51 @@ nil."
map)
"CIDER jack-in and connect keymap.")


(defun cider--do-start-server (params on-port-callback)
"Starts an nrepl server and passes the callback to it.
PARAMS is a plist optionally containing :project-dir and :jack-in-cmd.
ON-PORT-CALLBACK is a function of one argument (server buffer)
which is called by the process filter once the port of the connection has
been determined. Can be nil."
(nrepl-start-server-process
(plist-get params :project-dir)
(plist-get params :jack-in-cmd)
on-port-callback))

;;;###autoload
(defun cider-jack-in-clj (params)
"Start an nREPL server for the current project and connect to it.
PARAMS is a plist optionally containing :project-dir and :jack-in-cmd.
With the prefix argument, allow editing of the jack in command; with a
double prefix prompt for all these parameters."
double prefix prompt for all these parameters.

See also: `cider-start-server'."
(interactive "P")
(let ((params (thread-first
params
(cider--update-project-dir)
(cider--check-existing-session)
(cider--update-jack-in-cmd))))
(cider--do-start-server params
(lambda (server-buffer)
(cider-connect-sibling-clj params server-buffer)))))


(defun cider-start-server (params)
"Start an nREPL server for the current project, but don't connect to it.
PARAMS is a plist optionally containing :project-dir and :jack-in-cmd.
With the prefix argument, allow editing of the start server in command; with a
double prefix prompt for all these parameters.

See also: `cider-jack-in-clj'."
(interactive "P")
(let ((params (thread-first
params
(cider--update-project-dir)
(cider--check-existing-session)
(cider--update-jack-in-cmd))))
(nrepl-start-server-process
(plist-get params :project-dir)
(plist-get params :jack-in-cmd)
(lambda (server-buffer)
(cider-connect-sibling-clj params server-buffer)))))
(cider--do-start-server params nil)))

;;;###autoload
(defun cider-jack-in-cljs (params)
Expand Down
18 changes: 18 additions & 0 deletions doc/modules/ROOT/pages/basics/up_and_running.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,24 @@ Here is an example Nbb Jack-In command, providing a custom `:jack-in-cmd`.
(cider-jack-in-clj '(:jack-in-cmd "nbb nrepl-server")))
----

==== Starting nREPL server without trying to connect to it ====

In some situations, it might be useful to only start a nREPL server process, without
connecting to it. This can support complex setups
for which CIDER cannot reliably detect to which server/port to connect, and
would therefore fail.
This assumes that the user will execute a `cider-connect` command manually afterwards,
specifying host/port.

For this scenario, the `cider-start-server` command is offered, which optionally takes the same
parameters than `cider-jack-in`.

Sample usage:

[source,lisp]
----
M-x cider-start-server
----

== Connect to a Running nREPL Server

Expand Down