Fork me on GitHub
#cursive
<
2023-12-12
>
p-himik11:12:42

Just in case I've missed something and can't figure it out - there's no support for this currently, is there? https://github.com/cursive-ide/cursive/issues/2193 Tried Alt+Enter - nothing. Tried ;;noinspection unused - nothing.

cfleming09:12:50

Ugh, sorry, I’ve partially investigated this multiple times, but not got around to fixing it. I’ve moved this into the next release.

👍 1
isak15:12:42

Not sure if this is the new IntelliJ or a Cursive change, but I notice now when I: 1. right click a folder and click create a new clojure file 2. type a namespace name 3. press enter That namespace is now at the root. This seems like a step backwards from the old behavior, where it would be in the right namespace based on the folder in 1.

👍 1
isak15:12:00

A workaround is to press right arrow, so the text is not selected, and the namespace prefix therefore doesn't get replaced in 2.

imre15:12:22

Yeah I noticed it too but wasn't sure whether it always worked like this or not 😅

👍 1
Ben Kamphaus21:12:36

have also noticed this, and mostly adapted to it w/the right arrow thing mentioned ^

cfleming23:12:42

Yes, I made this change recently, because the IntelliJ new package dialog does this. However, the fact that the text is selected initially is a pain, I’ll see if I can fix that.

💯 1
cfleming00:12:40

Ok, there is absolutely no way to fix this without duplicating all the code involved - it’s all private and final. Would everyone prefer the old way this used to work?

1
imre10:12:28

While I'd prefer the old way, I think I'd rather get used to how it currently works and avoid some future breakage or maintenance issue arising from going against Jetbrains

Anders Corlin11:12:57

> Would everyone prefer the old way this used to work? Haha, interesting to see if you'll be able to get a confirmation from all Cursive users here 😜. I'm fine with either or, hadn't noticed the change 😃

souenzzo11:12:37

I liked that change. I used to create many app.core.app.core.new-ns

imre12:12:13

The improved visibility that comes with the change is nice indeed

👍 2
😨 1
wilkerlucio15:02:01

oh, just found this, because Im having the same issue, making wrong namespaces because of the change: https://clojurians.slack.com/archives/C0744GXCJ/p1707233059463129?thread_ts=1707233059.463129

wilkerlucio15:02:21

would be great if the cursor just started at the end instead of having the text selected

1
cfleming00:03:19

The fix for this is out now, in the latest EAP.

❤️ 3
wilkerlucio14:03:14

working great! thanks!

JAtkins18:12:44

is it possible for some extension points to be added to cursive leveraging the NREPL connection to my app? I'd love some way to add e.g. project defined documentation for keywords. Or, "goto definition" for keywords. Or, ... actually alot of my ideas are surrounding keywords 😂. But some way to add nrepl middleware for cursive where I can plug the handlers for those requests would be top tier.

imre21:12:08

where would goto definition on a keyword take you?

JAtkins21:12:08

A couple different places potentially. I use fulcro defattrs generally, so that would be nice for my own projects. I'm fairly certain that other projects have similar "def kwd" type calls too.

1
JAtkins04:01:52

@U0567Q30W is this feature idea interesting / possible? I know next to nothing about IJ plugins and UI requirements so it could easily be technically infeasible for all I know... But if it's not that would be 🔥.

cfleming20:03:33

My apologies for this taking so long to get to. I’m not sure about making this pluggable, but Cursive does actually support this for some keyword use cases, e.g. spec:

