Fork me on GitHub
#cursive
<
2023-02-02
>
grav08:02:29

We have a "private" repo defined in our project.clj like so:

:repositories [["private-repo"        {:url ""
                                       :username      :env/PRIVATE_MVN_USERNAME
                                       :password      :env/PRIVATE_MVN_PASSWORD
                                       :sign-releases false
                                       :checksum      :fail}]]

grav08:02:02

Whenever I use Refresh Leiningen Projects, I get a dependency resolution error. Works fine from the cli with lein deps, as long as the env-vars are set up correctly. So I'm thinking it's related to the missing env vars. Can I somehow get Cursive to resolve those?

grav08:02:27

@U0567Q30W Hope it's okay to ping you (again 😉) - threads get burried pretty quickly here

cfleming09:02:05

It is! I’ll try to take a look at this over the weekend.

cfleming09:02:52

Which platform are you on? Getting IntelliJ to see env vars can be a real pain.

grav09:02:03

I'm on Linux. Can also test on Mac

cfleming09:02:05

So the issue here is that IntelliJ invokes lein in-process to do that operation. That means that IntelliJ itself will have to see those env vars for this to work. Do you know how to make that happen on your distribution?

cfleming09:02:24

Depends how you invoke IntelliJ, I guess.

grav09:02:44

Ah, okay, that makes sense. I can try launching IntelliJ from bash and see if it will pick up the env vars 👍

grav09:02:59

And if it does then I can probably get my app launcher to pass them on

cfleming09:02:02

Let me know if that doesn’t work.

grav09:02:14

Will do! Thanks for the suggestions 🙏

cfleming09:02:45

No worries! I was thinking about some way to pass env var values to lein through the UI, but I’m guessing you don’t want to be configuring your secrets in the preferences.

cfleming09:02:17

So if you can inherit from the environment that’s probably a better solution.

grav09:02:37

Well, it wouldn't be a no-go in this case. I was looking for a place to do that, but I gave up 🤷 It would be nice if it were per-project (like I have .envrc setup per project-dir), not sure if that would be an IntelliJ feature or a Cursive feature?

grav09:02:11

In any case, it's not a deal-breaker if I need to launch IDEA with those env vars, so I'll look into that first

cfleming09:02:51

So there’s this: https://github.com/ashald/EnvFile, which I did some work to support a while back. But that’s just for run configs. I’ll see if I can hook into it somehow.

👍 2
anovick11:02:23

Hello friends, I am new to using Cursive. What action can I use to send an expression to a working REPL in the side pane?

onetom11:02:48

u should put your whole question into a single message next time, so it's easier to respond to it on a thread. u can also number the options, so we can refer back to it easily in a response.

onetom11:02:48

here u can find some animations showing how these operations work

onetom11:02:22

if i remember correctly

anovick11:02:39

What is the difference between the two actions?

anovick11:02:43

what does Top form mean?

onetom11:02:02

i usually just use the "Send top form to REPL", because i can be in the middle of a deeply nested expression and it would still evaluate the whole expression up to the top-level of the file (or to the (comment ...) expression containing it)

anovick11:02:40

makes sense

onetom11:02:08

top-form means, it's not within some other expression. a (comment ...) expression is an exception though. everything within it is still considered top-level

onetom11:02:02

if u leave expressions within a (comment ...) in your source code, those are referred to as "Rich comments", because Rich Hickey popularized this tactic. u can provide examples of how to use adjacent code within such blocks or show the REPL session of the thinking process, which lead to a specific implementation.

clojure-spin 2
anovick11:02:44

oh haha that's interesting

anovick11:02:31

thanks :hugging_face:

anovick11:02:20

is that "Send top form to REPL" ?

anovick11:02:46

or "Send Form before Caret to REPL"

anovick11:02:08

I just learned I can go to implementation code with the action "Go to implementation" is there a way to return back to the file where I called this action from?

onetom11:02:55

yes, with cmd-opt-left

anovick11:02:18

oh that's great but do you know what action this is?

anovick11:02:25

or maybe I can look up in keymaps

onetom11:02:25

it's the Navigate / Back action in the menu

❤️ 2
onetom11:02:44

u can look up actions based on their keyboard shortcuts too btw

onetom11:02:13

if u hop on this screen sharing session, i can show u around https://pop.com/j/895-310-241

anovick11:02:16

this is sweet 🙂

onetom11:02:21

i have ~30 mins to help, if u want

anovick11:02:49

you're very generous

anovick11:02:01

can I use this opportunity another time perhaps when you're available?

anovick11:02:26

I have other obligations to attend to at this hour...

onetom11:02:35

sure. i live in GMT+8 and i usually have some time around this hour

onetom11:02:45

just DM me to see if im available

anovick11:02:07

very happy to receive your kind attention 🙂 thanks and have a great day

onetom11:02:51

i love to help with the workflow, because that can make ppl a loooot lot more effective at learning clojure. they can focus on the meat of the language and the std lib, instead of fighting with the tooling.

gratitude-thank-you 2
anovick11:02:51

yea it's hard to set everything up! glad to have people like you around to help out

onetom11:02:59

very little effort at the beginning can save tremendous amount of pain later, so i think it makes a lot of sense to help ppl out, so there can be more clojure programmers out there 🙂

anovick11:02:21

definitely appreciated

onetom11:02:15

well, see u later then, when u have more time! but keep asking in the meantime and also read thru the official cursive users manual, because it's pretty good and relatively short too.

