Fork me on GitHub
#cursive
<
2024-03-04
>
gtbono20:03:11

is there any way to create a shortcut to execute something like "Last REPL Action" on cursive? It seems like I can only do "Last Test Action"

genekim20:03:45

Hello! I was watching a video that @slipset made doing a refactoring some code I did (which was actually a refactoring of an even earlier version), and saw this: What caught my interest was the “0 references” or “1 reference” in the right-hand gutter, showing how often that function or var is referenced. Is this possible with some combination of Cursive and/or Clojure Extras from @brcosta? TY!!! (PS: does kondo detection of zero referenced var work for everyone? I feel like it doesn’t work for me 80% of the time — for the last 1.5 years, I’ve wanted to come up with a reproduction….).

borkdude20:03:47

This is probably #CPABC1H61 which uses kondo for its linting and analysis

🙏 1
gtbono02:03:38

can't wait for this release @U0567Q30W !! keep up the great work! :star-struck:

💯 1
onetom04:03:36

@U064X3EF3 it's not as effortless as a hover, but almost, if u Cmd-Click (or Middle-Click or Force touch) over a symbol, u do get usages info in an ephemeral popup, including the number of usages and the source-code context of the usage, if u turn that on too. i personally just use Cmd-B. i found the inlays annoying (when i tried it on javascript code), because they make the text jump around a lot. it most disorienting in parameter-name inlays at call-sites, so i wouldn't use it probably.

cfleming01:03:50

Ok, this was both easier and more difficult than I expected. The APIs for this are all marked as internal, so in theory as a plugin author I shouldn’t be using them, but it seems to work. I also found a related problem in the existing marking of vars as unused - like those, and like the Java implementation, this is a best-effort annotation. What that means is that vars with names that are very common appear in lots of places, and that makes the search very expensive for a (semi-)real-time annotation and they won’t be annotated. There was a bug previously which made this extremely conservative for Clojure, so it should work better now, but it’s still noticeable for vars with names which are words which appear frequently (so names like action, project and module in the Cursive source, for example). This means that this is generally useful for finding unused vars, but some will be missed if they have very common names. If an annotation appears, it should be accurate, though.

🔥 1
cfleming02:03:20

These shouldn’t cause code to jump around because they always appear at the end of the line, as with the VCS annotations.

cfleming02:03:55

This will be in the next EAP build. And just to clarify, the kondo bit won’t be in this EAP series, but in the next release (either 1.13.3 or 1.14, depending on how much else happens).

onetom02:03:29

where would the annotation appear, if there is some metadata involved? for example in this case:

(defonce
  ^{:doc "Sequence of authorizations, to see how the id/access/refresh tokens evolve"}
  authzs
  (atom '()))

cfleming02:03:23

Like this:

👍 1
🔥 2
onetom02:03:21

and if it's folded? still works?

cfleming05:03:47

No, looks like not.

genekim06:03:52

Wow!!! Super exciting!!!! 🎉 🙏 ❤️

onetom06:03:54

btw, im not sure whether usage inlays should appear in a folded view. im not trying to suggest they should.

cfleming06:03:28

> im not trying to suggest it should. Sure, no worries. There actually isn’t any logic in the code vision provider about folding, so I suspect inlays are just not shown in folded code. In any case, it’s using the same logic as the Java version, so it’ll be consistent with that.

serioga18:03:36

@U0567Q30W Can we have a usage inlay on the namespace declaration as well?

cfleming21:03:05

Good idea, yes I’ll add that. I noticed that they’re not added to the methods of protocols either, I’ll figure out why.

🙏 1
1
cfleming19:03:15

Namespace decls now have usages as well, and protocol methods as well. There’s a small change in the case with a doc meta, the hint is now shown on the line of the var symbol, like this:

genekim19:03:55

Wooo! Standing by to download! 🎉

cfleming19:03:23

When I say “now”, I mean “in the next EAP build” 🙂

cfleming19:03:03

I’ll be looking to get this into a stable build very soon, since there are fixes to deps and lein I want to get out.

👍 1