"Determine if current server is capable of FEAT."
(plist-get (eglot--capabilities (eglot--current-process-or-lose)) feat))
-(cl-defmacro eglot--with-lsp-range ((start end) range &body body
- &aux (range-sym (cl-gensym)))
- "Bind LSP RANGE to START and END. Evaluate BODY."
- (declare (indent 2) (debug (sexp sexp &rest form)))
- `(let* ((,range-sym ,range)
- (,start (eglot--lsp-position-to-point (plist-get ,range-sym :start)))
- (,end (eglot--lsp-position-to-point (plist-get ,range-sym :end))))
- ,@body))
+(defun eglot--range-region (range)
+ "Return region (BEG . END) that represents LSP RANGE."
+ (cons (eglot--lsp-position-to-point (plist-get range :start))
+ (eglot--lsp-position-to-point (plist-get range :end))))
\f
;;; Minor modes
collect (cl-destructuring-bind (&key range severity _group
_code source message)
diag-spec
- (eglot--with-lsp-range (beg end) range
+ (pcase-let ((`(,beg . ,end) (eglot--range-region range)))
(flymake-make-diagnostic (current-buffer)
beg end
(cond ((<= severity 1) :error)
(defun eglot--hover-info (contents &optional range)
(concat (and range
- (eglot--with-lsp-range (beg end) range
+ (pcase-let ((`(,beg . ,end) (eglot--range-region range)))
(concat (buffer-substring beg end) ": ")))
(mapconcat #'eglot--format-markup
(append
(when-buffer-window
(eglot--mapply
(eglot--lambda (&key range _kind)
- (eglot--with-lsp-range (beg end) range
+ (pcase-let ((`(,beg . ,end)
+ (eglot--range-region range)))
(let ((ov (make-overlay beg end)))
(overlay-put ov 'face 'highlight)
(overlay-put ov 'evaporate t)
(save-restriction
(widen)
(save-excursion
- (eglot--with-lsp-range (beg end) range
+ (pcase-let ((`(,beg . ,end) (eglot--range-region range)))
(goto-char beg) (delete-region beg end) (insert newText)))))
edits)
(eglot--message "%s: Performed %s edits" (current-buffer) (length edits)))