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

Add custom lsp-clients-extract-signature-on-hover #187

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions lsp-haskell.el
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,26 @@ Note that this must be set to true in order to get completion of pragmas."
;; ---------------------------------------------------------------------
;; Starting the server and registration with lsp-mode

(cl-defmethod lsp-clients-extract-signature-on-hover (contents (_server-id (eql lsp-haskell)))
"Display the type signature of the function under point."
(let* ((groups (--filter (s-equals? "```haskell" (car it))
(-partition-by #'s-blank?
(->> (lsp-get contents :value)
Copy link
Author

@slotThe slotThe Aug 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope I did this right, but this should be agnostic wrt the chosen lsp-mode configuration. Still, I've only tested it with use-plists, so it would be nice if someone using hashtables could also test this

s-trim
s-lines))))
(type-sig-group
(car (--filter (--any? (s-contains? (symbol-name (symbol-at-point))
it)
it)
groups))))
(lsp--render-string
(->> (or type-sig-group (car groups))
(-drop 1) ; ``` LANG
(-drop-last 1) ; ```
(-map #'s-trim)
(s-join " "))
"haskell")))

(defun lsp-haskell--server-command ()
"Command and arguments for launching the inferior language server process.
These are assembled from the customizable variables `lsp-haskell-server-path'
Expand Down