Fork me on GitHub
#lsp
<
2023-05-10
>
practicalli-johnny12:05:34

comment-* snippets are not showing up consistently after clojure-lsp https://github.com/clojure-lsp/clojure-lsp/releases/tag/2023.01.26-11.08.16 and often fuzzy matching across a large number of Java libraries are shown instead with version https://github.com/clojure-lsp/clojure-lsp/releases/tag/2023.02.26-23.46.05 the comment snippets were occasionally showing on one project. I wiped all caches (.clj-kondo , .cpcache and .lsp) from the projects and tried with newer versions, but I get a lot of java matches that I am not interested in. Is it possible to turn off matching java (I cant imagine wanting to use any of the matches that I am being given when typing comment )

ericdallo12:05:14

That fuzzy is probably not from clojure-lsp but the client, lsp-mode I guess is caching the first request of com and fuzzing, but does not request comment otherwise would not have any java class items

ericdallo12:05:38

Even so, there should be a first item comment

practicalli-johnny12:05:03

I am restarting Emacs each time I change clojure-lsp version (trying all clojure-lsp versions this year). Its been happening since clojure-lsp version https://github.com/clojure-lsp/clojure-lsp/releases/tag/2023.02.26-23.46.05 was released, so I rolled back to an earlier version. If there is nothing obvious I can do, I'll stick with https://github.com/clojure-lsp/clojure-lsp/releases/tag/2023.01.26-11.08.16 for now, which works consistently. Its strange that its only happening on snippets that start with com I guess because its matching so many java libraries... maybe it runs out of space or something is replacing the snippets in the results...

ericdallo12:05:39

It doesn't seem like a clojure-lsp issue but I can confirm that soon

practicalli-johnny12:05:38

As soon as I change to the https://github.com/clojure-lsp/clojure-lsp/releases/tag/2023.01.26-11.08.16 clojure-lsp version the completion works correctly (even if I dont restart anything)

ericdallo12:05:48

I'd suggest try paying with lsp-completion-cache disabling

ericdallo12:05:18

Because there were no java analysis before that, but the client bug could always exist

ericdallo12:05:32

One way to confirm that is checking client server logs, and check if clojure-lsp return java items on the completion request eve if you typed comment which I think it doesn't

practicalli-johnny12:05:42

Okay, I'll take a look at the logs and https://emacs-lsp.github.io/lsp-mode/page/settings/completion/#lsp-completion-no-cache (I assume that was the cache setting you mentioned)

practicalli-johnny12:05:41

Seems to be working now with the latest release I found the 'global' user cache for clojure-lsp in .cache/clojure-lsp and deleted that along with all other caches. I also commented the java config from the user .config/clj-kondo/config.edn (I had tried this before, but had not deleted the user cache for clojure-lsp)

;; :java
 ;; {:jdk-source-uri "file:///usr/lib/jvm/openjdk-17/lib/src.zip"}
I'll try including the java sources when I actually get around to using them again 🙂 Thanks for the pointers.

👍 1
ericdallo12:05:51

I think removing the java feature doesn't fix the root cause, but fix your issue, would be nice to understand if there is something to improve in lsp-mode or clojure-lsp side

ericdallo13:05:23

àlso, curious why you had jdk-source-uri specified that clojure-lsp couldn't provide by default

practicalli-johnny13:05:02

