From 45234e8e6c134091acb85f1aae78da8ac1058ca2 Mon Sep 17 00:00:00 2001 From: Tony Zorman Date: Sat, 17 Aug 2024 14:51:30 +0200 Subject: [PATCH] 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: https://github.com/emacs-lsp/lsp-haskell/issues/151 Related: https://github.com/emacs-lsp/lsp-mode/issues/4362 Related: https://github.com/emacs-lsp/lsp-mode/pull/1740 --- lsp-haskell.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lsp-haskell.el b/lsp-haskell.el index d4c8593..5d23ce6 100644 --- a/lsp-haskell.el +++ b/lsp-haskell.el @@ -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'