Fork me on GitHub
#cursive
<
2023-09-20
>
Jakub Holý (HolyJak)19:09:12

Hi! Didn’t cursive have some feature to complete methods when you write the object? But I see nothing about it at https://cursive-ide.com/userguide/editing.html🙏

isak22:09:06

Yea you may mean this thing, where you write the method call in the 'wrong' order, then Cursive will switch it when you confirm the method:

isak22:09:39

After I pressed tab:

😲 1
onetom16:09:09

i've noticed method autocompletion issues in the past days. i got the impression that some regression might have been introduced. i can't reproduce it reliably though.

Jakub Holý (HolyJak)17:09:03

I guess that's it, thank you.

Sahil Dhanju21:09:18

How do I create a run configuration which is a REPL but runs my -main first?

isak22:09:26

Here is one way: 1. Create a folder called dev 2. Add an alias (e.g., :dev) that will add that folder to the source paths 3. Add a file dev/user.clj, put your code in that file (or call your function) 4. Create a REPL config that uses that alias. (Put it in the 'Run with Deps' option: -A:dev

Sahil Dhanju23:09:37

Thanks! I will try this next chance I get. One thing I did try was simply calling (-main) which did run it but because I'm running a small web server, my repl was hanging since my (-main) does a join on the web server thread. How do what you described above but have the repl in a separate process? Remote REPL doesn't seem like what I want exactly. Seems similar to lein trampoline?

isak14:09:04

Usually for that, you just check if it is the dev environment, and then only join the web server thread if it is production. Or wait for a promise that never gets delivered in the main method, no need for the server join feature.

onetom16:09:52

also, why would u want to immediately run a web server? that assumes that u load your whole application, which assumes that your whole application is a loadable state. what if it is not? then your REPL startup would fail, leaving u having no REPL, which makes it harder to fix the issue, which prevented your startup? a better approach would be to create a REPL command (in Settings / Languages & Frameworks / Clojure / REPL Commands), which evals the expression required to start your REPL. then u can just execute this command through the Cmd-Shift-A action menu or Double Shift search everywhere menu, and maybe assign some abbreviation or keyboard shortcut to it. that way it's also more obvious that u want that expression to return after the server has been started.

onetom16:09:43

similarly, we have defined REPL commands to run tests with kaocha, for example. as your application grows, it takes longer and longer to load the whole of it, so it will start to make more and more sense to get a REPL as quickly as possible and then only load namespaces which u actually need for whatever you are trying to do. it's very much possible that u just want change something in a ring handler for example. to run the tests just for that ring handler function, u don't need the routing and request/response coercion libraries loaded. etc.

onetom16:09:37

we very rarely need to start a local web server for example. we do have a handful of automated tests though, which start (and stop) throw-away web servers on a random port, but their lifetime is are managed by our test harness. still, most often we just need to run tests which doesn't require a web server.

Sahil Dhanju18:09:50

@U086D6TBN I'm very new to clojure so most definitely am not working in the most idiomatic way. My want is to have my application running and then connect a repl into it so I can poke around. This isn't for normal workflow but just for the sake of poking around the running application

Sahil Dhanju18:09:43

@U08JKUHA9 by waiting for a promise that never gets delivered isn't the main thread still waiting on that?

isak18:09:40

@U05N8AJMWQG yea, I mean that is something you might do in a -main function, but not elsewhere

Sahil Dhanju18:09:45

Oh I think I misunderstood you, you were saying a promise that never gets delivered and join are the same thing? Which makes sense to me

👍 1
onetom22:09:35

@U05N8AJMWQG > My want is to have my application running and then connect a repl into it so I can poke around that's also possible, if - from your -main function - u either 1. start an nrepl programmatically, something like this:

(try (nrepl.server/start-server :bind "0.0.0.0" :port 3001)
     (catch BindException _ (println "REPL port 3001 is already in use!")))
2. open up a socket REPL via a JVM option, like -Dclojure.server.repl={:address,"0.0.0.0",:port,5555,:accept,clojure.core.server/repl} then connect to them via remote REPL run configurations.

Sahil Dhanju22:09:02

I'll try this next chance I get, thanks!

👍 1