Fork me on GitHub
#conjure
<
2020-09-21
>
Aron11:09:22

Can I use conjure with multiple projects at once? Like connect to one thing in one terminal and another in another? I was trying to connect and it kept talking about the other 🙂

Olical11:09:31

Do you mean in one neovim instance or two?

Olical11:09:46

Because if it's two, of course, open neovim in another project and away you go

Olical11:09:01

If it's one neovim instance you'll need to set the state key as you :cd between projects or maybe even as you open different files. This means you set up an autocmd on directory change or on file open that works out which project you're in and runs :ConjureClientState my-project-name where the project name can be any string really

👍 3
Olical11:09:26

Basically by running :ConjureClientState SOMESTRING you can hop into an alternate reality of Conjure where you're connected to something else

Olical11:09:55

It's up to you to set up autocmds / key mappings to hop between client state strings, so you can tailor it to your needs. It's more of a building block than anything.

Olical11:09:09

You could just have two like "a" and "b" and set up a mapping to hop to a and one to b

Olical11:09:45

I use this at work with nvim-local-fennel

(module redacted
  {require {nvim aniseed.nvim}})

(set nvim.g.conjure#relative_file_root "./")

(nvim.ex.augroup :redacted-lnvim)
(nvim.ex.autocmd_)
(nvim.ex.autocmd :DirChanged :* :execute "'ConjureClientState ' . fnamemodify(getcwd(), ':t')")
(nvim.ex.augroup :END)

Olical11:09:05

so as I :cd module/some-module I get an isolated environment for that separate clojure project.

Aron11:09:22

two neovim makes more sense, but I might've been trying in the same one

Olical11:09:01

Yeah, two neovims in two terminals works great for me

Aron11:09:02

and thanks, I that's very helpful, I think I will try it

Olical11:09:25

No problem! The client state stuff basically lets you simulate two entirely separate conjure instances

Olical11:09:55

But two terminals is simpler to do, :ConjureClientState ... is there for when you want to get creative and have things just connect and do what you want in monorepo style projects

jkrasnay11:09:50

I guess the same applies to two nREPLs (e.g. clj and cljs) in the same project. Either you use something like Piggieback or you wrangle :ConjureClientState. Is that right?

Aron11:09:56

Seems like the problem is going to be something WSL related. I opened a completely new terminal and it still tells me that watch for the build is not running and when I want to connect it mentions the other project's namespace

Aron12:09:25

these are completely separated projects in entirely different directories

Aron12:09:36

both shadow-cljs though

Olical12:09:16

@U0DTSCAUU kinda although CLJS + CLJ in one nREPL actually works well through sessions.

Olical12:09:35

You can use session mappings to hop between your Clojure and ClojureScript sessions.

Olical12:09:58

That sounds like your CWD isn't being updated @U0VQ4N5EE?

Olical12:09:10

I'd check :cwd in both terminals, if they're the same you're in the same project

Olical12:09:42

Also if you have two nREPLs with two ports just using :ConjureConnect ... with just the port number for each nREPL in each terminal.

Aron12:09:47

I think it's that, the port was the same, so it didn't start, had probably nothing to do with conjure, sorry for the bother 😞 But at least I learned about ConjureClientState

Olical12:09:36

Not a problem! And yeah, I'd consider client state extremely useful in some cases with some upfront thinking / autocmds but an advanced feature most don't need.

orestis12:09:48

TIL about ConjureClientState 🙂 I’ve been using the session list functionality

orestis12:09:32

The error printer in Conjure seems rather sparse — no stacktrace, no ex-data… I end up evaluating *e in the editor to figure things out. Is this something pluggable via say an nrepl middleware?

Olical13:09:45

I tend to just use *e too, you could rig up a mapping that evaluated *e with whatever wrapper you're interested in at the time via :ConjureEval .... I would imagine nREPL middleware would give you some good hooks into it too! Although I've never tried that myself

Olical13:09:14

I didn't do anything special with the errors because the default seemed pretty good already and I didn't want to step on the toes of middleware / custom setups / environmental differences (cljs / clj etc).

orestis14:09:34

Good pointers, thanks

orestis14:09:23

BTW one thing that I realised might influence the floating window delay that I’m seeing is wrapping. I usually tend to wrap my logs (set wrap) so floating window might have to do a lot of work to show the wrapped results?

orestis14:09:50

I always kind-of expected that the floating window will only show the last evaluation result, not the whole log. But that’s just me 🙂

Olical17:09:18

Only showing the last thing is definitely something worth considering

Olical17:09:48

The current route just means "there's only ever one buffer and we get a little view of it" which is sometimes bad, sometimes good when you want to see a glimpse into your previous evals as the latest one comes back

Olical17:09:56

I find that pretty helpful with my goldfish memory 😬

nate14:09:44

It took me a bit to get used to the error reporting in conjure. Now I'm used to the terse default and use ,ve to show the whole stack trace. I think it's a good balance.

💯 3
orestis16:09:17

I didn’t know there was a mapping, I’ll try that tomorrow.

uwo17:09:52

I love this mapping!

❤️ 3
dharrigan15:09:44

I must be the weird one. I run my repl outside of Conjure and I see everything :)

Olical17:09:04

I rarely run my REPL inside nvim but when I do I use https://github.com/clojure-vim/vim-jack-in

Olical17:09:17

Most of the time I'm REPLing into docker containers (plural)

dharrigan18:09:36

What does vim-jack-in do?

dharrigan18:09:50

I normally have two terms open, one for nvim + conjure, the other running clj

dharrigan18:09:24

since clj is also running nrepl

dharrigan18:09:37

I can simply require a namespace and try things out in the term

dharrigan18:09:41

whilst evaling things in the nvim

Olical18:09:43

Opens a terminal buffer/window/tab in nvim and runs lein/clj etc within it. That's all! It also injects all the magic cider nrepl middleware stuff which can be handy for off the cuff evals

Olical18:09:59

But if you have a working script in another terminal you don't need it

Olical18:09:25

I just use it where my CIDER/Emacs wielding team mates rely on their form of jack in, which usually means the project.clj isn't actually set up properly and they lean on CIDER's jack in

Olical18:09:42

So I do the same but nvim equivalent where it makes sense