Skip to content

Commit 9d2bab7

Browse files
yuansljcs090218
andauthored
lsp: Add support for external document show (showDocument param :external?) (#4872)
* Add support for external document show This change enhances lsp--window-show-document to handle external URLs by: - Adding external? parameter support from ShowDocumentParams - Opening external URIs in browser via browse-url - Maintaining existing file-based document handling * lsp: response t if we can show document in external browser * style: indentation --------- Co-authored-by: JenChieh <[email protected]>
1 parent f3dcffb commit 9d2bab7

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lsp-mode.el

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2226,14 +2226,18 @@ PARAMS - the data sent from WORKSPACE."
22262226
(completing-read (concat message " ") (seq-into choices 'list) nil t)
22272227
(lsp-log message))))
22282228

2229-
(lsp-defun lsp--window-show-document ((&ShowDocumentParams :uri :selection?))
2230-
"Show document URI in a buffer and go to SELECTION if any."
2229+
(lsp-defun lsp--window-show-document ((&ShowDocumentParams :uri :selection? :external?))
2230+
"Show document URI in a buffer or in a external browser if EXTERNAL is t, and go to SELECTION if any."
22312231
(let ((path (lsp--uri-to-path uri)))
2232-
(when (f-exists? path)
2233-
(with-current-buffer (find-file path)
2234-
(when selection?
2235-
(goto-char (lsp--position-to-point (lsp:range-start selection?))))
2236-
t))))
2232+
(if external?
2233+
(progn
2234+
(browse-url uri)
2235+
t)
2236+
(when (f-exists? path)
2237+
(with-current-buffer (find-file path)
2238+
(when selection?
2239+
(goto-char (lsp--position-to-point (lsp:range-start selection?))))
2240+
t)))))
22372241

22382242
(defcustom lsp-progress-prefix "⌛ "
22392243
"Progress prefix."

0 commit comments

Comments
 (0)