anovick11:02:33

will do. take care :hugging_face:

onetom11:02:10

also https://clojure.org/guides/getting_started is pretty useful im still referring to it after almost a decade of using clojure, because it's getting extended with docs about newer features, like tools.build

👍 2
clojure-spin 2
staypufd05:02:26

This training session you offered would be great to see as a video of setting stuff up and the basics of using Cursive effectively. I’d love to watch that.

👍 1
onetom11:02:47

does anyone have a list of ALL Cursive menu items in markdown format? it would be helpful to help others out faster, because we can just copy-paste things, like

`Main Menu` / `Tools` / `REPL` / `Send Form Before Caret to REPL
` because we can just full-text search such a file.

clojure-spin 2
cfleming22:02:27

This is actually trickier to generate than you might think. However I do generate a similar list as part of my documentation generation. I could potentially create a doc page containing this, as well as the settings.

onetom05:02:33

i didn't say generate, just asked if anyone has a list 🙂 if no one has, i will just start typing up a list as need arises

cfleming09:02:31

True, but after maintaining my doc by hand for ages, whenever I hear anything like that, I immediately think: generate, don’t maintain by hand 🙂. I’ll see if I can get that into the doc.

clojure-spin 2
onetom11:02:18

similarly a file for the various cursive / clojure preferences would be helpful too, so it's easier to put together a documentation for company-specific, recommended settings

4
onetom11:02:31

for example, we have a Notion page like this now

onetom11:02:11

i have to say, that emacs is better in this respect, because i could communicate a set of settings via a trivial program, which sets customization or regular variables, regardless of the categorization (because the setting category is already encoded in the setting name)

👍 2
anovick11:02:16

I'm not sure why but "Send Form Before Caret to REPL" key binding doesn't seem to work for me I also don't have this action listed in "Find Action" menu

onetom12:02:07

u have to have some expression before your caret. if u r inside some symbol, string or keyword, then there is no complete form before the caret

❤️ 2
onetom12:02:28

maybe u can think of this operation as "(the previous complete) form left of the cursor or above the cursor, if there are only spaces left of it"

onetom12:02:02

CIDER for Emacs has a cider-eval-last-sexp operation and explains last-sexp as: > the form preceding the cursor — https://docs.cider.mx/cider/usage/code_evaluation.html

onetom13:02:57

there is a "form before caret" if the cursor - shown as - is at the following positions:

(prn• "asd")  123
(prn "asd"•)  123
(prn "asd")•  123
(prn "asd") • 123
but u the form before caret is deemed ambiguous, if the cursor is in the following positions:
(pr•n "asd")  123
(prn •"asd")  123
(prn "as•d")  123
(prn "asd")  •123
(prn "asd")  12•3
so u won't have the Send Form Before Caret to REPL operation available

🤯 2
clojure-spin 2
onetom13:02:09

at the beginning, i recommend to use the Opt-Up/Down aka Extend / Shrink Selection commands to see where the expression boundaries are, until u can see it without explicit selection too.

❤️ 4
onetom13:02:27

and when u have already selected some valid and complete forms with these commands, u can use either Send ... to REPL operations to evaluate that selection.

👍 2
onetom13:02:42

this way u can even ignore the Send Form Before Caret to REPL commands and always just use the Send Top Form to REPL with or without a selection. it would 2 multiple keystrokes, but since it's a rarely needed operation, it might worth using it, since it requires a simpler mental model.

anovick18:02:07

@U086D6TBN that's so awesome

onetom05:02:59

MVP? Minimal Viable Product? 🙂

staypufd05:02:57

Most Valuable Player for sure. Thanks for sharing alll these things.

Rachel Westmacott16:02:00

Would it be possible for REPL configurations to come pre-populated with the selected aliases in a deps.edn project? I have to select the aliases I'm using in the 'Clojure Deps' pane to make the IDE understand my project, and then I also have to specify them in the run configuration for the REPL to make my REPL work. It would be great if Cursive did something clever here (though I confess I've not thought through the consequences), even if it just pre-filled the currently selected aliases at the time you create the run REPL configuration.

cfleming22:02:23

The issue that I can think of is that for syncing aliases to a project I usually use the superset of all aliases I might want, to ensure that all the sources are available. For example, you might not want your test alias enabled in your REPL, but you definitely want it for editing.

Rachel Westmacott09:02:11

It's rare that i don't want the test alias enabled in my REPL - or at least I see no harm in having the source on the classpath, but it would be nice not to have the :main-opts. This clearly relates to the other thread: https://clojurians.slack.com/archives/C0744GXCJ/p1675354446280009

Rachel Westmacott16:02:06

On the subject of REPLs and deps.edn files, it would also be nice if the REPL run configurations ignored the :main-opts of the specified aliases. If you're running a REPL I can't imagine them being useful.

cfleming22:02:44

So I recently fixed this (or broke it, depending on your point of view). See https://github.com/cursive-ide/cursive/issues/2322 for some discussion.

cap10morgan16:02:39

I switch those to :exec-fn to solve that issue. And I assumed that was (part of) the motivation for that feature in tools.deps? But it's not a drop-in replacement.

anovick18:02:22

Just learned I can make my parens rainbow colored 😮 and also I can separate the REPL outputs 🤯 man I'm having so much fun with this

🌈 8
kennytilton19:02:19

We call this "the Lisp curse". It's so much fun we forget to do the work intended.

😆 4
😁 2
clojure-spin 2