lsp 2024-09-03

some clojure core functions (particularly those in the loaded files, like defprotocol) don't have docstrings returned from clojure-lsp. Is this due to a limitation of clj-kondo? would it be possible to hardcode docstring support for them in some way?

For me in neovim I can jump into definitions in jars fwiw. I'm just using neovim-lsp.

can you jump to the definition of defprotocol? that's the question at hand.

Oh I can't, no. defn, and other things in jars work fine though.

I misread some of the above conversation, oops. So yeah, I'm the same as you!

@borkdude are you sure you are not using any fallback like a repl or something to go to defprotocol?

lemme try in a random file

yes, you're right, it was using the REPL as a fallback. I configured it as lsp first, then REPL

😂 1

having thought about it over night, i suspect this is related to clj-kondo not supporting load / merging namespaces that are defined with in-ns in separate files. i know i've raised this in #clj-kondo before but now i can't find it, which is annoying lol

IIRC that doesn't happen only with defprotocol, there are some clojure.core stuff like that that I noticed before

👍 1

it's a tough problem, I experimented with solving it in splint (https://github.com/NoahTheDuke/splint/pull/9) and set it aside cuz it's a pain in the ass

it's a pain in the ass indeed. the load pattern should maybe die? ;)

tell that to rich hickey 😉

😂 1

could maybe hard-code some fixes for clojure.core though

1

Yes, I'm not sure why kondo doesn't include them but I guess it's related to how those are defined in clojure.core which should not be straightforward

does navigating to the file work though?

navigating to what file?

where defprotocol is defined

i can't navigate to it, it's bundled in the clojure core jar

that isn't a limitation though

at least not in emacs

I can navigate to clojure.core/inc without issues

I can also navigate to defprotocol

that's in clojure.core. defprotocol is defined in core_deftype.clj which is loaded with load

2024-09-03T15:17:59.688Z  DEBUG [clojure-lsp.server:55] - [Trace - 2024-09-03T15:17:59.688Z] Received request 'textDocument/definition - (26167)'
Params: {
  "text-document" : {
    "uri" : "file:///Users/noah/personal/splint/src/noahtheduke/splint/runner.clj"
  },
  "position" : {
    "line" : 23,
    "character" : 11
  }
}



2024-09-03T15:17:59.689Z  INFO [clojure-lsp.handlers:261] - :definition 1ms
2024-09-03T15:17:59.689Z  DEBUG [clojure-lsp.server:55] - [Trace - 2024-09-03T15:17:59.689Z] Sending response 'textDocument/definition - (26167)'. Request took 1ms.
Result: null

I guess you need to install some zip plugin or so

i can navigate into clojure.core just fine, just not into anything in core_deftype.clj

weird, I can

2024-09-03T15:18:28.645Z  DEBUG [clojure-lsp.server:55] - [Trace - 2024-09-03T15:18:28.645Z] Received request 'textDocument/definition - (26171)'
Params: {
  "text-document" : {
    "uri" : "file:///Users/noah/personal/splint/src/noahtheduke/splint/runner.clj"
  },
  "position" : {
    "line" : 26,
    "character" : 1
  }
}



2024-09-03T15:18:28.646Z  INFO [clojure-lsp.handlers:261] - :definition 1ms
2024-09-03T15:18:28.646Z  DEBUG [clojure-lsp.server:55] - [Trace - 2024-09-03T15:18:28.646Z] Sending response 'textDocument/definition - (26171)'. Request took 1ms.
Result: {
  "uri" : "zipfile:///Users/noah/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar::clojure/core.clj",
  "range" : {
    "start" : {
      "line" : 293,
      "character" : 1
    },
    "end" : {
      "line" : 293,
      "character" : 5
    }
  }
}
that's for defn as above

do you use clojure-lsp or just flycheck, borkdude?

clojure-lsp

👍 1

huh. does emacs have any special handling for go-to definition? i rely solely on clojure-lsp for it

Yes, this unfortunately is more complex than it could be

how about you @ericdallo, can you navigate to defprotocol

Yes, there is custom code for that on each editor

😮 1

But vim is the only one not following, as it uses the zip dependency scheme while other editors use the jar

😅 1

how is this different?

anyway, I guess the answer is pretty bloody evident. use emacs.

💯 1
4
🙅‍♂️ 1
😅 2

when you find a definition of something that ends in a jar, the clients request server for https://github.com/clojure-lsp/clojure-lsp/blob/4ce7c0c2bdc6f7dfd65b58a901f20f9c772425d9/cli/src/clojure_lsp/server.clj#L173, which clojure-lsp will return the file content (decompiling it if it's a .class)

I'm aware of lsp-mode, eglot, clojure-lsp-intellij and calva doing that

Would be awesome to standardize how vim does that as well @nbtheduke

i'm down to help, it's a big annoyance for me

I'm not sure if fixing this will help showing the docstring though, I don't rely on my editor for docstrings

there is a clojure-lsp integration test that may help understand too

at least not lsp

can you see the docstring for defprotocol @ericdallo?

I cant, but I use docstrings a lot and most devs I work use too

it's weird because I can't navigate to defprotocol too 🤔

so that might be a different issue

oh ok. for some obscure reason I can

we should all move to Calva then maybe

2
😂 2

how does calva do this? is everyone expected to use dependencyContents?

Currently, yes

I'm not finding that on calva code, so not sure anymore 🤔

ah, calva has its own way to handle jar

something weird is happening, i'll have to do some more digging to figure it out