doomemacs/modules/tools/lsp/config.el
Henrik Lissner ad6a3d0f33
refactor: deprecate featurep! for modulep!
featurep! will be renamed modulep! in the future, so it's been
deprecated. They have identical interfaces, and can be replaced without
issue.

featurep! was never quite the right name for this macro. It implied that
it had some connection to featurep, which it doesn't (only that it was
similar in purpose; still, Doom modules are not features). To undo such
implications and be consistent with its namespace (and since we're
heading into a storm of breaking changes with the v3 release anyway),
now was the best opportunity to begin the transition.
2022-08-14 20:43:35 +02:00

47 lines
1.8 KiB
EmacsLisp

;;; tools/lsp/config.el -*- lexical-binding: t; -*-
(defvar +lsp-defer-shutdown 3
"If non-nil, defer shutdown of LSP servers for this many seconds after last
workspace buffer is closed.
This delay prevents premature server shutdown when a user still intends on
working on that project after closing the last buffer, or when programmatically
killing and opening many LSP/eglot-powered buffers.")
;;
;;; Common
(defvar +lsp--default-read-process-output-max nil)
(defvar +lsp--default-gcmh-high-cons-threshold nil)
(defvar +lsp--optimization-init-p nil)
(define-minor-mode +lsp-optimization-mode
"Deploys universal GC and IPC optimizations for `lsp-mode' and `eglot'."
:global t
:init-value nil
(if (not +lsp-optimization-mode)
(setq-default read-process-output-max +lsp--default-read-process-output-max
gcmh-high-cons-threshold +lsp--default-gcmh-high-cons-threshold
+lsp--optimization-init-p nil)
;; Only apply these settings once!
(unless +lsp--optimization-init-p
(setq +lsp--default-read-process-output-max (default-value 'read-process-output-max)
+lsp--default-gcmh-high-cons-threshold (default-value 'gcmh-high-cons-threshold))
(setq-default read-process-output-max (* 1024 1024))
;; REVIEW LSP causes a lot of allocations, with or without the native JSON
;; library, so we up the GC threshold to stave off GC-induced
;; slowdowns/freezes. Doom uses `gcmh' to enforce its GC strategy,
;; so we modify its variables rather than `gc-cons-threshold'
;; directly.
(setq-default gcmh-high-cons-threshold (* 2 +lsp--default-gcmh-high-cons-threshold))
(gcmh-set-high-threshold)
(setq +lsp--optimization-init-p t))))
;;
;;; Implementations
(if (modulep! +eglot)
(load! "+eglot")
(load! "+lsp"))