I already have the Java sources downloaded via the Operating System package manager, so dont need another copy 😉 Also prefer to have the same Java sources version for the JVM I am using (JDK 17) and clojure-lsp uses JDK 19 (so I dont try and use something from Java that is not available in the version I'm using - a small chance I admit, but useful to minimise issues) If I could specify the version of the JDK sources that clojure-lsp uses, that would negate the need for this setting. Perhaps having latest and LTS versions as an option (to limit the number of java sources to maintain). I dont know if anyone else shared the same pedantic nature though 😄

ericdallo13:05:27

That's the point, clojure-lsp already seek for your JVM installed in your system, if not found then it downloads if no URI is specified.

ericdallo13:05:44

More details https://clojure-lsp.io/settings/#java-support, so TLDR: avoid changing the defaults unless you need it :)

shaunlebron19:05:01

I wonder if it’s possible (and useful) to have something like clojure-lsp browse serve a github-style webpage, acting as a read-only editor for a clojure project. That way, people can just click on var symbols to go to definition, or find where vars are used without having to setup an editor.

dpsutton19:05:48

i think @U04V15CAJ created something like this with clj-kondo

ericdallo20:05:02

That sounds interesting indeed, I could not find a example with quicdoc though

dpsutton20:05:17

rust has this built in and it is lovely

shaunlebron20:05:03

I just tried quickdoc, thanks! I like it.

shaunlebron20:05:57

it generates api docs as a markdown file, but doesn’t show source code for navigating references

ericdallo20:05:55

Yeah, that's what I thought

borkdude20:05:06

@U061E2UBT it shows a link to the source code

dpsutton20:05:27

i suspect not too hard to extend it to generate html, put each namespace in a separate section and include collapsible source code blocks

ericdallo20:05:42

I think @U061E2UBT expects something more like GitHub which for some langs allow clicking and navigating to definition and references

borkdude20:05:17

@U061E2UBT So in the link above: I posted that idea but haven't implemented it yet. You can do so using the analysis data: https://github.com/clj-kondo/clj-kondo/tree/master/analysis and then use something like nextjournal/clojure-mode + UI skillz which you have :)

👀 1
shaunlebron20:05:32

@UKFSJSM38 and even crazier than that, I’d like the option to place a function’s source in something like http://OrgPad.com, so when I click a reference it opens a node in a graph

👀 1
shaunlebron20:05:21

orgpad is so good, I’m surprised I couldn’t find its clojure author Pavel Klavik on slack to tag here

shaunlebron20:05:17

it’s made in blazing fast clojurescript, and the UI is very polished, joy to use

borkdude20:05:19

I've interacted with him on Telegram once and actually I think I convinced him to come here in the past to discuss some development thing around bb

shaunlebron20:05:13

@U04V15CAJ would this be better as a kondo browse or clojure-lsp browse command

shaunlebron20:05:11

this is how I used orgpad to understand a reagent thing btw

dpsutton20:05:57

that’s really cool

shaunlebron20:05:41

oh my, @U0739PUFQ already built the graph browser thing: https://github.com/jpmonettas/clograms/

shaunlebron20:05:39

> Any function x-references, protocols or multimethods is one click away

ericdallo20:05:34

I'd say this is something to be created in a new project, not kondo or LSP, seems really cool, quite specific too, but could use kondo analysis

👍 1
borkdude20:05:58

ok, that idea is slightly different than what I had in mind: my idea was just the github code UI but you could click on locals and vars and get x-refs and you could just navigate on an HTML page like you could in your IDE

borkdude20:05:23

which is already supported for some languages on Github, but not for Clojure

ericdallo20:05:57

Yeah, that is a little closer to a LSP online xp

borkdude20:05:48

There's also this one, based on clj-kondo analysis but it doesn't show the source, just the nodes + edges https://github.com/benedekfazekas/morpheus

👍 1
borkdude20:05:08

The source is quite easy to get if you have the analysis + file path btw

ericdallo21:05:42

Yeah, I think the most complicated is provide find definition and references and navigation reliable which is already built-in in clojure-lsp. Maybe that tool could use LSP under the hood?

shaunlebron16:05:13

@U04V15CAJ @UKFSJSM38 what do you guys think of a github browser plugin that turns symbols into links?

borkdude16:05:07

that sounds very good!

shaunlebron16:05:12

is clj-kondo simple enough to surmise where a symbol is defined just from a single file’s text

borkdude16:05:47

@U061E2UBT clj-kondo is designed to work with single files, not with whole projects, yes but note that it doesn't work in ClojureScript today

shaunlebron16:05:32

so clj-kondo can work in js yeah?

shaunlebron16:05:23

actually I don’t see how we could get the definition’s line number in an external file, from just looking at a single file

borkdude16:05:11

that will only work if the definition is also in the same single file :)

shaunlebron16:05:03

or we can just make a PR to add clojure to GitHub‘s semantic library, and it would work: https://github.com/github/semantic

borkdude17:05:13

Last time I spoke with any of the Github people they told me their IDE features were supported by tree-sitter but what you're showing seems to be a Haskell project

ericdallo17:05:01

hum, I thought they were using https://lsif.dev/, brother of LSP

shaunlebron17:05:43

github’s builtin code navigation uses semantic, which uses tree-sitter: https://github.com/github/semantic/blob/main/docs/adding-new-languages.md

shaunlebron17:05:45

I’ll ask in #tree-sitter

borkdude17:05:07

well good luck with that then

borkdude17:05:37

I can tell you right now that tree-sitter-clojure won't get you any semantic information about clojure

borkdude17:05:52

at least not in its current state

shaunlebron18:05:19

yeah the tree-sitter-clojure docs just point to clj-kondo for parsing semantic info: https://github.com/sogaiu/tree-sitter-clojure/blob/master/doc/scope.md

shaunlebron18:05:58

alright I think I’m caught up on the landscape of tooling that’s been done here. thanks yall