Do not require eglot at compile time

This fixes #46, reverts c18023132d.
Moved eglot-related functions into a
(eval-and-compile (when (require 'eglot nil t))) form.

* eldoc-box.el (require): Remove eglot requires.
This commit is contained in:
Yuan Fu 2022-05-05 17:22:23 -07:00
parent 6c3107aa69
commit b90780c93c
No known key found for this signature in database
GPG Key ID: 56E19BC57664A442

View File

@ -40,11 +40,6 @@
(require 'cl-lib) (require 'cl-lib)
(require 'seq) (require 'seq)
;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Compiling-Macros.html
(eval-when-compile
(require 'jsonrpc)
(require 'eglot))
;;;; Userland ;;;; Userland
;;;;; Variable ;;;;; Variable
(defgroup eldoc-box nil (defgroup eldoc-box nil
@ -451,11 +446,14 @@ You can use \[keyboard-quit] to hide the doc."
;;;; Eglot helper ;;;; Eglot helper
(defvar eldoc-box-eglot-help-at-point-last-point 0 (eval-and-compile
(require 'jsonrpc)
(when (require 'eglot nil t)
(defvar eldoc-box-eglot-help-at-point-last-point 0
"This point cache is used by clean up function. "This point cache is used by clean up function.
If (point) != last point, cleanup frame.") If (point) != last point, cleanup frame.")
(defun eldoc-box--eglot-help-at-point-cleanup () (defun eldoc-box--eglot-help-at-point-cleanup ()
"Try to clean up the childframe made by eldoc-box hack." "Try to clean up the childframe made by eldoc-box hack."
(if (or (eq (point) eldoc-box-eglot-help-at-point-last-point) (if (or (eq (point) eldoc-box-eglot-help-at-point-last-point)
;; don't clean up when the user clicks childframe ;; don't clean up when the user clicks childframe
@ -463,16 +461,16 @@ If (point) != last point, cleanup frame.")
(run-with-timer 0.1 nil #'eldoc-box--eglot-help-at-point-cleanup) (run-with-timer 0.1 nil #'eldoc-box--eglot-help-at-point-cleanup)
(eldoc-box-quit-frame))) (eldoc-box-quit-frame)))
(defvar eglot--managed-mode) (defvar eglot--managed-mode)
(declare-function eglot--dbind "eglot.el") (declare-function eglot--dbind "eglot.el")
(declare-function eglot--hover-info "eglot.el") (declare-function eglot--hover-info "eglot.el")
(declare-function eglot--current-server-or-lose "eglot.el") (declare-function eglot--current-server-or-lose "eglot.el")
(declare-function eglot--TextDocumentPositionParams "eglot.el") (declare-function eglot--TextDocumentPositionParams "eglot.el")
(declare-function eglot--error "eglot.el") (declare-function eglot--error "eglot.el")
(declare-function jsonrpc-request "jsonrpc") (declare-function jsonrpc-request "jsonrpc")
(defun eldoc-box-eglot-help-at-point () (defun eldoc-box-eglot-help-at-point ()
"Display documentation of the symbol at point." "Display documentation of the symbol at point."
(interactive) (interactive)
(when eglot--managed-mode (when eglot--managed-mode
@ -487,7 +485,7 @@ If (point) != last point, cleanup frame.")
(eldoc-box--display hover-info) (eldoc-box--display hover-info)
(eglot--error "No hover info here")))) (eglot--error "No hover info here"))))
(setq eldoc-box-eglot-help-at-point-last-point (point)) (setq eldoc-box-eglot-help-at-point-last-point (point))
(run-with-timer 0.1 nil #'eldoc-box--eglot-help-at-point-cleanup))) (run-with-timer 0.1 nil #'eldoc-box--eglot-help-at-point-cleanup)))))
;;;; Comany compatibility ;;;; Comany compatibility
;; ;;