Skip to content

Commit

Permalink
Close #393: eglot--completing-read
Browse files Browse the repository at this point in the history
* eglot.el (eglot-code-actions): Remove code related to tmm
* eglot.el (eglot--completing-read): Adds implementation for
completing-read
  • Loading branch information
theothornhill committed Dec 31, 2019
1 parent 3879d57 commit 824360b
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -2458,29 +2458,31 @@ potentially rename EGLOT's help buffer."
[,@(cl-loop for diag in (flymake-diagnostics beg end)
when (cdr (assoc 'eglot-lsp-diag (eglot--diag-data diag)))
collect it)]))))
(menu-items
(or (mapcar (jsonrpc-lambda (&rest all &key title &allow-other-keys)
(cons title all))
actions)
(eglot--error "No code actions here")))
(menu `("Eglot code actions:" ("dummy" ,@menu-items)))
(action (if (listp last-nonmenu-event)
(x-popup-menu last-nonmenu-event menu)
(let ((never-mind (gensym)) retval)
(setcdr (cadr menu)
(cons `("never mind..." . ,never-mind) (cdadr menu)))
(if (eq (setq retval (tmm-prompt menu)) never-mind)
(keyboard-quit)
retval)))))
(menu-items (or (mapcar (jsonrpc-lambda (&rest all &key title &allow-other-keys)
(cons title all))
actions)
(eglot--error "No code actions here")))
(action (eglot--completing-read
"Eglot code actions: "
menu-items
nil t)))
(eglot--dcase action
(((Command) command arguments)
(eglot-execute-command server (intern command) arguments))
(((Command) command arguments)
(eglot-execute-command server (intern command) arguments))
(((CodeAction) edit command)
(when edit (eglot--apply-workspace-edit edit))
(when command
(eglot--dbind ((Command) command arguments) command
(eglot-execute-command server (intern command) arguments)))))))

(defun eglot--completing-read (prompt collection &optional predicate
require-match initial-input
hist def inherit-input-method)
(let ((completion (completing-read prompt (mapc 'cl-first collection)
predicate require-match initial-input hist
def inherit-input-method)))
(cdr (assoc completion collection))))



;;; Dynamic registration
Expand Down

0 comments on commit 824360b

Please sign in to comment.