From 2d38afd4184c44812ed59024b1ba13390c45bb85 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Fri, 1 Apr 2022 10:26:05 -0400 Subject: [PATCH] Add embark target for LSP identifiers w/ binding for code actions --- emacs/.emacs.d/config/init-completion.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/emacs/.emacs.d/config/init-completion.el b/emacs/.emacs.d/config/init-completion.el index 44c562c..3e7d9dc 100644 --- a/emacs/.emacs.d/config/init-completion.el +++ b/emacs/.emacs.d/config/init-completion.el @@ -81,6 +81,19 @@ targets." ("k" password-store-remove) ("U" password-store-url)) (add-to-list 'embark-keymap-alist '(password-store . embark-password-store-actions)) + ;; Add identifiers in LSP-mode as their own target type + (with-eval-after-load 'lsp-mode + (defun embark-target-lsp-identifier-at-point () + (when lsp-mode + (when-let ((sym (embark-target-identifier-at-point))) + (cons 'lsp-identifier (cdr sym))))) + (add-to-list 'embark-target-finders 'embark-target-lsp-identifier-at-point) + (embark-define-keymap embark-lsp-identifier-actions + "Keymap for actions on LSP identifiers." + :parent embark-identifier-map + ("a" lsp-execute-code-action)) + (add-to-list 'embark-keymap-alist '(lsp-identifier . embark-lsp-identifier-actions)) + (add-to-list 'embark-target-injection-hooks '(lsp-execute-code-action embark--ignore-target))) :general ("C-." #'embark-act) ("M-." #'embark-dwim)