diff --git a/.gitignore b/.gitignore index 633c4ac..1488546 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,5 @@ -config/emacs/backups/ -config/emacs/eln-cache/ -config/emacs/elpa/ -config/emacs/auto-save/ -config/emacs/auto-save-list/ -config/emacs/custom.el -config/emacs/places.eld -config/emacs/projects.eld -config/emacs/recentf.eld config/emacs/.ignore -config/emacs/session* -config/emacs/history +config/emacs/var/ config/fish/conf.d config/fish/functions config/fish/fish_variables diff --git a/config/emacs/early-init.el b/config/emacs/early-init.el index 79c96a3..f754e73 100644 --- a/config/emacs/early-init.el +++ b/config/emacs/early-init.el @@ -21,6 +21,9 @@ ;;; Code: +(startup-redirect-eln-cache (expand-file-name "var/eln-cache/" user-emacs-directory)) +(setq package-user-dir (expand-file-name "var/elpa/" user-emacs-directory)) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Garbage Collection ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/config/emacs/init.el b/config/emacs/init.el index 5f4b0b0..5821ccd 100644 --- a/config/emacs/init.el +++ b/config/emacs/init.el @@ -5,16 +5,31 @@ ;; to the window on the left. ;;; Code: -;;;; 1. Basics +;;;; 1. Emac setup, files, packages and paths (let ((bin (expand-file-name "~/.local/bin"))) (add-to-list 'exec-path bin) (setenv "PATH" (concat bin path-separator (getenv "PATH")))) -;; Custom's output goes to its own file, not here. -(setq custom-file (expand-file-name "custom.el" user-emacs-directory)) +;; all the emacs runtime files live in var/. +;; early-init.el redirects eln-cache and elpa. +(defvar my/var (locate-user-emacs-file "var/")) +(make-directory (concat my/var "transient/") t) +(setq savehist-file (concat my/var "history") + save-place-file (concat my/var "places.eld") + recentf-save-file (concat my/var "recentf.eld") + project-list-file (concat my/var "projects.eld") + transient-history-file (concat my/var "transient/history.el") + transient-levels-file (concat my/var "transient/levels.el") + transient-values-file (concat my/var "transient/values.el")) + +;; Custom output goes to its own file, not here. +(setq custom-file (expand-file-name "var/custom.el" user-emacs-directory)) (load custom-file 'noerror 'nomessage) -;; Package archives: GNU and NonGNU are built in, MELPA is added at lowest priority. +;; No session manager save: stops the empty session.* files. +(add-hook 'emacs-save-session-functions #'always) + +;; Package GNU, NonGNU are built in melpa additional lowest priority. (require 'package) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (setq package-archive-priorities '(("gnu" . 3) ("nongnu" . 2) ("melpa" . 1))) @@ -23,7 +38,8 @@ (require 'use-package) (setq use-package-always-ensure t) -;;;; 2. UI +;;;; 2. Ui settings, theme setup and fonts +(add-to-list 'default-frame-alist '(fullscreen . maximized)) (menu-bar-mode -1) (tool-bar-mode -1) (scroll-bar-mode -1) @@ -46,43 +62,29 @@ (electric-pair-mode 1) (which-key-mode 1) -;; Jellybeans theme. (add-to-list 'warning-suppress-types '(files)) (use-package jbeans-theme :config (load-theme 'jbeans t)) -;; Font, on a darker background than the theme's. -(set-face-attribute 'default nil - :family "JetBrainsMono Nerd Font" - :height 120 - :background "#131313") +(set-face-attribute 'default nil :family "JetBrainsMono Nerd Font" :height 120) +(setq-default line-spacing '(4 . 4)) -;; Mode line at the top of each window: the header line takes over its -;; format and look, on the editor background. +;; set mode line at the top of each window (setq-default header-line-format mode-line-format mode-line-format nil) (set-face-attribute 'header-line nil :inherit 'mode-line :background "#131313") -(setq-default line-spacing '(4 . 4)) - ;; Command launcher. (keymap-global-set "C-S-p" #'execute-extended-command) -;; Escape cancels prompts. keyboard-quit can't leave the minibuffer, so there -;; Escape runs abort-minibuffers, as C-g does. +;; Escape behaves like C-g (keymap-global-set "" #'keyboard-quit) (keymap-set minibuffer-local-map "" #'abort-minibuffers) -(add-to-list 'default-frame-alist '(fullscreen . maximized)) - ;;;; 3. Files -(dolist (d '("backups/" "auto-save/")) - (make-directory (locate-user-emacs-file d) t)) - -(setq backup-directory-alist - `(("." . ,(locate-user-emacs-file "backups/"))) - auto-save-file-name-transforms - `((".*" ,(locate-user-emacs-file "auto-save/") t)) +(setq make-backup-files nil + auto-save-default nil + auto-save-list-file-prefix nil create-lockfiles nil confirm-kill-processes nil vc-follow-symlinks t) @@ -93,8 +95,7 @@ (global-auto-revert-mode 1) ;;;; 4. Completion -;; C-n/C-p move through candidates: Vertico remaps next-line/previous-line, -;; and section 5 stops Evil from taking those keys in the minibuffer. +;; C-n/C-p navigates up and down, section 5 stops evil from overrriding (use-package vertico :init (vertico-mode 1) @@ -117,7 +118,6 @@ (vertico-posframe-mode 1)) ;;;; 5. Evil -;; Evil 1.15.0 on Emacs 31 reads this legacy variable, which Emacs no longer defines. (defvar evil-mode-buffers nil) (defun my/insert-tab () @@ -127,8 +127,6 @@ (use-package evil :init - ;; evil-want-keybinding: Evil Collection (below) supplies mode bindings instead - ;; of Evil's small built-in set. It has to be set before Evil loads. (setq evil-want-C-u-scroll t evil-undo-system 'undo-redo evil-want-keybinding nil) @@ -137,21 +135,16 @@ (evil-mode 1) (evil-define-key 'insert 'global - ;; Literal tab. as well, or a mode's own binding wins in GUI frames. (kbd "TAB") #'my/insert-tab (kbd "") #'my/insert-tab - - ;; C-SPC: complete using the buffer's completion sources. + ;; complete using the buffer's completion sources. (kbd "C-SPC") #'completion-at-point (kbd "C-@") #'completion-at-point) - ;; Global navigation. ;; C-p, C-f and C-b are assigned to Consult below. (evil-define-key '(normal motion) 'global (kbd "C-e") #'dired-jump)) -;; Evil Collection: vim-style bindings for other packages, one mode at a time. -;; Info here (F1 i); Magit, Magit sections and commit messages in git.el. (use-package evil-collection :after evil :custom @@ -172,13 +165,12 @@ (kbd "") #'abort-minibuffers) ;; Window navigation (normal/motion state): Ctrl+hjkl move, Ctrl+` closes. -;; GUI only for C-`: terminals send it as C-@. (evil-define-key '(normal motion) 'global (kbd "C-h") #'windmove-left (kbd "C-j") #'windmove-down (kbd "C-k") #'windmove-up (kbd "C-l") #'windmove-right - (kbd "C-`") #'delete-window) + (kbd "C-q") #'delete-window) ;; Result buffers: hjkl motions and RET to jump to a result. (dolist (m '(occur-mode grep-mode xref--xref-buffer-mode)) @@ -269,12 +261,10 @@ (when-let* ((win (get-buffer-window (process-buffer proc)))) (select-window win)))) -;;;; 9. Languages +;;;; 9. Modules - additional functionality outside of the core init.el +;; Magit and the :git command live in modules/git.el. +(load (locate-user-emacs-file "modules/git.el") nil 'nomessage) ;; Setup for dev languages, modes, lsp and lsp keybinds. -(load (locate-user-emacs-file "development.el") nil 'nomessage) - -;;;; 10. Git -;; Magit and the :git command live in git.el, next to this file. -(load (locate-user-emacs-file "git.el") nil 'nomessage) +(load (locate-user-emacs-file "modules/development.el") nil 'nomessage) ;;; init.el ends here diff --git a/config/emacs/development.el b/config/emacs/modules/development.el similarity index 100% rename from config/emacs/development.el rename to config/emacs/modules/development.el diff --git a/config/emacs/git.el b/config/emacs/modules/git.el similarity index 100% rename from config/emacs/git.el rename to config/emacs/modules/git.el