Use symbol-at-point instead of xref w/ eglot

Otherwise doom-thing-at-point-or-region will return nil, causing
"Nothing under point" warnings when using lookup commands.
This commit is contained in:
Henrik Lissner 2020-06-29 15:12:30 -04:00
parent 6b781c55c2
commit 46d6d0b586
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -105,12 +105,15 @@ in some cases."
(doom-region-end))) (doom-region-end)))
(thing (thing
(thing-at-point thing t)) (thing-at-point thing t))
((and (require 'xref nil t) (not (eq (xref-find-backend) 'eglot))) ((require 'xref nil t)
;; A little smarter than using `symbol-at-point', though in most cases, ;; Eglot defines a dummy for `xref-find-backend', so we need a special
;; xref ends up using `symbol-at-point' anyway. ;; case to avoid xref when using eglot. See
;; "Most cases" doesn't cover 'eglot so we manually exclude it. ;; https://github.com/joaotavora/eglot/issues/503
;; See discussion in https://github.com/joaotavora/eglot/issues/503 (if (eq (xref-find-backend) 'eglot)
(xref-backend-identifier-at-point (xref-find-backend))) (thing-at-point 'symbol t)
;; A little smarter than using `symbol-at-point', though in most
;; cases, xref ends up using `symbol-at-point' anyway.
(xref-backend-identifier-at-point (xref-find-backend))))
(prompt (prompt
(read-string (if (stringp prompt) prompt ""))))) (read-string (if (stringp prompt) prompt "")))))