Clojure support for Visual Studio Code.
I'm trying, believe me!
- Code completion
- Code navigation
- Interaction with REPL
- Showing documentation on hover
- Function signatures
- Linting
- Debug
This extension relies on Cider nREPL.
This means you will need to add it to your profiles.clj
. Put the following content to your ~/.lein/profiles.clj
:
{:user {:plugins [[cider/cider-nrepl "0.13.0"]]
:dependencies [[org.clojure/tools.nrepl "0.2.12"]]}}
-
Create a Clojure project you wish to connect to. For this guide we will use Leinigen
$ lein new hello-vscode
-
Start a REPL in your terminal, and note the port the REPL is listening on
$ cd hello-vscode $ lein repl nREPL server started on port 45247 on host 127.0.0.1 - nrepl://127.0.0.1:45247 REPL-y 0.3.7, nREPL 0.2.12 Clojure 1.8.0
Note the port that your nREPL is listening on, in this case 45247 because you may need it later.
-
Now Let's Connect to the REPL.
3.1 Open the project folder in VS Code.
-
Open a clojure source file such as
src/hello_clojure/core.clj
If you have a repl running, the connection should be made automatically and you should see a repl indicator the status bar that looks like
nrepl://localhost:45247
.If you see the indicator, good news you're connected. Please move onto next step.
-
If you DO NOT see the connection indicator, or if you'd like to connect to a remote repl, we will need to create the connection manually.
Open the command pallet and select the command
Clojure: Connect to nREPL
You should then be prompted for an nREPL port, enter the port noted in step #2,
45247
.You should then be prompted for the host of the REPL. In this example we will enter
localhost
.You should then get a message showing successful connection to the nREPL!
-
-
Eval a file. The repl needs to have it's namespace initialized and set so it can know about and show things like your docstrings.
-
Open a Clojure source file
-
Open the command pallet, and select the command
Clojure: Eval
.This should evaluate the entire file, and a file successfully compiled notification should be shown.
-
-
Eval a selected expression
-
Show the output window by using the View / Output from menu bar if it's not already visible.
-
Select a block of code you wish to evaluate.
-
Open the command pallet, and select the command
Clojure: Eval and show the result
. -
Results from the REPL should be printed to the output window named
Evaluation Results
-
-
All done, you're ready to code some Clojure :)
Most likely you forgot to add cider-nrepl
to the list of dependencies. Please,
consult How to Use?
section.
You should eval the file first using the Eval
command.
If you see a nrepl://nreplhost:nreplport
status bar item, most likely you
are connected :)
Open an issue if you want to propose new features and ideas or to report bugs.
This is how you run this extension from source:
-
Download the source code and install npm dependencies;
git clone https://github.com/avli/clojureVSCode.git cd clojureVSCode npm install code .
-
Make the changes you want;
-
Open
debug
, selectLaunch Extension
and click onStart Debugging
to open a new vscode window with your modified extension.
Visual Studio Code has great docs about developping extensions. Check it out.
Fork us! Pull requests are welcome! :D