Fork me on GitHub
#lsp
<
2024-03-02
>
armed16:03:57

Hi, not sure how it is complicated to implement (or maybe can be configured?). Some libraries are aliasing symbols from its other namespaces as plain defs, e,g,

(ns lib.core-ns
  (:require [lib.other-ns :as other]))

(def a-function other/a-function)
A hover doc in my code for lib.core-ns/a-function won't show anything, because there is no docstring for aliased def. I've a keybinding for printing (doc sym) in a repl as a workaround atm.

ericdallo16:03:47

One way to workaround this is to add this meta do the first function: ^{:doc (:doc (meta #'other/a-function))}

ericdallo16:03:28

I know it's not ideal. not sure if would be possible without affect performance as we would have to parse the nodes during hover doc build but It may worth the try

armed16:03:36

Interesting, that lib (seesaw) has metas, but hover shows nothing

armed16:03:03

something with my config then?

armed16:03:57

if I require seesaw.event directly then hover works

ericdallo16:03:26

It's supposed to show, I recently tried that at my company

armed16:03:05

Ok, will ask colleagues. Thanks

borkdude16:03:21

It’s supposed to show but not via lsp which gets its analysis from clj-kondo

ericdallo16:03:52

Actually clojure-lsp support this meta hack

borkdude16:03:41

How if clj-kondo doesn’t?

armed16:03:53

(def ^{:doc (:doc (:meta #'clojure.core/map))}
  map clojure.core/map)

ma|p
so hover here isn't working for me

borkdude16:03:51

Hehe a bespoke hack

😅 2
ericdallo16:03:37

@U34K4458X it should be meta not :meta

armed16:03:54

right, my bad. Yes on my example it now works. Something with lib then

armed16:03:08

ah its because str

armed16:03:32

After I saw that hack in clojure-lsp

armed16:03:52

it won't recognize (str blah (:doc (meta ...)...

armed16:03:10

mystery solved, thanks fokls

ericdallo16:03:56

yeah, like I said it's a hack that works for that specific case, won't work for more advanced things that require runtime analysis

armed16:03:16

completely understand, no more questions 🍺

Noah Bogart18:03:18

Heh sorry for the hack, it was the best I could do

👏 1
ericdallo18:03:52

I find it really good :)

❤️ 1
Noah Bogart18:03:57

One of the few instances where nrepl middleware providing docstrings is better than lsp