2020-05-28 11:03:49 +02:00
|
|
|
;;; tools/lsp/+eglot.el -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
(use-package! eglot
|
2020-05-28 15:30:20 -04:00
|
|
|
:commands eglot eglot-ensure
|
2020-08-11 21:10:35 -04:00
|
|
|
:hook (eglot-managed-mode . +lsp-init-optimizations-h)
|
2020-05-28 11:03:49 +02:00
|
|
|
:init
|
|
|
|
(setq eglot-sync-connect 1
|
|
|
|
eglot-connect-timeout 10
|
|
|
|
eglot-autoshutdown t
|
|
|
|
eglot-send-changes-idle-time 0.5
|
2020-05-28 15:30:20 -04:00
|
|
|
;; NOTE We disable eglot-auto-display-help-buffer because :select t in
|
|
|
|
;; its popup rule causes eglot to steal focus too often.
|
2020-05-28 11:03:49 +02:00
|
|
|
eglot-auto-display-help-buffer nil)
|
2020-05-28 15:30:20 -04:00
|
|
|
|
2020-05-28 11:03:49 +02:00
|
|
|
:config
|
2020-08-20 14:07:47 -04:00
|
|
|
(set-popup-rule! "^\\*eglot-help" :size 0.15 :quit t :select t)
|
2020-05-28 15:30:20 -04:00
|
|
|
(set-lookup-handlers! 'eglot--managed-mode
|
2020-05-29 16:52:31 +09:00
|
|
|
:implementations #'eglot-find-implementation
|
|
|
|
:type-definition #'eglot-find-typeDefinition
|
2020-08-20 14:07:47 -04:00
|
|
|
:documentation #'+eglot-lookup-documentation)
|
2020-08-21 00:09:59 -04:00
|
|
|
|
|
|
|
(add-to-list 'doom-debug-variables '(eglot-events-buffer-size . 0))
|
|
|
|
|
2020-05-28 11:03:49 +02:00
|
|
|
(when (featurep! :checkers syntax)
|
2020-05-28 11:12:35 +02:00
|
|
|
(after! flycheck
|
2020-08-20 22:00:53 -04:00
|
|
|
(load! "autoload/flycheck-eglot")))
|
|
|
|
|
|
|
|
(defadvice! +lsp--defer-server-shutdown-a (orig-fn &optional server)
|
|
|
|
"Defer server shutdown for a few seconds.
|
|
|
|
This gives the user a chance to open other project files before the server is
|
|
|
|
auto-killed (which is a potentially expensive process). It also prevents the
|
|
|
|
server getting expensively restarted when reverting buffers."
|
|
|
|
:around #'eglot--managed-mode
|
|
|
|
(letf! (defun eglot-shutdown (server)
|
|
|
|
(if (or (null +lsp-defer-shutdown)
|
|
|
|
(eq +lsp-defer-shutdown 0))
|
|
|
|
(funcall eglot-shutdown server)
|
|
|
|
(run-at-time
|
|
|
|
(if (numberp +lsp-defer-shutdown) +lsp-defer-shutdown 3)
|
|
|
|
nil (lambda (server)
|
|
|
|
(unless (eglot--managed-buffers server)
|
|
|
|
(funcall eglot-shutdown server)))
|
|
|
|
server)))
|
|
|
|
(funcall orig-fn server))))
|