2020-05-01 11:01:11 +02:00
|
|
|
;;; tools/lsp/autoload/eglot.el -*- lexical-binding: t; -*-
|
2022-08-12 20:29:19 +02:00
|
|
|
;;;###if (modulep! +eglot)
|
2020-05-01 11:01:11 +02:00
|
|
|
|
|
|
|
;;;###autodef
|
|
|
|
(defun set-eglot-client! (mode server-call)
|
|
|
|
"Add SERVER-CALL list as a possible lsp server for given major MODE.
|
|
|
|
|
2022-08-14 18:10:01 +02:00
|
|
|
Example : (set-eglot-client! 'python-mode `(,(concat doom-data-dir \"lsp/mspyls/Microsoft.Python.LanguageServer\")))"
|
2020-05-28 11:49:53 +02:00
|
|
|
(after! eglot
|
2020-05-01 11:01:11 +02:00
|
|
|
(add-to-list 'eglot-server-programs `(,mode . ,server-call))))
|
|
|
|
|
2020-08-20 14:07:47 -04:00
|
|
|
;; HACK Eglot removed `eglot-help-at-point' in joaotavora/eglot@a044dec for a
|
|
|
|
;; more problematic approach of deferred to eldoc. Here, I've restored it.
|
|
|
|
;; Doom's lookup handlers try to open documentation in a separate window
|
|
|
|
;; (so they can be copied or kept open), but doing so with an eldoc buffer
|
|
|
|
;; is difficult because a) its contents are generated asynchronously,
|
|
|
|
;; making them tough to scrape, and b) their contents change frequently
|
|
|
|
;; (every time you move your cursor).
|
|
|
|
(defvar +eglot--help-buffer nil)
|
2020-05-01 11:01:11 +02:00
|
|
|
;;;###autoload
|
2020-08-20 14:07:47 -04:00
|
|
|
(defun +eglot-lookup-documentation (_identifier)
|
|
|
|
"Request documentation for the thing at point."
|
|
|
|
(eglot--dbind ((Hover) contents range)
|
|
|
|
(jsonrpc-request (eglot--current-server-or-lose) :textDocument/hover
|
|
|
|
(eglot--TextDocumentPositionParams))
|
|
|
|
(let ((blurb (and (not (seq-empty-p contents))
|
|
|
|
(eglot--hover-info contents range)))
|
|
|
|
(hint (thing-at-point 'symbol)))
|
|
|
|
(if blurb
|
|
|
|
(with-current-buffer
|
|
|
|
(or (and (buffer-live-p +eglot--help-buffer)
|
|
|
|
+eglot--help-buffer)
|
|
|
|
(setq +eglot--help-buffer (generate-new-buffer "*eglot-help*")))
|
|
|
|
(with-help-window (current-buffer)
|
|
|
|
(rename-buffer (format "*eglot-help for %s*" hint))
|
|
|
|
(with-current-buffer standard-output (insert blurb))
|
|
|
|
(setq-local nobreak-char-display nil)))
|
|
|
|
(display-local-help))))
|
|
|
|
'deferred)
|