(s/def :order/date inst?)
(s/def :deck/suit #{:club :diamond :heart :spade})

(s/valid? :order/date (Date.))
(s/conform :deck/suit :club)

cfleming20:03:12

Here, you can navigate to :order/deck, use find usages, etc. It requires me to add support for forms using this currently, I’d be interested to know if there are common cases that are missing.

imre20:03:36

There is https://plugins.jetbrains.com/plugin/18019-integrant which adds support for navigating to integrant component definitions. I use this and find it useful

cfleming20:03:01

Thanks, I’ll take a look and see what it’s doing.

JAtkins20:03:48

I've recently retrofitted VSCode with kw-docs that I hand rolled for my work app for example. I've also added some goto-definition that goes to com.fulcrologic.rad.attributes/defattr definitions.

cfleming20:03:12

How does that work?

cfleming20:03:44

What I mean by that is, what’s the logic you’re using to populate that popup?

JAtkins20:03:09

This is probably also a pain to implement, but using the NREPL support from calva and some custom relation

JAtkins20:03:05

> What I mean by that is, what’s the logic you’re using to populate that popup? I have a function in my code that searches for defattr s, and populates the popup with generically relevant information of all related defattrs

JAtkins20:03:53

currently this requires a running repl connection, but it may be possible to just create static dumps of this as edn, if that's workable

cfleming20:03:41

So, you have features for: navigation (going to definitions based on some logic), documentation (generated based on some custom logic) and… is that last one completion?

JAtkins20:03:08

yep, this one is completion based on var attrlists

cfleming20:03:17

I see, that one I could potentially do generically in Cursive, which would be a nice addition.

cfleming20:03:45

The issue with a lot of this is that Cursive doesn’t use the REPL for any of that functionality. So that makes it harder to hook into.

cfleming20:03:09

How do you calculate the related kws in the case of defattrs? I’m not really sure how those work.

JAtkins20:03:49

I'm contemplating hooking that up with guardrails, but I've not had time free to make that happen yet. Anyway, just some ideas I've been messing with that would be awesome for cursive as well.

JAtkins20:03:07

sorry for the unrelated msg, my internet dropped out

cfleming20:03:36

Absolutely, I’d like to try to support some of these, but I’ll have to think about how to do it. It’s not as simple as just hooking into nREPL, sadly.

JAtkins20:03:18

there's another, potentially nearer at hand solution - using clojure-lsp? It already has support for library-specific metadata collection, and it's hooked into IJ. I think the important metadata from stuff like fulcro can be dumped as edn for completion/gotodef/docs

JAtkins20:03:51

I'd have to check, but I think clojure-lsp has pluggable versions of all of the above

cfleming20:03:16

Ok. I’m planning to integrate lsp into Cursive in some degree in the next release.

cfleming20:03:01

Which metadata from fulcro do you use?

JAtkins20:03:19

Primarily anything from a defattr

cfleming20:03:02

So in that case, I’m unsure what that’s doing. It looks like it’s defining a var and a keyword?

JAtkins20:03:58

The var is a map... e.g.

(defattr state :address/state :enum
  {ao/enumerated-values (set (keys states))
   ao/identities        #{:address/id}
   ao/schema            :production
   ao/enumerated-labels states})
compiles to
(def state {::attr/qualified-key :address/state ::attr/type :enum ao/enumerated-values ...})

cfleming20:03:52

And you’d want to be able to navigate from :address/state to that defattr?

cfleming20:03:08

Ok. That’s quite easy, I can add that.

cfleming20:03:36

This stuff will eventually be user-extensible, but it’s not yet.

JAtkins20:03:49

I'm not sure all fulcro people would like that, since I know one or two that still use specs, though I'm not sure if they use gotodef on those specs

cfleming20:03:39

Ok, I’ll check with Tony, he uses Cursive (or did, anyway).

JAtkins20:03:52

still does to my knowledge

cfleming20:03:41

So from the defattr, which kws do you consider related?

JAtkins20:03:59

There's typically an :something/id type keyword, and anything with ao/identities #{:something/id} is related, which may be across multiple files

JAtkins20:03:53

e.g. in the address file, every property on an address has ao/identities #{:address/id}

cfleming20:03:51

Interesting, I see. That’s tricky.

hlship22:12:37

Is it possible/reasonable for Cursive to recognize carriage returns in the REPL output and to move the cursor as would happen in a terminal window? This is for a simple text-based progress bar for some long running output.

Ivar Refsdal08:12:51

A possible workaround is using this (which is supported by Cursive):

(println (str "Hello" \u001b "[1KWorld"))
from the issue https://github.com/cursive-ide/cursive/issues/2555

hlship00:12:56

Thanks, yes, Cursive does support that ANSI code.

hlship22:12:15

Works as I'd like in a normal REPL but not in a Cursive REPL.

hlship22:12:08

And, hey, if you could implement more of the ANSI escape codes, such as Cursor Position and Erase in Line that would be great, too!