From 5590c2c96fa8334d3d9d5c78b544fdbd86879e81 Mon Sep 17 00:00:00 2001 From: ncaq Date: Fri, 25 Jun 2021 18:46:00 +0900 Subject: [PATCH 1/3] added: lsp-haskell-execute-code-action-add-signature I want it to be a stand-alone function because I often do this in Haskell code actions. I update Package-Requires emacs `24.3` -> `26.1`, because `seq-find` require Emacs 25, lsp-mode of base package require `26.1`, Since lsp-haskell will never work without lsp-mode, there is no point in lsp-haskell supporting old Emacs that lsp-mode does not support. --- lsp-haskell.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lsp-haskell.el b/lsp-haskell.el index 29703d3..cf6ac5e 100644 --- a/lsp-haskell.el +++ b/lsp-haskell.el @@ -1,7 +1,7 @@ ;;; lsp-haskell.el --- Haskell support for lsp-mode ;; Version: 1.0 -;; Package-Requires: ((emacs "24.3") (lsp-mode "3.0") (haskell-mode "1.0")) +;; Package-Requires: ((emacs "26.1") (lsp-mode "3.0") (haskell-mode "1.0")) ;; Keywords: haskell ;; URL: https://github.com/emacs-lsp/lsp-haskell @@ -228,6 +228,15 @@ if projectile way fails" (user-error "Couldn't find cabal file, using: %s" dir) dir)))) +(defun lsp-haskell-execute-code-action-add-signature () + "Execute code action of add signature. +Add the type signature that GHC infers to the function located below the point." + (interactive) + (let ((action (seq-find (lambda (e) (string-prefix-p "add signature" (gethash "title" e))) (lsp-code-actions-at-point)))) + (if (hash-table-p action) + (lsp-execute-code-action action) + (message "I Can't find add signature action for this point")))) + ;; --------------------------------------------------------------------- ;; Starting the server and registration with lsp-mode From 60e212191ce4d0fe3c30582953fc0e15f996c584 Mon Sep 17 00:00:00 2001 From: ncaq Date: Sat, 26 Jun 2021 14:24:53 +0900 Subject: [PATCH 2/3] fixed: delete hash map function. I followed the code review. > you should not use gethash because when lsp-use-plists is t the data structures will be plists. You may refer to lsp-execute-code-action-by-kind in lsp-java. > > --- lsp-haskell.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lsp-haskell.el b/lsp-haskell.el index cf6ac5e..bac0af9 100644 --- a/lsp-haskell.el +++ b/lsp-haskell.el @@ -232,8 +232,10 @@ if projectile way fails" "Execute code action of add signature. Add the type signature that GHC infers to the function located below the point." (interactive) - (let ((action (seq-find (lambda (e) (string-prefix-p "add signature" (gethash "title" e))) (lsp-code-actions-at-point)))) - (if (hash-table-p action) + (let ((action (seq-find + (lambda (e) (string-prefix-p "add signature" (lsp:code-action-title e))) + (lsp-code-actions-at-point)))) + (if action (lsp-execute-code-action action) (message "I Can't find add signature action for this point")))) From b4aad498840b0b607eaa9d3b19c11c7d2e0980bb Mon Sep 17 00:00:00 2001 From: ncaq Date: Sat, 26 Jun 2021 14:26:11 +0900 Subject: [PATCH 3/3] fixed: I had capitalized it by mistake --- lsp-haskell.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lsp-haskell.el b/lsp-haskell.el index bac0af9..d1e9e85 100644 --- a/lsp-haskell.el +++ b/lsp-haskell.el @@ -237,7 +237,7 @@ Add the type signature that GHC infers to the function located below the point." (lsp-code-actions-at-point)))) (if action (lsp-execute-code-action action) - (message "I Can't find add signature action for this point")))) + (message "I can't find add signature action for this point")))) ;; --------------------------------------------------------------------- ;; Starting the server and registration with lsp-mode