mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
Eglot: treat code=0 JSONRPC errors as benign
* lisp/progmodes/eglot.el (eglot--request): Shoosh code=0 errors. (eglot-mode-line-error): Check for code=0.
This commit is contained in:
parent
adb605716f
commit
977e354709
1 changed files with 23 additions and 15 deletions
|
|
@ -1959,15 +1959,21 @@ in project `%s'."
|
|||
"Like `jsonrpc-request', but for Eglot LSP requests.
|
||||
Unless IMMEDIATE, send pending changes before making request."
|
||||
(unless immediate (eglot--signal-textDocument/didChange))
|
||||
(jsonrpc-request server method params
|
||||
:timeout timeout
|
||||
:cancel-on-input
|
||||
(cond ((and cancel-on-input
|
||||
eglot-advertise-cancellation)
|
||||
(lambda (id)
|
||||
(jsonrpc-notify server '$/cancelRequest `(:id ,id))))
|
||||
(cancel-on-input))
|
||||
:cancel-on-input-retval cancel-on-input-retval))
|
||||
(condition-case oops
|
||||
(jsonrpc-request
|
||||
server method params
|
||||
:timeout timeout
|
||||
:cancel-on-input
|
||||
(cond ((and cancel-on-input
|
||||
eglot-advertise-cancellation)
|
||||
(lambda (id)
|
||||
(jsonrpc-notify server '$/cancelRequest `(:id ,id))))
|
||||
(cancel-on-input))
|
||||
:cancel-on-input-retval cancel-on-input-retval)
|
||||
(jsonrpc-error
|
||||
(let* ((data (cddr oops)) (code (alist-get 'jsonrpc-error-code data)))
|
||||
(if (zerop code) (eglot--message (alist-get 'jsonrpc-error-message data))
|
||||
(signal 'jsonrpc-error (cdr oops)))))))
|
||||
|
||||
(defvar-local eglot--inflight-async-requests nil
|
||||
"An plist of symbols to lists of JSONRPC ids.
|
||||
|
|
@ -2643,12 +2649,14 @@ Uses THING, FACE, DEFS and PREPEND."
|
|||
|
||||
(defconst eglot-mode-line-error
|
||||
'(:eval (when-let* ((server (eglot-current-server))
|
||||
(last-error (and server (jsonrpc-last-error server))))
|
||||
(eglot--mode-line-props
|
||||
"error" 'compilation-mode-line-fail
|
||||
'((mouse-3 eglot-clear-status "Clear this status"))
|
||||
(format "An error occurred: %s\n" (plist-get last-error
|
||||
:message)))))
|
||||
(last-error (and server (jsonrpc-last-error server)))
|
||||
(code (plist-get last-error :code)))
|
||||
(unless (zerop code)
|
||||
(eglot--mode-line-props
|
||||
"error" 'compilation-mode-line-fail
|
||||
'((mouse-3 eglot-clear-status "Clear this status"))
|
||||
(format "An error occurred: %s\n" (plist-get last-error
|
||||
:message))))))
|
||||
"Eglot mode line construct for LSP errors.")
|
||||
|
||||
(defconst eglot-mode-line-pending-requests
|
||||
|
|
|
|||
Loading…
Reference in a new issue