Skip to content

Commit 45234e8

Browse files
committed
Add custom lsp-clients-extract-signature-on-hover
This fixes a case where a type signature would be broken up over multiple lines, and we only display the first of these. Fixes: #151 Related: emacs-lsp/lsp-mode#4362 Related: emacs-lsp/lsp-mode#1740
1 parent 85a82c9 commit 45234e8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lsp-haskell.el

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,26 @@ Note that this must be set to true in order to get completion of pragmas."
495495
;; ---------------------------------------------------------------------
496496
;; Starting the server and registration with lsp-mode
497497

498+
(cl-defmethod lsp-clients-extract-signature-on-hover (contents (_server-id (eql lsp-haskell)))
499+
"Display the type signature of the function under point."
500+
(let* ((groups (--filter (s-equals? "```haskell" (car it))
501+
(-partition-by #'s-blank?
502+
(->> (lsp-get contents :value)
503+
s-trim
504+
s-lines))))
505+
(type-sig-group
506+
(car (--filter (--any? (s-contains? (symbol-name (symbol-at-point))
507+
it)
508+
it)
509+
groups))))
510+
(lsp--render-string
511+
(->> (or type-sig-group (car groups))
512+
(-drop 1) ; ``` LANG
513+
(-drop-last 1) ; ```
514+
(-map #'s-trim)
515+
(s-join " "))
516+
"haskell")))
517+
498518
(defun lsp-haskell--server-command ()
499519
"Command and arguments for launching the inferior language server process.
500520
These are assembled from the customizable variables `lsp-haskell-server-path'

0 commit comments

Comments
 (0)