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:
Henrik Lissner 2018-05-25 00:46:11 +02:00
parent 6a140209b8
commit 09cb4f6716
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
93 changed files with 644 additions and 846 deletions

View file

@ -1,32 +1,20 @@
;;; lang/nim/config.el -*- lexical-binding: t; -*-
(def-package! nim-mode
:mode "\\.nim\\'"
:mode ("\\.nim\\(ble\\|s\\)\\'" . nimscript-mode)
:config
(load "nim-mode-autoloads" nil t)
;; NOTE nim-mode autoloads sets up xref
(after! nim-mode
(defun +nim|init-nimsuggest-mode ()
"Conditionally load `nimsuggest-mode', instead of clumsily erroring out if
nimsuggest isn't installed."
(when (executable-find "nimsuggest")
(when (file-executable-p nimsuggest-path)
(nimsuggest-mode)))
(add-hook 'nim-mode-hook #'+nim|init-nimsuggest-mode)
(map! :map nim-mode-map
:localleader
:n "b" #'+nim/build-menu)
(def-menu! +nim/build-menu
"Building commands for `nim-mode' buffers."
'(("Build & run" :exec nim-compile))
:prompt "Build"))
:n "b" #'nim-compile))
(def-package! flycheck-nim
:when (featurep! :feature syntax-checker)
:after nim-mode
:config
(add-hook 'nimsuggest-mode-hook #'flycheck-mode))
:config (add-hook 'nimsuggest-mode-hook #'flycheck-mode))