Fork me on GitHub
#lsp
<
2024-02-07
>
John Doe03:02:30

I'm having trouble let lsp to display overloaded function docs with all possible arities like cider does in emacs echo area with eglot apart from: (eldoc-echo-area-use-multiline-p nil) .config/clojure-lsp/config.edn {:hover {:arity-on-same-line? true}} Are there any other settings I need to tweak?

(defn xx
  ([a] 1)
  ([a b] 1))
cider would show xx: ([a] [a b]) in echo area but clojure-lsp would only show (xx [a]) cross ref: https://clojurians.slack.com/archives/CPABC1H61/p1678733411503889

1
John Doe03:02:48

as far as I understand, if I open the full *eldoc**,* i can see

(xx [a])
(xx [a b])
my/ns [a] [a b]
and echo area only show the first line? ideally I would like it to show the last line one as cider does if possible

ericdallo13:02:16

Did you try the setting :hover` :arity-on-same-line?`? https://clojure-lsp.io/settings/#all-settings

John Doe13:02:23

yeah, that's what I put {:hover {:arity-on-same-line? true}} in ~/.config/clojure-lsp/config.edn i'm using nixpkgs unstable's 2023.08.06-00.28.06 version. Looks like the setting is not take effect somehow?

John Doe13:02:52

does it look normal that I found 2024-02-07T13:54:34.274Z WARN [clojure-lsp.server:401] - {:settings {}} in the lsp log?

John Doe14:02:35

well... I tried to build the latest clojure-lsp from master by nix shell github:clojure-lsp/clojure-lsp, and it seems to have the same result.. And since the DEV version generated huge amount of log, so I can dig up some thing like :project-settings {:log-path "/tmp/clojure-lsp.log", :hover {:arity-on-same-line? true}} from the log, so I assume the setting gotten read correctly at leaset? But still the same result in echo area. > clojure-lsp --version clojure-lsp 2024.02.01-11.01.59 clj-kondo 2023.12.16-SNAPSHOT

ericdallo14:02:22

that is a years old setting, so not sure it's related with version

ericdallo14:02:06

could you show a print? since I'm a lsp-mode user I think it should be a eglot issue since it works as expected on lsp-mode

John Doe14:02:25

I guess it's eglot then 😄 @UBRV1HXPD do you recall such weird issue with your eglot setup if you don't mind me asking (

👍 1
ericdallo14:02:03

also, it's weird that is not showing clojure.core/+ but + :thinking_face: are you sure that is coming from LSP?

John Doe15:02:47

I think I disabled all the related cider doc, and lsp is the only one left? (cider-eldoc-display-for-symbol-at-point nil) (remove-hook 'eldoc-documentation-functions #'cider-eldoc t) my eldoc only has 2 lines of config as well so.. (eldoc-echo-area-use-multiline-p nil) (eldoc-echo-area-prefer-doc-buffer t)

ericdallo15:02:53

looks correct

John Doe15:02:32

https://github.com/joaotavora/eglot/discussions/1181 there's some relevant discussion there as well..let me double check with eglot. It seems to me eglot only use first line of eldoc's output by default..

Akiz15:02:25

I think that by default you get the “current arrity” in the minibuffer and once you write (xx a b) you will see b highlighted there. If I am right, this is the advantage / disadvantage of eglot over lsp-mode which doesn’t highlight current symbol but i would have to check it. Is that right?

John Doe15:02:09

no, it always get the first one no matter what

Akiz15:02:33

Can you show screenshot of the eldoc-buffer please?

Akiz15:02:28

And if you move cursor on top of 2, do you still see one arg in minibuffer?

John Doe16:02:41

well, after I upgraded to latest eglot master, at least it gets the “current arrity” in the minibuffer correct. I presume that's what you got as well and this is the correct expected behavior for eglot? @UBRV1HXPD

Akiz19:02:56

@U0599HVJX70 Yes, we are on track 🙂. Now - if you want to have all artiness on the same line (without highlighting the current one) you can add this to you configuration:

(defun my/switch-eldoc-eglot-fns ()
     (when (derived-mode-p 'clojure-mode)
       (remove-hook 'eldoc-documentation-functions #'eglot-hover-eldoc-function t)
       (remove-hook 'eldoc-documentation-functions #'eglot-signature-eldoc-function t)
       (add-hook 'eldoc-documentation-functions #'eglot-signature-eldoc-function -99 t)
       (add-hook 'eldoc-documentation-functions #'eglot-hover-eldoc-function -99 t)))
and then use this hook (eglot-managed-mode . my/switch-eldoc-eglot-fns) Now you will get the signature in mini-buffer (which is what is on 3rd line in your picture of eldoc-buffer). I hope it will help you.

John Doe20:02:16

Work like a charm, ty!!! 👍

👍 1