Function: eca-editor--nav-request
eca-editor--nav-request is a natively compiled function defined in
eca-editor.el.
Signature
(eca-editor--nav-request SESSION REQUEST PARAMS METHOD EXTRA-PARAMS)
Documentation
Ask the editor for the METHOD locations of the symbol in PARAMS.
Respond to the server REQUEST of SESSION following the status
contract of the editor/getDefinition and editor/getReferences
requests: success, starting, no-server or error. EXTRA-PARAMS
are appended to the lsp request params. Prefer lsp-mode, falling
back to the buffer's xref backend (eglot, etags, ...) when
lsp-mode cannot serve the file. Return the response plist for
sync answers or :async when the response will be sent later.
Source Code
;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-editor.el
(defun eca-editor--nav-request (session request params method extra-params)
"Ask the editor for the METHOD locations of the symbol in PARAMS.
Respond to the server REQUEST of SESSION following the status
contract of the `editor/getDefinition' and `editor/getReferences'
requests: success, starting, no-server or error. EXTRA-PARAMS
are appended to the lsp request params. Prefer lsp-mode, falling
back to the buffer's xref backend (eglot, etags, ...) when
lsp-mode cannot serve the file. Return the response plist for
sync answers or `:async' when the response will be sent later."
(let* ((uri (plist-get params :uri))
(position (plist-get params :position))
(path (and uri (eca--uri-to-path uri))))
(cond
((or (null path) (not (file-exists-p path)))
(list :status "error"
:message (format "File not found: %s" (or path uri))))
((not (eca-editor--lsp-nav-available-p))
(with-current-buffer (eca-editor--file-buffer path)
(eca-editor--xref-fallback
session request params method
(list :status "no-server"
:message "No lsp-mode and no xref backend available for this file"))))
(t
(with-current-buffer (eca-editor--file-buffer path)
(let ((workspaces (eca-editor--lsp-buffer-workspaces)))
(cond
;; Workspace attached but the server has not finished the
;; initialize handshake yet: requests would fail with a
;; misleading capability error, so ask the server to retry.
((and workspaces
(not (eca-editor--lsp-workspaces-ready-p workspaces)))
(list :status "starting"))
(workspaces
(condition-case err
(progn
(eca-editor--lsp-request-async
method
(append (list :textDocument (list :uri (eca--path-to-uri path))
:position (list :line (max 0 (1- (or (plist-get position :line) 1)))
:character (max 0 (1- (or (plist-get position :character) 1)))))
extra-params)
(lambda (result)
(eca-api-send-request-response
session request
(list :status "success"
:locations (eca-editor--lsp-locations->eca result))))
(lambda (err)
(eca-api-send-request-response
session request
(list :status "error"
:message (eca-editor--lsp-error-message err)))))
:async)
;; lsp-mode can signal synchronously, e.g. the capability
;; check; answer error instead of dying in the filter.
(error (list :status "error"
:message (error-message-string err)))))
((eca-editor--lsp-known-root-p path)
(condition-case err
(if (eca-editor--lsp-start)
(list :status "starting")
(eca-editor--xref-fallback
session request params method
(list :status "no-server"
:message "No installed lsp-mode client for this file's major mode and no xref backend")))
(error (eca-editor--xref-fallback
session request params method
(list :status "no-server"
:message (error-message-string err))))))
(t
(eca-editor--xref-fallback
session request params method
(list :status "no-server"
:message "No lsp-mode workspace and no xref backend for this file; start lsp or eglot in its project once"))))))))))