Skip to content

Commit 504d5f6

Browse files
authored
Merge pull request #192 from yyoncho/multi-client
lsp-ui multi client changes
2 parents 5138e72 + 43ab6fc commit 504d5f6

5 files changed

+16
-38
lines changed

lsp-ui-doc.el

+4-8
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ The functions receive 2 parameters: the frame and its window.")
149149

150150
(defvar-local lsp-ui-doc--bounds nil)
151151

152-
(declare-function lsp-ui-sideline--get-renderer 'lsp-ui-sideline)
153-
154152
;; Avoid warning with emacs < 26
155153
(declare-function display-buffer-in-child-frame "window.el")
156154

@@ -165,8 +163,7 @@ Because some variables are buffer local.")
165163
"Execute BODY in the lsp-ui-doc buffer."
166164
`(let ((parent-vars (list :buffer (current-buffer)
167165
:window (get-buffer-window)
168-
:workspace-root (when lsp--cur-workspace
169-
(lsp--workspace-root lsp--cur-workspace)))))
166+
:workspace-root (lsp-workspace-root))))
170167
(with-current-buffer (get-buffer-create (lsp-ui-doc--make-buffer-name))
171168
(setq lsp-ui-doc--parent-vars parent-vars)
172169
(prog1 (let ((buffer-read-only nil))
@@ -230,7 +227,7 @@ MODE is the mode used in the parent frame."
230227
(gethash "value" marked-string)))
231228
(with-lang (hash-table-p marked-string))
232229
(language (and with-lang (gethash "language" marked-string)))
233-
(render-fn (if with-lang (lsp-ui-sideline--get-renderer language)
230+
(render-fn (if with-lang (lsp-get-renderer language)
234231
(and (functionp lsp-ui-doc-render-function)
235232
lsp-ui-doc-render-function)))
236233
(mode major-mode))
@@ -254,7 +251,7 @@ MODE is the mode used in the parent frame."
254251

255252
(defun lsp-ui-doc--filter-marked-string (list-marked-string)
256253
(let ((groups (--separate (and (hash-table-p it)
257-
(lsp-ui-sideline--get-renderer (gethash "language" it)))
254+
(lsp-get-renderer (gethash "language" it)))
258255
(append list-marked-string nil))))
259256
(when-let ((marked-string (caar groups)))
260257
;; Without run-with-idle-timer, echo area will be cleared after displaying the message instantly.
@@ -284,8 +281,7 @@ We don't extract the string that `lps-line' is already displaying."
284281
(defun lsp-ui-doc--hover (orig-fn)
285282
"Request the documentation to the LS."
286283
(if lsp-ui-doc-mode
287-
(when (and (bound-and-true-p lsp--cur-workspace)
288-
(not (bound-and-true-p lsp-ui-peek-mode))
284+
(when (and (not (bound-and-true-p lsp-ui-peek-mode))
289285
(lsp--capability "hoverProvider"))
290286
(cond
291287
((symbol-at-point)

lsp-ui-flycheck.el

+4-4
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ If nil, diagnostics will be reported according to `flycheck-check-syntax-automat
9090
(car (split-string message "\n")))))
9191
(add-text-properties 0 (length text) `(diag ,diag file ,file window ,window) text)
9292
(insert (concat text "\n")))))
93-
lsp--diagnostics))
93+
(lsp-diagnostics)))
9494
(if (= (point) 1)
9595
(overlay-put (make-overlay 1 1)
9696
'after-string "No diagnostic available\n")
@@ -177,11 +177,11 @@ If nil, diagnostics will be reported according to `flycheck-check-syntax-automat
177177
"Start an LSP syntax check with CHECKER.
178178
179179
CALLBACK is the status callback passed by Flycheck."
180-
;; Turn all errors from lsp--diagnostics for the current buffer into
180+
;; Turn all errors from lsp-diagnostics for the current buffer into
181181
;; flycheck-error objects and pass them immediately to the callback
182182
(let ((errors))
183-
(dolist (diag (or (gethash buffer-file-name lsp--diagnostics)
184-
(gethash (file-truename buffer-file-name) lsp--diagnostics)))
183+
(dolist (diag (or (gethash buffer-file-name (lsp-diagnostics))
184+
(gethash (file-truename buffer-file-name) (lsp-diagnostics))))
185185
(push (flycheck-error-new
186186
:buffer (current-buffer)
187187
:checker checker

lsp-ui-peek.el

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ XREFS is a list of references/definitions."
337337
(-let* ((xref (lsp-ui-peek--get-selection))
338338
((&plist :file file :chunk chunk) (or xref lsp-ui-peek--last-xref))
339339
(header (concat " " (lsp-ui--workspace-path file) "\n"))
340-
(header2 (format " %s %s" lsp-ui-peek--size-list
340+
(header2 (format " %s %s" lsp-ui-peek--size-list
341341
(string-remove-prefix "workspace/" (string-remove-prefix "textDocument/" lsp-ui-peek--method))))
342342
(ref-view (--> chunk
343343
(if (eq lsp-ui-peek-fontify 'on-demand)

lsp-ui-sideline.el

+4-20
Original file line numberDiff line numberDiff line change
@@ -176,21 +176,6 @@ if UP is non-nil, it loops on the previous lines.."
176176
(seq-do 'delete-overlay lsp-ui-sideline--ovs)
177177
(setq lsp-ui-sideline--ovs nil))
178178

179-
(defun lsp-ui-sideline--get-renderer (language)
180-
"Return a function to fontify a string in LANGUAGE."
181-
(thread-last lsp--cur-workspace
182-
lsp--workspace-client
183-
lsp--client-string-renderers
184-
(assoc-string language)
185-
cdr))
186-
187-
(defun lsp-ui-sideline--get-language ()
188-
"Return the language of the buffer."
189-
(thread-first lsp--cur-workspace
190-
lsp--workspace-client
191-
lsp--client-language-id
192-
(funcall (current-buffer))))
193-
194179
(defun lsp-ui-sideline--extract-info (contents)
195180
"Extract the line to print from CONTENTS.
196181
CONTENTS can be differents type of values:
@@ -202,11 +187,11 @@ function signature)."
202187
((stringp contents) contents)
203188
((sequencep contents) ;; MarkedString[]
204189
(seq-find (lambda (it) (and (hash-table-p it)
205-
(lsp-ui-sideline--get-renderer (gethash "language" it))))
190+
(lsp-get-renderer (gethash "language" it))))
206191
contents))
207192
((gethash "kind" contents) (gethash "value" contents)) ;; MarkupContent
208193
((gethash "language" contents) ;; MarkedString
209-
(and (lsp-ui-sideline--get-renderer (gethash "language" contents))
194+
(and (lsp-get-renderer (gethash "language" contents))
210195
(gethash "value" contents))))))
211196

212197
(defun lsp-ui-sideline--format-info (marked-string)
@@ -218,7 +203,7 @@ MARKED-STRING is the string returned by `lsp-ui-sideline--extract-info'."
218203
(when (hash-table-p marked-string)
219204
(let* ((language (gethash "language" marked-string))
220205
(value (gethash "value" marked-string))
221-
(renderer (lsp-ui-sideline--get-renderer language)))
206+
(renderer (lsp-get-renderer language)))
222207
(setq marked-string (if (and (functionp renderer) value)
223208
(funcall renderer value)
224209
value))))
@@ -384,8 +369,7 @@ CURRENT is non-nil when the point is on the symbol."
384369
It loops on the symbols of the current line and request information
385370
to the language server."
386371
(lsp-ui-sideline--delete-ov)
387-
(when (and lsp--cur-workspace
388-
buffer-file-name)
372+
(when buffer-file-name
389373
(let ((eol (line-end-position))
390374
(bol (line-beginning-position))
391375
(tag (lsp-ui-sideline--calculate-tag))

lsp-ui.el

+3-5
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,14 @@
5454
(funcall major))
5555
(ignore-errors
5656
(font-lock-ensure)))
57-
(buffer-string))
58-
)
59-
57+
(buffer-string)))
6058

6159
(defun lsp-ui--workspace-path (path)
6260
"Return the PATH relative to the workspace.
6361
If the PATH is not in the workspace, it returns the original PATH."
6462
(let* ((path (file-truename path))
65-
(root (lsp--workspace-root lsp--cur-workspace))
66-
(in-workspace (string-prefix-p root path)))
63+
(root (lsp-workspace-root path))
64+
(in-workspace (and root (string-prefix-p root path))))
6765
(if in-workspace
6866
(substring path (length root))
6967
path)))

0 commit comments

Comments
 (0)