-
-
Notifications
You must be signed in to change notification settings - Fork 133
Quick start: Clojure
Clojure is a robust, practical, and fast programming language with a set of useful features that together form a simple, coherent, and powerful tool.
Conjure has deep support for Clojure either in the original JVM setting or JavaScript via ClojureScript. We’re focusing on regular JVM Clojure here, see other guides for specifics on ClojureScript since it has its own nuances.
-
Install the latest Neovim.
-
Install the Conjure plugin.
-
Install the Clojure CLI tools (my preference) or Leiningen.
-
Get a project set up with the CLI tools or Leiningen.
You can skip this section by installing vim-jack-in and executing the appropriate command such as :Clj or :Lein. It’ll start an nREPL server with all of the appropriate middleware inside your Neovim instance, you can then connect to it as described in the final section.
Configure an alias in the project or user level deps.edn file to include the appropriate dependencies, e.g. $XDG_CONFIG_HOME/clojure/deps.edn or $HOME/.clojure/deps.edn.
{:aliases
{:repl/conjure
{:extra-deps {nrepl/nrepl {:mvn/version "1.0.0"}
cider/cider-nrepl {:mvn/version "0.42.1"}}
:main-opts ["--main" "nrepl.cmdline"
"--middleware" "[cider.nrepl/cider-middleware]"
"--interactive"]}
}}In the root of the project, start a REPL process and an nREPL server with the added CIDER middleware.
clj -M:repl/conjureAlternatively, you can start the same thing without creating a deps.edn file with this.
clj -Sdeps '{:deps {nrepl/nrepl {:mvn/version "1.0.0"} cider/cider-nrepl {:mvn/version "0.42.1"}}}' \
-M -m nrepl.cmdline \
--middleware '["cider.nrepl/cider-middleware"]' \
--interactiveNow open any .clj or .cljc file and start evaluating! It will automatically connect to the correct host and port as you open a source file, provided .nrepl-port was created when you started your REPL (this should be the case). If not, you can either create that file yourself or use :ConjureConnect [port] to get started. Note that .nrepl-port is in the working directory that you ran clj nrepl.cmdline from, so start nvim in that directory.
If you’re unsure how to evaluate things with Conjure, please refer to :help conjure, :help conjure-client-clojure-nrepl and :ConjureSchool (an interactive tutorial).
Asking for user input with (read-line) might not work with the default session as it does NOT work correctly with the need-input operation. Hit <prefix>sQ to quit ALL nREPL sessions, Conjure will automatically make a new one) that will be set up correctly to prompt for the need-input operation.