Fork me on GitHub
#conjure
<
2022-11-16
>
Martynas Maciulevičius11:11:26

How does one start a REPL to connect to when project is using tools.deps? I think when I write clj it doesn't have nREPL middleware

Olical11:11:37

I'd recommend either vim-jack-in to start a tools.deps REPL with an nREPL connection OR go through the nREPL / cider documentation websites, they have a bunch of examples of config and one liners that start an nREPL.

Olical11:11:03

The CIDER website / documentation is probably the best one since it include nREPL and the CIDER middleware.

Olical11:11:11

Sorry I don't have a link, I'm on my phone!

practicalli-johnny12:11:10

I have several aliases in the user level configuration for starting a Repl via the command line (which I start before opening a Clojure file in Conjure) https://github.com/practicalli/clojure-deps-edn#repl-terminal-ui In basic terms, include the nrepl library as a dependency and call nrepl. Cider middleware is also required for full Repl support when using Conjure. So for a headless terminal Repl, run clojure -M:repl/headless

;; Simple nREPL server REPL with Cider & Conjure support, headless
  :repl/headless
  {:extra-deps {nrepl/nrepl       {:mvn/version "1.0.0"}
               cider/cider-nrepl {:mvn/version "0.28.5"}}
   :main-opts  ["-m" "nrepl.cmdline"
                "--middleware" "[cider.nrepl/cider-middleware]"]}

🆒 2
💯 3
practicalli-johnny12:11:48

Or if Repl prompt is required

:repl/interactive
  {:extra-deps {nrepl/nrepl {:mvn/version "1.0.0"}
                cider/cider-nrepl {:mvn/version "0.28.5"}}
   :main-opts  ["-m" "nrepl.cmdline"
                "--middleware" "[cider.nrepl/cider-middleware]"
                "--interactive"]}

Martynas Maciulevičius15:11:21

Thanks. This was exactly what I was asking about (didn't test but I already have this setup with Leiningen). I'd like to have this pasted into the README of Conjure so that there wouldn't be a need to look for it.

Olical15:11:11

Pretty sure it's on the Clojure nREPL quick start wiki page :thinking_face:

Martynas Maciulevičius15:11:46

Ah, this was what I was looking for: https://github.com/Olical/conjure/wiki/Quick-start:-Clojure#with-clojure-cli I didn't want to delve too much into how tools.deps works, I wanted to run it and figure out later.

practicalli-johnny16:11:17

Leiningen has nREPL built in, so its always there when using lein repl Clojure CLI (tools.deps) is a lot more possible options even for starting a REPL process, (socket, prepl, nrepl, etc) so does not provide anything by default.

Martynas Maciulevičius07:11:24

Why would one want a non-interactive REPL? I think that even if I connect to it from a tool like Conjure I still want to have it as interactive because it helps to debug if it's the REPL that hangs or the editor. The only place where I would be ok with non-interactive REPL is on some kind of deployment where I'll have to connect to REPL. But even then I'd probably want to use interactive too. I don't understand why you have both configs in your user config. Do you even use non-interactive one?

rgm18:11:49

I just keep a shell script in ~/bin/repl. I might have more specialized ones in project directories, that maybe export some env vars or set up different tools.deps aliases:

#!/usr/bin/env bash

clj -Sdeps '{:deps {nrepl/nrepl {:mvn/version "RELEASE"} cider/cider-nrepl {:mvn/version "RELEASE"}}}' -M -m nrepl.cmdline --middleware '[cider.nrepl/cider-middleware]' --interactive --color

rgm18:11:33

guess that's pretty similar to the conjure quickstart

Martynas Maciulevičius19:11:57

Ah, but that's skips leiningen then :thinking_face:

practicalli-johnny13:11:18

This reminds me, I should update the deps versions in the Conjure quickstart examples…

walterl18:11:54

I use https://github.com/walterl/dotfiles/blob/master/_config/nvim/plugin/clj_jackin.vim`RunClj`https://github.com/walterl/dotfiles/blob/master/_config/nvim/plugin/clj_jackin.vim, which is a severely stripped down version of vim-jack-in's Clj command. The main feature is that it does less, so you can take more control over things like :main-opts via aliases in deps.edn, to use the sweet solutions like those provided by @U05254DQM and @U08BW7V1V.