[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master c083fa5cf80: Eglot: support window/showRequest (bug#62116)
From: |
João Távora |
Subject: |
master c083fa5cf80: Eglot: support window/showRequest (bug#62116) |
Date: |
Sat, 13 May 2023 08:00:29 -0400 (EDT) |
branch: master
commit c083fa5cf80f711ac43dca1b6582aff1ad526e8e
Author: Felicián Németh <felician.nemeth@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Eglot: support window/showRequest (bug#62116)
Co-authored-by: João Távora
* lisp/progmodes/eglot.el (eglot-client-capabilities): Advertise
window/showDocument.
(eglot-handle-request window/showDocument): New handler.
---
lisp/progmodes/eglot.el | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 66d893a14b5..52f87c1af5d 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -845,7 +845,8 @@ ACTION is an LSP object of either `CodeAction' or `Command'
type."
`(:valueSet
[,@(mapcar
#'car eglot--tag-faces)])))
- :window `(:workDoneProgress t)
+ :window `(:showDocument (:support t)
+ :workDoneProgress t)
:general (list :positionEncodings ["utf-32" "utf-8" "utf-16"])
:experimental eglot--{})))
@@ -2366,6 +2367,28 @@ THINGS are either registrations or unregisterations
(sic)."
"Handle server request workspace/workspaceFolders."
(eglot-workspace-folders server))
+(cl-defmethod eglot-handle-request
+ (_server (_method (eql window/showDocument)) &key
+ uri external takeFocus selection)
+ "Handle request window/showDocument."
+ (if (eq external t) (browse-url uri)
+ ;; Use run-with-timer to avoid nested client requests like the
+ ;; synchronous imenu case caused by which-func-mode.
+ (run-with-timer
+ 0 nil
+ (lambda ()
+ (with-current-buffer (find-file-noselect (eglot--uri-to-path uri))
+ (cond (takeFocus
+ (pop-to-buffer (current-buffer))
+ (select-frame-set-input-focus (selected-frame)))
+ ((display-buffer (current-buffer))))
+ (when selection
+ (eglot--widening
+ (pcase-let ((`(,beg . ,end) (eglot--range-region selection)))
+ (goto-char beg)
+ (pulse-momentary-highlight-region beg end 'highlight))))))))
+ '(:success t))
+
(defun eglot--TextDocumentIdentifier ()
"Compute TextDocumentIdentifier object for current buffer."
`(:uri ,(eglot--path-to-uri (or buffer-file-name
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master c083fa5cf80: Eglot: support window/showRequest (bug#62116),
João Távora <=