Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement textDocument/signatureHelp #324

Closed
bpringe opened this issue Feb 17, 2021 · 10 comments
Closed

Implement textDocument/signatureHelp #324

bpringe opened this issue Feb 17, 2021 · 10 comments
Assignees
Labels
enhancement New feature or request
Projects

Comments

@bpringe
Copy link
Contributor

bpringe commented Feb 17, 2021

This is just a nice to have thing that we currently have in Calva using info from nrepl. See a demo here: https://github.com/BetterThanTomorrow/calva#demo-signature-help-while-typing

@bpringe bpringe added the enhancement New feature or request label Feb 17, 2021
@ericdallo ericdallo added this to Low priority in clojure-lsp via automation Feb 17, 2021
clojure-lsp automation moved this from Low priority to Next release Feb 21, 2021
@ericdallo
Copy link
Member

Available on next release @bpringe :)
signature-help

But we are not sending the active parameter yet, I think it'd be necessary a clj-kondo analysis change for that.

@borkdude, Would you think it would be possible to add to clj-kondo var-definition analysis some :args field?
For example (defn foo [a b & rest]) would have something like :args ["a" "b" "& rest"].

@ericdallo ericdallo self-assigned this Feb 21, 2021
@borkdude
Copy link
Contributor

@ericdallo We already have :arglist-strs:

$ clojure -M:clj-kondo/dev --config '{:output {:analysis {:arglists true} :format :edn}}' --lint - <<< '(defn foo [a b])' | jet --query ':analysis :var-definitions (map :arglist-strs)'
[["[a b]"]]

@borkdude
Copy link
Contributor

borkdude commented Feb 21, 2021

Adding this from a conversation on Slack. If you need the individual args, you can parse it as EDN and ignore the & symbol. This should work for most arglists, except those with auto-resolved keywords. You can work around this using edamame, which already comes with the clj-kondo dependency:

user=> (require '[edamame.core :as e])
nil
user=> (e/parse-string "{::str/keys [:a]}" {:auto-resolve (fn [ns] (symbol (str ":" ns)))})
#::str{:keys [:a]}

dharrigan pushed a commit to dharrigan/clojure-lsp that referenced this issue Feb 21, 2021
ericdallo added a commit that referenced this issue Feb 21, 2021
@ericdallo
Copy link
Member

ericdallo commented Feb 21, 2021

Done @bpringe, we have full support for textDocument/signatureHelp now :)
Thanks for the help @borkdude, we are using edamame now as you suggested and it seems to work perfectly

@bpringe
Copy link
Contributor Author

bpringe commented Feb 21, 2021

Awesome! Thanks guys.

@ericdallo ericdallo moved this from Next release to Done in clojure-lsp Feb 22, 2021
@gdanov
Copy link

gdanov commented Feb 26, 2021

this is great, but I can't figure out how to display the signature in pop-up. It does show in the mode line but not in postframe

@ericdallo
Copy link
Member

you need to use (setq lsp-signature-posframe 'lsp-signature-posframe)

@gdanov
Copy link

gdanov commented Feb 26, 2021

this did the job for me

(setq lsp-signature-function 'lsp-signature-posframe)

source:

https://twitter.com/yonchovski/status/1362858080430604292

@ericdallo
Copy link
Member

Oh sorry, yes, that is the correct 😅

@gdanov
Copy link

gdanov commented Feb 26, 2021

no problem ;) just wanted to have it documented for the next one to google it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

4 participants