Fork me on GitHub
#announcements
<
2024-02-01
>
seancorfield06:02:22

https://github.com/clj-commons/marginalia and lein-marginaliahttps://github.com/clj-commons/lein-marginalia -- the first new releases since 2017! • New :meta option in project.clj > :marginalia settings to generate <meta> tags in the documentation <head> • Lots of other changes in https://github.com/clj-commons/marginalia/releases/tag/v0.9.2 that predate me taking over maintenance but were never released Follow-up in #C064TCA0GBW

❤️ 6
1
👍 6
🎉 3
ericdallo14:02:58

clojure-lsp Released https://clojure-lsp.io/ https://github.com/clojure-lsp/clojure-lsp/releases/tag/2024.02.01-11.01.59 with lots of fixes and a new custom Clojure feature, a project tree, giving visibility of the project source-paths, external dependencies, jars and ns! For more info, come to #CPABC1H61 Happy code Clojurians! This release was supported by #C8145Q6VD clojurists-togethergratitude

🎉 39
clojure-lsp 4
clojurists-together 1
💜 2
Alex Miller (Clojure team)15:02:15

very cool! just fyi, the "tree" is really a graph - if the same lib shows up at multiple points in the tree, do you get expansion on all of them, or is there some visual indication of omitted children? also, one thing that is often difficult to debug is exclusions - are those just missing or is there some way to tell a lib has a child that is being excluded? (extra difficult because it may be excluded due to parents multiple levels up)

ericdallo16:02:46

Thanks! This is just a visualization of what clojure-lsp already has in it's analysis in memory, and all that analysis come from the classpath command that the user configure for that project (usually the default clj -Spath), so if the classpath command excludes that lib you won't see that there, would be difficult indeed to show those exclusions

Alex Miller (Clojure team)16:02:10

so it's really just a flat list of libs?

Alex Miller (Clojure team)16:02:39

(which is fine, I just misunderstood)

ericdallo16:02:55

Yes, all libs available in the classpath

ericdallo16:02:29

I think it's the same that other tools like Java for vscode does, I actually based on that

Akiz19:02:57

Can Eglot user profit from this or is this lsp-mode only? Edit: It is a custom function, so I guess the answer is “can’t” 🙂.

ericdallo19:02:04

only if eglot allow extends that, but ATM it's only available for lsp-mode as I coded manually that https://github.com/emacs-lsp/lsp-mode/blob/master/clients/lsp-clojure.el#L453-L561. That's something that I wish would go to LSP protocol itself, but that's another discussion :)

👏 1
Akiz21:02:41

And what was the motivation for writing it? Or rather, what do you usually use it for?

ericdallo22:02:30

@UBRV1HXPD that was a feature request from some users but the last one that asked made me realize it was something that other tools like cursive and other langs like Java had that we didn't had anything closer and that works out of the box to easily visualize the project scope

Richie04:02:26

Most frequently it’s to check versions of transitives and I currently solve that with lein deps tree. It’s also just to see what’s present. Some things behave differently depending on what’s on the class path. Rarely it’s because I want to use a library in a pinch and I don’t know if it’s available; if it’s not then I make do without.

Akiz15:02:40

Thanks! I tried it and I like it very much. So I am trying to rewrite it for Eglot + hierarchies.el 🙂 .

Akiz17:02:43

The work on the project-tree for Eglot is going well. But could someone please advise me what files inside the external dependency are visible in the context of the extracted JAR? The point is that I would like to offer the user a list of files that he can visit (via Jarchive), but I'm not quite clear what is reasonable selection to offer.

ericdallo18:02:49

@UBRV1HXPD that's great! not sure I got, but we don't extract the jar, we just list the contents, and technically all of them are accessible by user

🙏 1
Akiz19:02:15

@UKFSJSM38 For some reason I can’t make rewrite-edn to be visible under my external dependencies but when i take a look into your picture I see it was expanded to 4 things. Can you help me to understand what these are and how did you get them?

Akiz19:02:52

btw. this is how it will look for the eglot.. but right now, clicking on jar just opens the dired with its content

ericdallo20:02:30

looks nice! Yeah, the jars are expansible and they should show namespaces or java classes

ericdallo21:02:20

basically if your node is not final, you should be able to request more children nodes

Akiz21:02:09

Thanks, type 4 itself does not provide any additional nodes. But if it’s just classes and namespaces, it shouldn’t be a problem to filter them out of the archive. Do you do that too? I’m trying to figure out the best way to get this list of them. Once I have it, it won’t be a problem to visit them via jar:file://....

Akiz13:02:16

I found a solution, everything is good 🙂

ericdallo14:02:01

good! I'm not sure if there is anything clojure-lsp is doing wrong, but this comment should help understand along with the test: https://github.com/clojure-lsp/clojure-lsp/blob/a59f0c6e9d8340ecea53e6bdc6f0f2e977c85ae4/lib/src/clojure_lsp/feature/project_tree.clj#L138

Akiz14:02:34

Thanks, the tests are useful. So the “problem” is that when I call

(eglot--request (eglot-current-server) :clojure/workspace/projectTree/nodes '(:name "rewrite-edn-0.3.4.jar" :detail "jar:file:///Users/akiz/.m2/repository/borkdude/rewrite-edn/0.3.4/rewrite-edn-0.3.4.jar" :uri "jar:file:///Users/akiz/.m2/repository/borkdude/rewrite-edn/0.3.4/rewrite-edn-0.3.4.jar" :final :json-false :type 4))
I get
(:name "rewrite-edn-0.3.4.jar" :type 4 :detail "jar:file:///Users/akiz/.m2/repository/borkdude/rewrite-edn/0.3.4/rewrite-edn-0.3.4.jar" :uri "jar:file:///Users/akiz/.m2/repository/borkdude/rewrite-edn/0.3.4/rewrite-edn-0.3.4.jar" :nodes [])
but based on what I see here, I should get nodes as well. Do you have any idea why I don’t get the nodes like you do here? https://github.com/clojure-lsp/clojure-lsp/blob/a59f0c6e9d8340ecea53e6bdc6f0f2e977c85ae4/lib/test/clojure_lsp/feature/project_tree_test.clj#L115

ericdallo14:02:15

Hum, weird, we get https://github.com/clojure-lsp/clojure-lsp/blob/7ed3133845e1b0c103e890a1e7c7a1e689b4cdd3/lib/src/clojure_lsp/feature/project_tree.clj#L54-L55 the ns and java classes from that uri, the only thing I can think is that jar contain only .class files and not .java or .clj :thinking_face:

Akiz14:02:46

It contains .clj files. I used the same external dependency as you did in your picture. Just to be sure. Then i will investigate furher. Would be nice to avoid my current workaround which is 1. “use jar command to get content of the jar” 2. filter all clj files 3. create nodes based on them and add them as a children of the dep 4. clicking on them will open them via find-file and jarchive

ericdallo15:02:15

yeah, clojure-lsp should provide that already, does that works for you with lsp-mode though?

Akiz15:02:44

It does and now it works with Eglot too! I also changed lsp’ setting to :dependency-scheme "jar" maybe it was it?

ericdallo15:02:13

ah yeah, lsp-mode sets that by default, and I think the only client that don't set that is vim

Akiz15:02:01

And thanks again! I am glad that i can get rid of that workaround…

ericdallo15:02:46

Cool, glad we have it working for eglot too!

Akiz15:02:21

And one more question @UKFSJSM38 - if I may - perhaps the last one - what do you use to decompile java class?