Skip to content

Commit 30c1b58

Browse files
authored
Update nREPL server doc with supported and unsupported editors (#940)
Hi, I have updated the nREPL server documentation in the `cli` section to provide new instructions on how users can start the server for their editor. Additionally, I've a reference to it in the `REPL` page, so users whoa re likely to be looking for the nREPL server, can locate it more easily. I consider promoting the nREPL section to a new page next to `REPL`, but decided to be discreet for now. Any feedback would be greatly appreciated. Thanks --------- Co-authored-by: ikappaki <[email protected]>
1 parent e7a027f commit 30c1b58

File tree

2 files changed

+67
-9
lines changed

2 files changed

+67
-9
lines changed

docs/cli.rst

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,82 @@ The builtin REPL supports basic code completion suggestions, syntax highlighting
3737
Start an nREPL Session
3838
----------------------
3939

40+
An nREPL server provides an interactive REPL environment for remote code execution and development from an editor.
41+
4042
Basilisp's CLI incorporates an nREPL server adapted from `nbb <https://github.com/babashka/nbb>`_.
4143

42-
To start the server from the command line use the following command
44+
Start from an editor with a Clojure extension supporting Basilisp
45+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
46+
47+
.. note::
48+
49+
The extension's ``Jack-in`` command is used to start an nREPL session and connect your editor to it.
50+
51+
With Emacs `CIDER v1.14 <https://docs.cider.mx/cider/platforms/basilisp.html>`_ and Visual Studio Code `Calva v2.0.453 <https://calva.io/basilisp/>`_ or later, you can ``Jack-in`` to a Basilisp project directly.
52+
The extensions also recognize Basilisp ``.lpy`` files as Clojure files.
53+
54+
To ``Jack-in`` to a Basilisp project
55+
56+
1. Ensure that a ``basilisp.edn`` file is present at the root of your project, even if it is empty.
57+
2. Run the ``Jack-in`` command in your editor and select ``Basilisp`` if prompted.
58+
The Editor should then start the server and connect to it.
59+
60+
Start from an editor with a Clojure extension not yet supporting Basilisp
61+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
62+
.. note::
63+
64+
The extension's ``connect`` command is used to connect your editor to a running nREPL server.
65+
It requires the port number where the server is running at.
66+
67+
.. note::
68+
69+
Basilisp code files use the ``.lpy`` filename suffix.
70+
You might need to adjust your editor's extension settings to recognize this suffix as a Clojure file.
71+
Alternatively, you can evaluate code inside ``.clj`` files, though importing these files from other Basilisp files might not be possible due to the different file extension.
72+
73+
If your editor extension does not yet support Basilisp, or if you prefer more control over the nREPL server, you can start the server from the command line and connect to using your extension's ``connect`` command.
74+
75+
The nREPL server when started will provide the host and port number it is listening on.
76+
77+
To view available command line options, use
78+
79+
.. code-block:: bash
80+
81+
basilisp nrepl-server -h
82+
83+
84+
To start the server on a random port, use
4385

4486
.. code-block:: bash
4587
4688
basilisp nrepl-server
4789
# => nREPL server started on port 50407 on host 127.0.0.1 - nrepl://127.0.0.1:50407
4890
49-
You can then establish a connection from your IDE to the server address.
5091
51-
- from `Emacs`, using `CIDER <https://github.com/clojure-emacs/cider>`_
92+
To start the server on a specific port, use
93+
94+
.. code-block:: bash
95+
96+
basilisp nrepl-server --port 8889
97+
#=> nREPL server started on port 8889 on host 127.0.0.1 - nrepl://127.0.0.1:8889
5298
53-
.. code-block::
99+
Some extensions can connect to a running server automatically by looking for a ``.nrepl-port`` file at the root of the project. This file contains the port the server is listening on.
54100

55-
M-x cider-connect-clj
101+
The ``nrepl-server`` command will generate this file in the current working directory where the server is started.
102+
If your extension's ``connect`` command looks for this file, run the server command from the root of the project, so that is generated in there
56103

57-
- from `Visual Studio Code`, using `Calva <https://calva.io/>`_
104+
.. code-block:: bash
58105
59-
.. code-block::
106+
cd <project-root-directory>
107+
basilisp nrepl-server
108+
#=> nREPL server started on port 632128 on host 127.0.0.1 - nrepl://127.0.0.1:63128
109+
110+
Alternatively, specify the full path where this file should be generated using the ``--port-filepath`` CLI option
111+
112+
.. code-block:: bash
60113
61-
REPL -> Connect to a running REPL in your project -> Generic
114+
basilisp nrepl-server --port-filepath <project-root-directory>/.nrepl-port
115+
#=> nREPL server started on port 62079 on host 127.0.0.1 - nrepl://127.0.0.1:62079
62116
63117
.. _run_basilisp_code:
64118

@@ -145,4 +199,4 @@ If you would like to remove the bootstrapped Basilisp from your installation, yo
145199

146200
.. code-block:: bash
147201
148-
basilisp bootstrap --uninstall
202+
basilisp bootstrap --uninstall

docs/repl.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ The default REPL namespace is ``basilisp.user``, but users can modify that at st
2222

2323
REPL is an acronym meaning ``Read-Eval-Print-Loop`` which is refreshingly self-descriptive.
2424

25+
.. seealso::
26+
27+
:ref:`start_an_nREPL_session`
28+
2529
.. _repl_utilities:
2630

2731
REPL Utilities

0 commit comments

Comments
 (0)