diff options
| -rw-r--r-- | home-manager/homeModules/emacs/config.org | 524 | ||||
| -rw-r--r-- | home-manager/homeModules/emacs/early-init.el | 197 |
2 files changed, 579 insertions, 142 deletions
diff --git a/home-manager/homeModules/emacs/config.org b/home-manager/homeModules/emacs/config.org index 4942611..37cb6a5 100644 --- a/home-manager/homeModules/emacs/config.org +++ b/home-manager/homeModules/emacs/config.org @@ -5,9 +5,8 @@ * Table Of Contents :toc: - [[#progs-to-load-first][Progs to load first]] - - [[#optimisations][Optimisations]] - [[#elpaca][elpaca]] - - [[#native-comp-warnings][Native comp warnings]] + - [[#from-minimal-emacsd][From minimal-emacs.d]] - [[#no-littering][No littering]] - [[#save-history][Save history]] - [[#meow-mode][Meow mode]] @@ -22,13 +21,10 @@ - [[#modeline][Modeline]] - [[#scroll][Scroll]] - [[#dashboard][Dashboard]] - - [[#disable-ring-bell][Disable ring-bell]] - [[#indent-guide][Indent guide]] - - [[#misc][Misc]] -- [[#projects][Projects]] - [[#org-mode][Org mode]] - [[#org-modern][Org modern]] - - [[#enabling-toc][Enabling toc]] +- [[#enabling-toc][Enabling toc]] - [[#better-ux][Better UX]] - [[#vertico][Vertico]] - [[#consult][Consult]] @@ -119,9 +115,248 @@ (elpaca-wait) #+end_src -** Native comp warnings +** From minimal-emacs.d +*** Minibuffer #+begin_src emacs-lisp - (setq native-comp-async-report-warnings-errors nil) + (setq enable-recursive-minibuffers t) +#+end_src +*** Misc +#+begin_src emacs-lisp + ;; switch-to-buffer runs pop-to-buffer-same-window instead + (setq switch-to-buffer-obey-display-actions t) + + (setq show-paren-delay 0.1 + show-paren-highlight-openparen t + show-paren-when-point-inside-paren t + show-paren-when-point-in-periphery t) + + (setq whitespace-line-column nil) ; whitespace-mode + (setq comint-prompt-read-only t) + (setq comint-buffer-maximum-size 2048) + + (setq compilation-always-kill t + compilation-ask-about-save nil + compilation-scroll-output 'first-error) + + (setq truncate-string-ellipsis "…") + + ;; Configure Emacs to ask for confirmation before exiting + (setq confirm-kill-emacs 'y-or-n-p) + + ;; Delete by moving to trash in interactive mode + (setq delete-by-moving-to-trash (not noninteractive)) +#+end_src +*** Files +#+begin_src emacs-lisp + ;; Disable the warning-suppress-types "X and Y are the same file". Ignoring this warning is + ;; acceptable since it will redirect you to the existing buffer regardless. + (setq find-file-suppress-same-file-warnings t) + + ;; Resolve symlinks when opening files, so that any operations are conducted + ;; from the file's true directory (like `find-file'). + (setq find-file-visit-truename t + vc-follow-symlinks t) + + ;; Skip confirmation prompts when creating a new file or buffer + (setq confirm-nonexistent-file-or-buffer nil) + + (setq uniquify-buffer-name-style 'forward) + + (setq mouse-yank-at-point t) +#+end_src +*** Backup files +#+begin_src emacs-lisp + ;; Avoid generating backups or lockfiles to prevent creating world-readable + ;; copies of files. + (setq create-lockfiles nil) + (setq make-backup-files nil) + + (setq backup-directory-alist + `(("." . ,(expand-file-name "backup" user-emacs-directory)))) + (setq tramp-backup-directory-alist backup-directory-alist) + (setq backup-by-copying-when-linked t) + (setq backup-by-copying t) ; Backup by copying rather renaming + (setq delete-old-versions t) ; Delete excess backup versions silently + (setq version-control t) ; Use version numbers for backup files + (setq kept-new-versions 5) + (setq kept-old-versions 5) + (setq vc-make-backup-files nil) ; Do not backup version controlled files +#+end_src +*** Auto save +#+begin_src emacs-lisp + ;; Enable auto-save to safeguard against crashes or data loss. The + ;; `recover-file' or `recover-session' functions can be used to restore + ;; auto-saved data. + (setq auto-save-default t) + + ;; Do not auto-disable auto-save after deleting large chunks of + ;; text. The purpose of auto-save is to provide a failsafe, and + ;; disabling it contradicts this objective. + (setq auto-save-include-big-deletions t) + + (setq auto-save-list-file-prefix + (expand-file-name "autosave/" user-emacs-directory)) + (setq tramp-auto-save-directory + (expand-file-name "tramp-autosave/" user-emacs-directory)) + + ;; Auto save options + (setq kill-buffer-delete-auto-save-files t) +#+end_src +*** Auto revert +=Auto-revert= in Emacs is a feature that automatically updates the +contents of a buffer to reflect changes made to the underlying file +on disk. + +#+begin_src emacs-lisp + (setq revert-without-query (list ".") ; Do not prompt + auto-revert-stop-on-user-input nil + auto-revert-verbose t) + + ;; Revert other buffers (e.g, Dired) + (setq global-auto-revert-non-file-buffers t) + (add-hook 'after-init-hook #'global-auto-revert-mode) +#+end_src +*** Recentf +=recentf= is an Emacs package that maintains a list of recently +accessed files, making it easier to reopen files you have worked on +recently. +#+begin_src emacs-lisp + (setq recentf-max-saved-items 300) ; default is 20 + (setq recentf-auto-cleanup 'mode) + (add-hook 'after-init-hook #'recentf-mode) +#+end_src +*** Save place +=save-place-mode= enables Emacs to remember the last location within a file +upon reopening. This feature is particularly beneficial for resuming work at +the precise point where you previously left off. +#+begin_src emacs-lisp + (setq save-place-file (expand-file-name "saveplace" user-emacs-directory)) + (setq save-place-limit 600) + (add-hook 'after-init-hook #'save-place-mode) +#+end_src +*** Savehist +=savehist= is an Emacs feature that preserves the minibuffer history between +sessions. It saves the history of inputs in the minibuffer, such as commands, +search strings, and other prompts, to a file. This allows users to retain +their minibuffer history across Emacs restarts. +#+begin_src emacs-lisp + (setq history-length 300) + (setq savehist-save-minibuffer-history t) ;; Default + (add-hook 'after-init-hook #'savehist-mode) +#+end_src +*** Frames and windows +#+begin_src emacs-lisp + ; Resizing the Emacs frame can be costly when changing the font. Disable this + ;; to improve startup times with fonts larger than the system default. + (setq frame-resize-pixelwise t) + + ;; However, do not resize windows pixelwise, as this can cause crashes in some + ;; cases when resizing too many windows at once or rapidly. + (setq window-resize-pixelwise nil) + + (setq resize-mini-windows 'grow-only) +#+end_src +*** Scrolling +#+begin_src emacs-lisp + ;; Enables faster scrolling through unfontified regions. This may result in + ;; brief periods of inaccurate syntax highlighting immediately after scrolling, + ;; which should quickly self-correct. + (setq fast-but-imprecise-scrolling t) + + ;; Move point to top/bottom of buffer before signaling a scrolling error. + (setq scroll-error-top-bottom t) + + ;; Keeps screen position if the scroll command moved it vertically out of the + ;; window. + (setq scroll-preserve-screen-position t) +#+end_src +*** Cursor +#+begin_src emacs-lisp + (blink-cursor-mode -1) + + ;; Don't blink the paren matching the one at point, it's too distracting. + (setq blink-matching-paren nil) +#+end_src +*** Annoyances +#+begin_src emacs-lisp + ;; No beeping or blinking + (setq visible-bell nil) + (setq ring-bell-function #'ignore) + + ;; This controls how long Emacs will blink to show the deleted pairs with + ;; `delete-pair'. A longer delay can be annoying as it causes a noticeable pause + ;; after each deletion, disrupting the flow of editing. + (setq delete-pair-blink-delay 0.03) +#+end_src +*** Indent and formatting +#+begin_src emacs-lisp + (setq-default left-fringe-width 8) + (setq-default right-fringe-width 8) + + ;; Do not show an arrow at the top/bottom the fringe and empty lines + (setq-default indicate-buffer-boundaries nil) + (setq-default indicate-empty-lines nil) + + ;; Continue wrapped lines at whitespace rather than breaking in the + ;; middle of a word. + (setq-default word-wrap t) + + ;; Prefer spaces over tabs. Spaces offer a more consistent default compared to + ;; 8-space tabs. This setting can be adjusted on a per-mode basis as needed. + (setq-default indent-tabs-mode nil + tab-width 4) + + ;; Enable multi-line commenting which ensures that `comment-indent-new-line' + ;; properly continues comments onto new lines, which is useful for writing + ;; longer comments or docstrings that span multiple lines. + (setq comment-multi-line t) + + ;; We often split terminals and editor windows or place them side-by-side, + ;; making use of the additional horizontal space. + (setq-default fill-column 80) + + ;; Disable the obsolete practice of end-of-line spacing from the + ;; typewriter era. + (setq sentence-end-double-space nil) + + ;; According to the POSIX, a line is defined as "a sequence of zero or + ;; more non-newline characters followed by a terminating newline". + (setq require-final-newline t) + + ;; Remove duplicates from the kill ring to reduce clutter + (setq kill-do-not-save-duplicates t) + + ;; Ensures that empty lines within the commented region are also commented out. + ;; This prevents unintended visual gaps and maintains a consistent appearance, + ;; ensuring that comments apply uniformly to all lines, including those that are + ;; otherwise empty. + (setq comment-empty-lines t) + + ;; Eliminate delay before highlighting search matches + (setq lazy-highlight-initial-delay 0) +#+end_src +*** Filetype +#+begin_src emacs-lisp + ;; Do not notify the user each time Python tries to guess the indentation offset + (setq python-indent-guess-indent-offset-verbose nil) + + (setq sh-indent-after-continuation 'always) + + (setq dired-clean-confirm-killing-deleted-buffers nil + dired-recursive-deletes 'top + dired-recursive-copies 'always + dired-create-destination-dirs 'ask) +#+end_src +*** Font / text scale +#+begin_src emacs-lisp + ;; Avoid automatic frame resizing when adjusting settings. + (setq global-text-scale-adjust-resizes-frames nil) +#+end_src +*** Ediff +#+begin_src emacs-lisp + ;; Configure Ediff to use a single frame and split windows horizontally + (setq ediff-window-setup-function #'ediff-setup-windows-plain + ediff-split-window-function #'split-window-horizontally) #+end_src ** No littering #+begin_src emacs-lisp @@ -304,26 +539,26 @@ #+begin_src emacs-lisp (setq default-frame-alist '((font . "Sauce Code Pro Nerd Font"))) (set-face-attribute 'default nil - :font "SauceCodePro Nerd Font" - :height 110 - :weight 'medium) + :font "SauceCodePro Nerd Font" + :height 110 + :weight 'medium) (set-face-attribute 'fixed-pitch nil - :font "SauceCodePro Nerd Font" - :height 110 - :weight 'medium) + :font "SauceCodePro Nerd Font" + :height 110 + :weight 'medium) (set-face-attribute 'variable-pitch nil - :font "Rubik" - :height 110 - :weight 'medium) + :font "Rubik" + :height 110 + :weight 'medium) (set-face-attribute 'font-lock-comment-face nil - :slant 'italic) + :slant 'italic) (set-face-attribute 'font-lock-keyword-face nil - :weight 'bold) + :weight 'bold) #+end_src ** Display line numbers #+begin_src emacs-lisp -(add-hook 'prog-mode-hook 'display-line-numbers-mode) -(visual-line-mode 1) + (add-hook 'prog-mode-hook 'display-line-numbers-mode) + (visual-line-mode 1) #+end_src ** Theme @@ -358,12 +593,12 @@ "Widen the mode-line." (interactive) (set-face-attribute 'mode-line nil - :inherit 'mode-line - :box '(:line-width 8 :style flat-button)) + :inherit 'mode-line + :box '(:line-width 8 :style flat-button)) (set-face-attribute 'mode-line-inactive nil - :inherit 'mode-line-inactive - :box '(:line-width 8 :style flat-button))) - + :inherit 'mode-line-inactive + :box '(:line-width 8 :style flat-button))) + (add-hook 'after-load-theme-hook 'widen-mode-line) (use-package mood-line @@ -394,58 +629,59 @@ ** Dashboard #+begin_src emacs-lisp - (use-package dashboard - :init - (dashboard-setup-startup-hook) - :config - (setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))) - (setq dashboard-banner-logo-title "Yep, it's emacs, not vim") - (setq dashboard-startup-banner 'official) - (setq dashboard-center-content t) - (setq dashboard-items '((projects . 5) - (recents . 5) - (bookmarks . 5) - (registers . 5)))) -#+end_src -** Disable ring-bell -#+begin_src emacs-lisp - (setq ring-bell-function 'ignore) + (use-package dashboard + :init + (dashboard-setup-startup-hook) + :config + (setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))) + (setq dashboard-banner-logo-title "Yep, it's emacs, not vim") + (setq dashboard-startup-banner 'official) + (setq dashboard-center-content t) + (setq dashboard-items '((projects . 5) + (recents . 5) + (bookmarks . 5) + (registers . 5)))) #+end_src ** Indent guide #+begin_src emacs-lisp (use-package indent-guide :hook (prog-mode . indent-guide-mode)) #+end_src -** Misc -#+begin_src emacs-lisp - (setq window-resize-pixelwise t) - (setq frame-resize-pixelwise t) - (save-place-mode t) - (defalias 'yes-or-no #'y-or-n-p) -#+end_src -* Projects -#+begin_src emacs-lisp - (use-package projectile - :init - (projectile-mode) - :config - (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)) -#+end_src * Org mode #+begin_src emacs-lisp (add-hook 'org-mode-hook 'org-indent-mode) (require 'org-tempo) (use-package org-mode :ensure nil + :custom + (org-hide-emphasis-markers t) + (org-format-latex-options '(:foreground default + :background default + :scale 1.5 + :html-foreground "Black" + :html-background "Transparent" + :html-scale 1.0 + :matchers ("begin" "$1" "$" "$$" "\\(" "\\["))) :mode "\\.org\\'") #+end_src + ** Org modern #+begin_src emacs-lisp (use-package org-modern + :after org :ghook 'org-mode-hook) #+end_src -** Enabling toc +*** Modern Indent +#+begin_src emacs-lisp + (use-package org-modern-indent + :after org-modern + :ensure (:host github :repo "jdtsmith/org-modern-indent") + :config + (add-hook 'org-mode-hook #'org-modern-indent-mode 90)) +#+end_src +* Enabling toc #+begin_src emacs-lisp (use-package toc-org + :after org :ghook 'org-mode-hook) #+end_src * Better UX @@ -461,7 +697,7 @@ "RET" 'vertico-directory-enter "DEL" 'vertico-directory-delete-char "M-DEL" 'vertico-directory-delete-word)) - + (use-package emacs :ensure nil :init ;; Add prompt indicator to `completing-read-multiple'. @@ -488,10 +724,6 @@ ;; Enable recursive minibuffers (setq enable-recursive-minibuffers t)) #+end_src -*** Ordeless -#+begin_src emacs-lisp - (use-package orderless) -#+end_src *** Marginalia #+begin_src emacs-lisp (use-package marginalia @@ -584,6 +816,7 @@ #+begin_src emacs-lisp (use-package consult-lsp :after consult lsp + :defer t :general (:keymaps 'lsp-mode-map :prefix "M-g" "f" 'consult-lsp-diagnostics @@ -594,6 +827,7 @@ #+begin_src emacs-lisp (use-package consult-dir :ensure t + :defer t :general (:prefix "C-x" :keymaps 'vertico-map "C-d" '('consult-dir :keymaps nil) @@ -635,21 +869,17 @@ ;; Consult users will also want the embark-consult package. (use-package embark-consult :ensure t ; only need to install it, embark loads it after consult if found - :hook config.el - (embark-collect-mode . consult-preview-at-point-mode)) + :hook (embark-collect-mode . consult-preview-at-point-mode)) #+end_src ** Pairs #+begin_src emacs-lisp (electric-pair-mode t) - (defun my/disable-puni-in-minibuffer () - "Disable `puni-mode' in minibuffer unless when eval-expression" - (unless (eq this-command 'eval-expression) - (puni-disable-puni-mode))) #+end_src ** Debugging #+begin_src emacs-lisp (use-package jsonrpc) (use-package dape + :defer t :after jsonrpc :config (setq dape-cwd-fn 'projectile-project-root)) @@ -687,22 +917,25 @@ ** Undo Tree #+begin_src emacs-lisp (use-package undo-tree + :defer t :config (global-undo-tree-mode)) #+end_src ** Dumb jump #+begin_src emacs-lisp (use-package dumb-jump + :defer t :config (add-hook 'xref-backend-functions #'dumb-jump-xref-activate)) #+end_src ** Command sorting and filtering #+begin_src emacs-lisp - (use-package prescient - :config - (prescient-persist-mode) - :custom-face - (prescient-primary-highlight ((t (:inherit 'orderless-match-face-0))))) + (use-package prescient + :defer t + :config + (prescient-persist-mode) + :custom-face + (prescient-primary-highlight ((t (:inherit 'font-lock-keyword-face))))) (use-package corfu-prescient :after corfu :config @@ -716,6 +949,7 @@ ** Multiple Cursors #+begin_src emacs-lisp (use-package multiple-cursors + :defer t :config (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines) (global-set-key (kbd "C->") 'mc/mark-next-like-this) @@ -724,18 +958,18 @@ #+end_src * Eshell #+begin_src emacs-lisp - (add-hook 'eshell-mode-hook - (lambda () - (setq-local corfu-auto nil) - (corfu-mode))) - (add-to-list 'display-buffer-alist - '("*eshell*" - (display-buffer-reuse-window display-buffer-at-bottom) - (window-height . 0.35))) - (add-hook 'eshell-exec-hook (lambda (p) - (buffer-disable-undo))) - (add-hook 'eshell-kill-hook (lambda (p s) - (buffer-enable-undo))) + (add-hook 'eshell-mode-hook + (lambda () + (setq-local corfu-auto nil) + (corfu-mode))) + (add-to-list 'display-buffer-alist + '("*eshell*" + (display-buffer-reuse-window display-buffer-at-bottom) + (window-height . 0.35))) + (add-hook 'eshell-exec-hook (lambda (p) + (buffer-disable-undo))) + (add-hook 'eshell-kill-hook (lambda (p s) + (buffer-enable-undo))) #+end_src ** Fish completions #+begin_src emacs-lisp @@ -752,6 +986,7 @@ ** Highlighting #+begin_src emacs-lisp (use-package eshell-syntax-highlighting + :after eshell :config (eshell-syntax-highlighting-global-mode 1)) #+end_src @@ -765,11 +1000,14 @@ :init (defun lsp-mode-setup-completion () (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults)) - '(orderless))) + '(prescient))) :hook (lsp-completion-mode . lsp-mode-setup-completion) - (prog-mode . lsp-mode)) + (nix-mode . lsp-mode) + (typescript-ts-mode . lsp-mode) + (go-ts-mode . lsp-mode) + (web-mode . lsp-mode)) #+end_src ** Flycheck #+begin_src emacs-lisp @@ -778,14 +1016,15 @@ (global-flycheck-mode) :config (add-to-list 'display-buffer-alist - '("\\*Flycheck" - (display-buffer-reuse-window display-buffer-at-bottom) - (reusable-frames . visible) - (window-height . 0.35)))) + '("\\*Flycheck" + (display-buffer-reuse-window display-buffer-at-bottom) + (reusable-frames . visible) + (window-height . 0.35)))) #+end_src ** lsp-ui #+begin_src emacs-lisp (use-package lsp-ui + :after lsp :custom (lsp-ui-doc-show-with-mouse nil)) #+end_src @@ -796,36 +1035,37 @@ (or (when (equal (following-char) ?#) (let ((bytecode (read (current-buffer)))) - (when (byte-code-function-p bytecode) - (funcall bytecode)))) + (when (byte-code-function-p bytecode) + (funcall bytecode)))) (apply old-fn args))) (advice-add (if (progn (require 'json) - (fboundp 'json-parse-buffer)) - 'json-parse-buffer - 'json-read) - :around - #'lsp-booster--advice-json-parse) + (fboundp 'json-parse-buffer)) + 'json-parse-buffer + 'json-read) + :around + #'lsp-booster--advice-json-parse) (defun lsp-booster--advice-final-command (old-fn cmd &optional test?) "Prepend emacs-lsp-booster command to lsp CMD." (let ((orig-result (funcall old-fn cmd test?))) (if (and (not test?) ;; for check lsp-server-present? - (not (file-remote-p default-directory)) ;; see lsp-resolve-final-command, it would add extra shell wrapper - lsp-use-plists - (not (functionp 'json-rpc-connection)) ;; native json-rpc - (executable-find "emacs-lsp-booster")) - (progn - (message "Using emacs-lsp-booster for %s!" orig-result) - (cons "emacs-lsp-booster" orig-result)) - orig-result))) + (not (file-remote-p default-directory)) ;; see lsp-resolve-final-command, it would add extra shell wrapper + lsp-use-plists + (not (functionp 'json-rpc-connection)) ;; native json-rpc + (executable-find "emacs-lsp-booster")) + (progn + (message "Using emacs-lsp-booster for %s!" orig-result) + (cons "emacs-lsp-booster" orig-result)) + orig-result))) (advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command) #+end_src ** Corfu #+begin_src emacs-lisp (use-package corfu + :defer t :bind (:map corfu-map - ("M-j" . corfu-next) - ("M-k" . corfu-previous)) + ("M-j" . corfu-next) + ("M-k" . corfu-previous)) :custom (corfu-preselect 'prompt) (corfu-auto t) @@ -845,6 +1085,7 @@ *** Cape #+begin_src emacs-lisp (use-package cape + :after corfu :custom (dabbrev-ignored-buffer-modes '(archive-mode image-mode eshell-mode)) :config @@ -924,8 +1165,8 @@ "\\.djhtml\\'" "\\.vue\\'") :hook (eb-mode . (lambda () (electric-pair-local-mode -1)))) - (use-package emmet-mode - :ghook 'web-mode) + ;; (use-package emmet-mode + ;; :ghook 'web-mode) #+end_src *** JavaScript #+begin_src emacs-lisp @@ -939,31 +1180,33 @@ (use-package odin-mode :ensure (:repo "https://git.sr.ht/~mgmarlow/odin-mode") :bind (:map odin-mode-map - ("C-c C-r" . 'odin-run-project) - ("C-c C-c" . 'odin-build-project) - ("C-c C-t" . 'odin-test-project)) + ("C-c C-r" . 'odin-run-project) + ("C-c C-c" . 'odin-build-project) + ("C-c C-t" . 'odin-test-project)) + :mode "\\.odin\\'" :config - (add-to-list 'lsp-language-id-configuration '(odin-mode . "odin")) + (with-eval-after-load 'lsp-mode + (add-to-list 'lsp-language-id-configuration '(odin-mode . "odin")) - (lsp-register-client (make-lsp-client - :new-connection (lsp-stdio-connection "ols") - :activation-fn (lsp-activate-on "odin") - :server-id 'ols))) + (lsp-register-client (make-lsp-client + :new-connection (lsp-stdio-connection "ols") + :activation-fn (lsp-activate-on "odin") + :server-id 'ols)))) #+end_src *** Gleam #+begin_src emacs-lisp - (use-package gleam-ts-mode - :ensure (:host github :repo "gleam-lang/gleam-mode" :branch "gleam-ts-mode") - :mode "\\.gleam\\'") - - (with-eval-after-load 'lsp-mode + (use-package gleam-ts-mode + :ensure (:host github :repo "gleam-lang/gleam-mode" :branch "gleam-ts-mode") + :mode "\\.gleam\\'" + :config + (with-eval-after-load 'lsp-mode (add-to-list 'lsp-language-id-configuration '(gleam-ts-mode . "gleam")) - (lsp-register-client (make-lsp-client - :new-connection (lsp-stdio-connection '("glas" "--stdio")) - :activation-fn (lsp-activate-on "gleam") - :server-id 'glas))) + (lsp-register-client (make-lsp-client + :new-connection (lsp-stdio-connection '("glas" "--stdio")) + :activation-fn (lsp-activate-on "gleam") + :server-id 'glas)))) #+end_src ** Direnv #+begin_src emacs-lisp @@ -973,7 +1216,8 @@ #+end_src ** Better scratch #+begin_src emacs-lisp - (use-package scratch) + (use-package scratch + :defer t) #+end_src * Dired ** Bindings @@ -1004,35 +1248,37 @@ ** Dired quick sort #+begin_src emacs-lisp (use-package dired-quick-sort + :after dired :config (dired-quick-sort-setup)) #+end_src ** Async copy #+begin_src emacs-lisp (use-package dired-rsync + :after dired :general (:prefix "C-c" :keymaps 'dired-mode-map - "C-r" 'dired-rsync - "C-x" 'dired-rsync-ent)) + "C-r" 'dired-rsync + "C-x" 'dired-rsync-ent)) #+end_src ** Media files #+begin_src emacs-lisp (use-package ready-player + :after dired :ensure (:host github :repo "xenodium/ready-player")) #+end_src * Sql - #+begin_src emacs-lisp (use-package sql-indent :hook (sql-mode . sqlind-minor-mode)) (setq sql-connection-alist - '(("postgres-sirius" - (sql-product 'postgres) - (sql-user "sirius_2024") - (sql-password "changed") - (sql-server "127.0.0.1") - (sql-database "postgres") - (sql-port 38746)))) + '(("postgres-sirius" + (sql-product 'postgres) + (sql-user "sirius_2024") + (sql-password "changed") + (sql-server "127.0.0.1") + (sql-database "postgres") + (sql-port 38746)))) (setq sql-sqlite-program "sqlite3") #+end_src diff --git a/home-manager/homeModules/emacs/early-init.el b/home-manager/homeModules/emacs/early-init.el index c767bdc..ce8d960 100644 --- a/home-manager/homeModules/emacs/early-init.el +++ b/home-manager/homeModules/emacs/early-init.el @@ -1,6 +1,197 @@ +;;;; Optimisations from https://github.com/jamescherti/minimal-emacs.d + +;;; Garbage collection +(setq gc-cons-threshold most-positive-fixnum) + +(add-hook 'emacs-startup-hook + (lambda () + (setq gc-cons-threshold (* 16 1024 1024)))) + +;;; Performance + +;; Prefer loading newer compiled files +(setq load-prefer-newer t) + +;; Increase how much is read from processes in a single chunk (default is 4kb). +(setq read-process-output-max (* 1024 1024)) ; 512kb + +;; Disable warnings from the legacy advice API. They aren't useful. +(setq ad-redefinition-action 'accept) + +(setq warning-suppress-types '((lexical-binding))) + +;; Don't ping things that look like domain names. +(setq ffap-machine-p-known 'reject) + +;; By default, Emacs "updates" its ui more often than it needs to +(setq idle-update-delay 1.0) + +;; Font compacting can be very resource-intensive, especially when rendering +;; icon fonts on Windows. This will increase memory usage. +(setq inhibit-compacting-font-caches t) + + +;; Disable warnings from the legacy advice API. They aren't useful. +(setq ad-redefinition-action 'accept) + +(setq warning-suppress-types '((lexical-binding))) + +;; Don't ping things that look like domain names. +(setq ffap-machine-p-known 'reject) + +;; By default, Emacs "updates" its ui more often than it needs to +(setq idle-update-delay 1.0) + +;; Font compacting can be very resource-intensive, especially when rendering +;; icon fonts on Windows. This will increase memory usage. +(setq inhibit-compacting-font-caches t) + + +;; Disable warnings from the legacy advice API. They aren't useful. +(setq ad-redefinition-action 'accept) + +(setq warning-suppress-types '((lexical-binding))) + +;; Don't ping things that look like domain names. +(setq ffap-machine-p-known 'reject) + +;; By default, Emacs "updates" its ui more often than it needs to +(setq idle-update-delay 1.0) + +;; Font compacting can be very resource-intensive, especially when rendering +;; icon fonts on Windows. This will increase memory usage. +(setq inhibit-compacting-font-caches t) + +(unless (daemonp) + (unless noninteractive + (progn + ;; Disable mode-line-format during init + (defun minimal-emacs--reset-inhibited-vars-h () + (setq-default inhibit-redisplay nil + ;; Inhibiting `message' only prevents redraws and + inhibit-message nil) + (redraw-frame)) + + (defvar minimal-emacs--default-mode-line-format mode-line-format + "Default value of `mode-line-format'.") + (setq-default mode-line-format nil) + + (defun minimal-emacs--startup-load-user-init-file (fn &rest args) + "Advice for startup--load-user-init-file to reset mode-line-format." + (let (init) + (unwind-protect + (progn + (apply fn args) ; Start up as normal + (setq init t)) + (unless init + ;; If we don't undo inhibit-{message, redisplay} and there's an + ;; error, we'll see nothing but a blank Emacs frame. + (minimal-emacs--reset-inhibited-vars-h)) + (unless (default-toplevel-value 'mode-line-format) + (setq-default mode-line-format + minimal-emacs--default-mode-line-format))))) + + (advice-add 'startup--load-user-init-file :around + #'minimal-emacs--startup-load-user-init-file)) + + ;; Without this, Emacs will try to resize itself to a specific column size + (setq frame-inhibit-implied-resize t) + + ;; A second, case-insensitive pass over `auto-mode-alist' is time wasted. + ;; No second pass of case-insensitive search over auto-mode-alist. + (setq auto-mode-case-fold nil) + + ;; Reduce *Message* noise at startup. An empty scratch buffer (or the + ;; dashboard) is more than enough, and faster to display. + (setq inhibit-startup-screen t + inhibit-startup-echo-area-message user-login-name) + (setq initial-buffer-choice nil + inhibit-startup-buffer-menu t + inhibit-x-resources t) + + ;; Disable bidirectional text scanning for a modest performance boost. + (setq-default bidi-display-reordering 'left-to-right + bidi-paragraph-direction 'left-to-right) + + ;; Give up some bidirectional functionality for slightly faster re-display. + (setq bidi-inhibit-bpa t) + + ;; Remove "For information about GNU Emacs..." message at startup + (advice-add #'display-startup-echo-area-message :override #'ignore) + + ;; Suppress the vanilla startup screen completely. We've disabled it with + ;; `inhibit-startup-screen', but it would still initialize anyway. + (advice-add #'display-startup-screen :override #'ignore) + + ;; Shave seconds off startup time by starting the scratch buffer in + ;; `fundamental-mode' + (setq initial-major-mode 'fundamental-mode + initial-scratch-message nil))) + +;;; Native compilation and Byte compilation + +(if (and (featurep 'native-compile) + (fboundp 'native-comp-available-p) + (native-comp-available-p)) + ;; Activate `native-compile' + (setq native-comp-jit-compilation t + package-native-compile t) + ;; Deactivate the `native-compile' feature if it is not available + (setq features (delq 'native-compile features))) + +;; Suppress compiler warnings and don't inundate users with their popups. +(setq native-comp-async-report-warnings-errors 'silent) + +;;; UI elements + +;; Disable startup screens and messages +(setq inhibit-splash-screen t) + + +(push '(menu-bar-lines . 0) default-frame-alist) +(unless (memq window-system '(mac ns)) + (setq menu-bar-mode nil)) + +(unless (daemonp) + (unless noninteractive + (when (fboundp 'tool-bar-setup) + ;; Temporarily override the tool-bar-setup function to prevent it from + ;; running during the initial stages of startup + (advice-add #'tool-bar-setup :override #'ignore) + (define-advice startup--load-user-init-file + (:before (&rest _) minimal-emacs-setup-toolbar) + (advice-remove #'tool-bar-setup #'ignore) + (tool-bar-setup))))) + +(push '(tool-bar-lines . 0) default-frame-alist) +(setq tool-bar-mode nil) + +(push '(vertical-scroll-bars) default-frame-alist) +(push '(horizontal-scroll-bars) default-frame-alist) +(setq scroll-bar-mode nil) +(when (fboundp 'horizontal-scroll-bar-mode) + (horizontal-scroll-bar-mode -1)) + +(when (bound-and-true-p tooltip-mode) + (tooltip-mode -1)) + +;; Disable GUIs because they are inconsistent across systems, desktop +;; environments, and themes, and they don't match the look of Emacs. +(setq use-file-dialog nil) +(setq use-dialog-box nil) + +;; Allow for shorter responses: "y" for yes and "n" for no. +(if (boundp 'use-short-answers) + (setq use-short-answers t) + (advice-add #'yes-or-no-p :override #'y-or-n-p)) +(defalias #'view-hello-file #'ignore) ; Never show the hello file + +;;; And that's mine + (setq package-enable-at-startup nil) (setenv "LSP_USE_PLISTS" "true") -(menu-bar-mode -1) -(tool-bar-mode -1) -(scroll-bar-mode -1) (setq-default pgtk-wait-for-event-timeout 0) +(setq vc-follow-symlinks t) + +(provide 'early-init) +;;; early-init.el ends here |
