Skip to content

Commit

Permalink
Add custom lsp-clients-extract-signature-on-hover
Browse files Browse the repository at this point in the history
This fixes a case where a type signature would be broken up over
multiple lines, and we only display the first of these.

Fixes: emacs-lsp#151
Related: emacs-lsp/lsp-mode#4362
Related: emacs-lsp/lsp-mode#1740
  • Loading branch information
slotThe committed Aug 17, 2024
1 parent 85a82c9 commit 45234e8
Showing 1 changed file with 20 additions and 0 deletions.
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)
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

0 comments on commit 45234e8

Please sign in to comment.