mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-03 12:27:26 -05:00
Major refactor & optimization of how modules load their packages
Now that we are loading package autoloads files (as part of the generated doom-package-autoload-file when running make autoloads), many :commands properties are redundant. In fact, many def-package! blocks are redundant. In some cases, we can do without a config.el file entirely, and can move into the autoloads file or rely entirely on package autoloads. Also, many settings have been moved in their module's autoloads files, which makes them available ASAP; their use no longer depends on module load order. This gained me a modest ~10% boost in startup speed.
This commit is contained in:
@ -1,9 +1,16 @@
|
||||
;;; feature/snippets/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defvar +snippets-dir (expand-file-name "snippets/" doom-private-dir)
|
||||
"Directory where `yasnippet' will search for your private snippets.")
|
||||
|
||||
|
||||
;;
|
||||
;; Plugins
|
||||
;;
|
||||
|
||||
(def-package! yasnippet
|
||||
:commands (yas-minor-mode yas-minor-mode-on yas-expand yas-expand-snippet
|
||||
yas-lookup-snippet yas-insert-snippet yas-new-snippet
|
||||
yas-visit-snippet-file snippet-mode)
|
||||
:commands (yas-minor-mode-on yas-expand yas-expand-snippet yas-lookup-snippet
|
||||
yas-insert-snippet yas-new-snippet yas-visit-snippet-file)
|
||||
:preface
|
||||
(defvar yas-minor-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
@ -23,28 +30,25 @@
|
||||
(setq yas-verbosity (if doom-debug-mode 3 0)
|
||||
yas-also-auto-indent-first-line t
|
||||
yas-prompt-functions (delq #'yas-dropdown-prompt yas-prompt-functions)
|
||||
;; Allow nested snippets
|
||||
yas-triggers-in-field t)
|
||||
yas-triggers-in-field t) ; Allow nested snippets
|
||||
|
||||
(cl-pushnew (expand-file-name "snippets/" doom-private-dir) yas-snippet-dirs
|
||||
:test #'string=)
|
||||
(add-to-list 'yas-snippet-dirs '+snippets-dir nil #'eq)
|
||||
|
||||
(defun +snippets|enable-project-modes (mode &rest _)
|
||||
"Enable snippets for project modes."
|
||||
"Automatically enable snippet libraries for project minor modes defined with
|
||||
`def-project-mode!'."
|
||||
(if (symbol-value mode)
|
||||
(yas-activate-extra-mode mode)
|
||||
(yas-deactivate-extra-mode mode)))
|
||||
(add-hook 'doom-project-hook #'+snippets|enable-project-modes)
|
||||
|
||||
;; fix an error caused by smartparens interfering with yasnippet bindings
|
||||
(advice-add #'yas-expand :before #'sp-remove-active-pair-overlay)
|
||||
|
||||
;; Exit snippets on ESC from normal mode
|
||||
(add-hook 'doom-escape-hook #'yas-abort-snippet))
|
||||
(add-hook 'doom-escape-hook #'yas-abort-snippet)
|
||||
|
||||
(after! smartparens
|
||||
;; fix an error caused by smartparens interfering with yasnippet bindings
|
||||
(advice-add #'yas-expand :before #'sp-remove-active-pair-overlay)))
|
||||
|
||||
|
||||
(def-package! auto-yasnippet
|
||||
:commands (aya-create aya-expand aya-open-line aya-persist-snippet)
|
||||
:config
|
||||
(after! auto-yasnippet
|
||||
(setq aya-persist-snippets-dir (concat doom-local-dir "auto-snippets/")))
|
||||
|
||||
|
Reference in New Issue
Block a user