Override lsp-mode code action autoselect

This commit is contained in:
outfoxxed 2023-08-13 16:56:37 -07:00
parent 7821b7b605
commit a254cc2951
Signed by: outfoxxed
GPG Key ID: 4C88A185FB89301E
1 changed files with 16 additions and 0 deletions

16
init.el
View File

@ -348,3 +348,19 @@
(lambda (&optional count file) (hyprctl "hy3:movefocus" "u")))
(advice-add #'evil-window-down :override
(lambda (&optional count file) (hyprctl "hy3:movefocus" "d")))
;;; Overrides
;; stop lsp-mode from yoloing code actions when only one is present
(defun lsp--select-action (actions)
"Select an action to execute from ACTIONS."
(cond
((seq-empty-p actions) (signal 'lsp-no-code-actions nil))
;;((and (eq (seq-length actions) 1) lsp-auto-execute-action)
;;(lsp-seq-first actions))
(t (let ((completion-ignore-case t))
(lsp--completing-read "Select code action: "
(seq-into actions 'list)
(-compose (lsp--create-unique-string-fn)
#'lsp:code-action-title)
nil t)))))