Improve vanity metric: startup time

This commit is contained in:
David Morgan 2022-10-14 12:29:07 +01:00
parent 05edd37e19
commit fc3ad64579
Signed by: djm
GPG Key ID: C171251002C200F2
4 changed files with 99 additions and 106 deletions

View File

@ -12,7 +12,7 @@
(dabbrev-case-replace nil))
(use-feature hippie-expand
:init
:config
(setq hippie-expand-try-functions-list
'(;yas-hippie-try-expand
try-expand-dabbrev
@ -25,7 +25,6 @@
try-expand-line
try-complete-lisp-symbol-partially
try-complete-lisp-symbol))
:config
;; https://www.emacswiki.org/emacs/HippieExpand#h5o-9
(defadvice he-substitute-string (after he-paredit-fix)
"Remove extra paren when expanding line in paredit."
@ -52,20 +51,23 @@
(setq tab-always-indent 'complete))
(use-package orderless
:defer 2
:bind (:map minibuffer-local-map
("C-l" . my/orderless-match-components-literally))
:custom (orderless-component-separator 'orderless-escapable-split-on-space)
:init
(setq completion-styles '(orderless partial-completion basic)
completion-category-defaults nil
completion-category-overrides '((file (styles . (partial-completion orderless)))))
:custom
(orderless-component-separator 'orderless-escapable-split-on-space)
(completion-styles '(orderless partial-completion basic))
(completion-category-defaults nil)
(completion-category-overrides '((file (styles . (partial-completion orderless)))))
(orderless-matching-styles '(orderless-literal orderless-regexp orderless-strict-leading-initialism))
(orderless-style-dispatchers '(+orderless-dispatch))
:config
(defun my/orderless-match-components-literally ()
"Components match literally for the rest of the session."
(interactive)
(setq-local orderless-matching-styles '(orderless-literal)
orderless-style-dispatchers nil))
:config
(defun orderless-strict-initialism (component &optional leading)
"Match a component as a strict leading initialism.
This means the characters in COMPONENT must occur in the
@ -124,10 +126,7 @@ no words in between, beginning with the first word."
((if-let (x (assq (aref word 0) +orderless-dispatch-alist))
(cons (cdr x) (substring word 1))
(when-let (x (assq (aref word (1- (length word))) +orderless-dispatch-alist))
(cons (cdr x) (substring word 0 -1)))))))
(setq orderless-matching-styles '(orderless-literal orderless-regexp orderless-strict-leading-initialism)
orderless-style-dispatchers '(+orderless-dispatch)))
(cons (cdr x) (substring word 0 -1))))))))
;; code completion - corfu
(use-package corfu
@ -139,12 +138,11 @@ no words in between, beginning with the first word."
([tab] . corfu-next)
("S-TAB" . corfu-previous)
([backtab] . corfu-previous))
:init
(global-corfu-mode))
:hook (emacs-startup . global-corfu-mode))
(use-package corfu-doc
:config
(add-hook 'corfu-mode-hook #'corfu-doc-mode))
:hook
(corfu-mode . corfu-doc-mode))
(use-package cape
:bind (("C-c p p" . completion-at-point) ;; capf

View File

@ -5,8 +5,12 @@
;; Relies on orderless config in init-completion.el
;;; Code:
(use-package emacs
:init
(use-package vertico
:straight (vertico :files (:defaults "extensions/*")
:includes (vertico-directory vertico-repeat))
:hook (emacs-startup . vertico-mode)
:custom (vertico-cycle t)
:config
;; Do not allow the cursor in the minibuffer prompt
(setq minibuffer-prompt-properties
'(read-only t cursor-intangible t face minibuffer-prompt))
@ -28,15 +32,8 @@
;; Emacs 28: Hide commands in M-x which do not work in the current mode.
;; Vertico commands are hidden in normal buffers.
(setq read-extended-command-predicate
#'command-completion-default-include-p))
#'command-completion-default-include-p)
(use-package vertico
:straight (vertico :files (:defaults "extensions/*")
:includes (vertico-directory vertico-repeat))
:init
(vertico-mode)
:custom (vertico-cycle t)
:config
(advice-add #'vertico--format-candidate :around
(lambda (orig cand prefix suffix index start)
(setq cand (funcall orig cand prefix suffix index start))
@ -99,7 +96,7 @@ DEFS is a plist associating completion categories to commands."
(use-feature vertico-directory
:after vertico
:init
:config
(defvar switching-project nil)
(defun vertico-directory-enter-or-select-project ()
"vertico-directory-enter wrapper that plays nicely with selecting new projects."
@ -140,13 +137,12 @@ DEFS is a plist associating completion categories to commands."
(define-vertico-key "M-DEL"
'file #'vertico-directory-delete-word
'project-file #'vertico-directory-delete-word)
:config
:commands (vertico-directory-enter vertico-directory-delete-word vertico-directory-delete-char)
;; Tidy shadowed file names
:hook (rfn-eshadow-update-overlay . vertico-directory-tidy))
(use-feature vertico-repeat
:bind ("M-P" . vertico-repeat))
:bind ("<f9>" . vertico-repeat))
(use-package consult
:bind (;; C-c bindings (mode-specific-map)
@ -198,7 +194,7 @@ DEFS is a plist associating completion categories to commands."
;; Toggle preview on/off without changing preview-key
("M-P" . consult-toggle-preview)))
:init
:config
;; Optionally configure the register formatting. This improves the register
;; preview for `consult-register', `consult-register-load',
@ -214,8 +210,6 @@ DEFS is a plist associating completion categories to commands."
(setq xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref)
:config
(defun consult-ripgrep-symbol-at-point (&optional dir initial)
(interactive
(list prefix-arg (when-let ((s (symbol-at-point)))
@ -410,9 +404,9 @@ DEFS is a plist associating completion categories to commands."
(use-package consult-project-extra)
(use-package marginalia
:init
:hook (emacs-startup . marginalia-mode)
:config
;; crux-recentf-find-file
(marginalia-mode)
(add-to-list 'marginalia-prompt-categories '("Choose recent file" . file)))
(use-package embark
@ -428,8 +422,8 @@ DEFS is a plist associating completion categories to commands."
(:map embark-become-file+buffer-map
("e" . consult-project-extra-find)
("E" . project-switch-consult-project-extra-find)))
:init
(setq prefix-help-command #'embark-prefix-help-command)
:custom
(prefix-help-command 'embark-prefix-help-command)
:config
(defun embark-preview ()
(interactive)
@ -446,9 +440,9 @@ DEFS is a plist associating completion categories to commands."
(use-package embark-consult
:after (embark consult)
:demand t ; only necessary if you have the hook below
;; if you want to have consult previews as you move around an
;; auto-updating embark collect buffer
;; demand, combined with after means that this will load after embark and consult
;; See https://github.com/oantolin/embark/commit/47daded610b245caf01a97d74c940aff91fe14e2#r46010972
:demand t
:bind
(:map embark-consult-async-search-map
("^" . consult-ripgrep-parent)

View File

@ -47,7 +47,6 @@
(use-package deadgrep)
(use-package affe
:after (consult orderless)
:config
(setq affe-grep-command (replace-regexp-in-string "\\." "-Suu ." affe-grep-command))
;; Configure Orderless

View File

@ -5,13 +5,19 @@
;;; Code:
(use-package emacs
:config
(cond
((find-font (font-spec :name "iosevka comfy"))
(set-face-attribute 'default nil :font "iosevka comfy"))
((find-font (font-spec :name "iosevka"))
(set-face-attribute 'default nil :font "iosevka")))
:hook (emacs-startup . (lambda ()
(cond
((find-font (font-spec :name "iosevka comfy"))
(set-face-attribute 'default nil :font "iosevka comfy"))
((find-font (font-spec :name "iosevka"))
(set-face-attribute 'default nil :font "iosevka")))
(global-display-line-numbers-mode)
(global-hl-line-mode +1)
(global-set-key (kbd "C-x C-S-k") 'kill-this-buffer)))
:config
;; https://github.com/rougier/elegant-emacs/blob/master/sanity.el
(setq inhibit-startup-screen t
inhibit-startup-echo-area-message t
@ -32,13 +38,8 @@
scroll-conservatively 100000
scroll-preserve-screen-position 1)
(global-display-line-numbers-mode)
(global-hl-line-mode +1)
(fset 'yes-or-no-p 'y-or-n-p)
(global-set-key (kbd "C-x C-S-k") 'kill-this-buffer)
(setq frame-title-format
'("Emacs: " (:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name))
@ -50,46 +51,58 @@
(setq mac-command-modifier 'super)))
(use-package modus-themes
:init
(setq modus-themes-syntax '(green-strings yellow-comments)
modus-themes-paren-match '(bold intense underline)
modus-themes-bold-constructs t
modus-themes-italic-constructs t
modus-themes-lang-checkers '(text-also))
(load-theme 'modus-vivendi t)
;; Use less magenta
(custom-set-faces
`(font-lock-builtin-face ((t (:foreground "LawnGreen"))))
`(font-lock-keyword-face ((t (:foreground "gold"))))
`(font-lock-function-name-face ((t (:foreground "cyan"))))
`(font-lock-variable-name-face ((t (:foreground "gold3"))))
`(font-lock-constant-face ((t (:foreground "DeepSkyBlue2"))))
`(font-lock-type-face ((t (:foreground "PaleGreen2"))))
`(font-lock-string-face ((t (:foreground "SpringGreen3"))))
`(font-lock-comment-face ((t (:foreground "burlywood"))))
`(font-lock-doc-face ((t :foreground "LightCyan3")))
`(region ((t (:background "firebrick"))))
`(secondary-selection ((t (:background "firebrick4"))))
`(idle-highlight ((t (:background "grey50" :foreground "white"))))
`(isearch ((t (:background "coral2"))))
`(lazy-highlight ((t (:background "LightSteelBlue2" :foreground "black"))))
`(match ((t (:background "gray35" :foreground "grey85"))))
`(lsp-face-highlight-textual ((t (:background "DimGrey"))))
`(whitespace-empty ((t (:background "gray10"))))
`(hl-line ((t :background "gray15" :underline "gray35" :inherit nil)))
`(simple-modeline-status-modified ((t :foreground "DeepSkyBlue")))
`(consult-async-split ((t :foreground "LightCoral")))
`(orderless-match-face-0 ((t :foreground "tomato")))
`(orderless-match-face-1 ((t :foreground "SpringGreen2")))
`(orderless-match-face-2 ((t :foreground "gold")))
`(orderless-match-face-3 ((t :foreground "cyan")))
`(flycheck-fringe-warning ((t :foreground "white" :background "gold3")))
`(flycheck-fringe-error ((t :foreground "white" :background "red2")))
`(flycheck-fringe-info ((t :foreground "white" :background "RoyalBlue3")))
`(alt-font-lock-keyword-face ((t :foreground "LightSkyBlue" :weight bold)))
`(alt-hl-line-face ((t :underline "gray50" :weight bold))))
:config
(defun my/load-theme ()
"Load modus vivendi theme, with my customisations."
(setq modus-themes-syntax '(green-strings yellow-comments)
modus-themes-paren-match '(bold intense underline)
modus-themes-bold-constructs t
modus-themes-italic-constructs t
modus-themes-lang-checkers '(text-also))
(load-theme 'modus-vivendi t)
(custom-set-faces
`(font-lock-builtin-face ((t (:foreground "LawnGreen"))))
`(font-lock-keyword-face ((t (:foreground "gold"))))
`(font-lock-function-name-face ((t (:foreground "cyan"))))
`(font-lock-variable-name-face ((t (:foreground "gold3"))))
`(font-lock-constant-face ((t (:foreground "DeepSkyBlue2"))))
`(font-lock-type-face ((t (:foreground "PaleGreen2"))))
`(font-lock-string-face ((t (:foreground "SpringGreen3"))))
`(font-lock-comment-face ((t (:foreground "burlywood"))))
`(font-lock-doc-face ((t :foreground "LightCyan3")))
`(region ((t (:background "firebrick"))))
`(secondary-selection ((t (:background "firebrick4"))))
`(idle-highlight ((t (:background "grey50" :foreground "white"))))
`(isearch ((t (:background "coral2"))))
`(lazy-highlight ((t (:background "LightSteelBlue2" :foreground "black"))))
`(match ((t (:background "gray35" :foreground "grey85"))))
`(lsp-face-highlight-textual ((t (:background "DimGrey"))))
`(whitespace-empty ((t (:background "gray10"))))
`(hl-line ((t :background "gray15" :underline "gray35" :inherit nil)))
`(simple-modeline-status-modified ((t :foreground "DeepSkyBlue")))
`(consult-async-split ((t :foreground "LightCoral")))
`(orderless-match-face-0 ((t :foreground "tomato")))
`(orderless-match-face-1 ((t :foreground "SpringGreen2")))
`(orderless-match-face-2 ((t :foreground "gold")))
`(orderless-match-face-3 ((t :foreground "cyan")))
`(flycheck-fringe-warning ((t :foreground "white" :background "gold3")))
`(flycheck-fringe-error ((t :foreground "white" :background "red2")))
`(flycheck-fringe-info ((t :foreground "white" :background "RoyalBlue3")))
`(alt-font-lock-keyword-face ((t :foreground "LightSkyBlue" :weight bold)))
`(alt-hl-line-face ((t :underline "gray50" :weight bold))))
(setq hl-todo-keyword-faces
'(("TODO" . "red3")
("FIXME" . "red3")
("DEBUG" . "#A020F0")
("GOTCHA" . "#FF4500")
("HACK" . "#FF4500")
("STUB" . "#1E90FF")
("FAIL" . "red3")
("NOTE" . "DarkOrange2")
("DEPRECATED" . "yellow"))))
(defun use-alt-font-lock-keyword-face ()
"Remap font-lock-keyword-face to the alternate one, in the current buffer"
(face-remap-add-relative 'font-lock-keyword-face 'alt-font-lock-keyword-face))
@ -97,12 +110,11 @@
"Remap hl-line face to the alternate one, in the current buffer"
(face-remap-add-relative 'hl-line 'alt-hl-line-face))
:hook
(after-init . my/load-theme)
(cider-inspector-mode . use-alt-font-lock-keyword-face)
(magit-mode . use-alt-hl-line-face))
(use-package hl-todo
:defer 5
:after modus-themes
:bind
(:map hl-todo-mode-map
("C-c c t p" . hl-todo-previous)
@ -110,19 +122,9 @@
("C-c c t o" . hl-todo-occur)
("C-c c t r" . hl-todo-rgrep)
("C-c c t i" . hl-todo-insert))
:custom
(hl-todo-keyword-faces
'(("TODO" . "red3")
("FIXME" . "red3")
("DEBUG" . "#A020F0")
("GOTCHA" . "#FF4500")
("HACK" . "#FF4500")
("STUB" . "#1E90FF")
("FAIL" . "red3")
("NOTE" . "DarkOrange2")
("DEPRECATED" . "yellow")))
:config
(global-hl-todo-mode 1))
;; Use emacs-startup-hook so that it runs after my/load-theme is called in after-init-hook
;; hl-todo-keyword-faces is customised in my/load-theme
:hook (emacs-startup . global-hl-todo-mode))
(use-package whitespace
:diminish