;; The default is 800 kilobytes. Measured in bytes.
(setq gc-cons-threshold (* 50 1000 1000))
(defun efs/display-startup-time ()
(message "Emacs loaded in %s with %d garbage collections."
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time)))
gcs-done))
(add-hook 'emacs-startup-hook #'efs/display-startup-time)
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name
"straight/repos/straight.el/bootstrap.el"
(or (bound-and-true-p straight-base-dir)
user-emacs-directory)))
(bootstrap-version 7))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(eval-when-compile (require 'use-package))
(use-package auto-package-update
:straight t
:custom
(auto-package-update-interval 7)
(auto-package-update-prompt-before-update t)
(auto-package-update-hide-results t)
:config
(auto-package-update-maybe)
(auto-package-update-at-time "09:00"))
;; NOTE: If you want to move everything out of the ~/.emacs.d folder
;; reliably, set `user-emacs-directory` before loading no-littering!
;(setq user-emacs-directory "~/.cache/emacs")
(straight-use-package 'no-littering)
;; no-littering doesn't set this by default so we must place
;; auto save files in the same path as it uses for sessions
(setq auto-save-file-name-transforms
`((".*" ,(no-littering-expand-var-file-name "auto-save/") t)))
(setq native-comp-async-report-warnings-errors nil)
(use-package all-the-icons
:straight t
:if (display-graphic-p))
(use-package all-the-icons-dired
:straight t
:hook (dired-mode . (lambda () (all-the-icons-dired-mode t))))
(setq inhibit-startup-message t)
(scroll-bar-mode -1) ; Disable visible scrollbar
(tool-bar-mode -1) ; Disable the toolbar
(tooltip-mode -1) ; Disable tooltips
(set-fringe-mode 10) ; Give some breathing room
(menu-bar-mode -1) ; Disable the menu bar
;; Set up the visible bell
(setq visible-bell t)
(column-number-mode)
(global-display-line-numbers-mode t)
;; Set frame transparency
(defvar efs/frame-transparency '(96 . 96))
(set-frame-parameter (selected-frame) 'alpha efs/frame-transparency)
(add-to-list 'default-frame-alist `(alpha . ,efs/frame-transparency))
(set-frame-parameter (selected-frame) 'fullscreen 'maximized)
(add-to-list 'default-frame-alist '(fullscreen . maximized))
(add-hook 'org-mode-hook (lambda ()
(setq-local electric-pair-inhibit-predicate
`(lambda (c)
(if (char-equal c ?<) t (,electric-pair-inhibit-predicate c))))))
(delete-selection-mode 1)
(electric-pair-mode 1)
;; Disable line numbers for some modes
(dolist (mode '(org-mode-hook
term-mode-hook
shell-mode-hook
treemacs-mode-hook
eshell-mode-hook))
(add-hook mode (lambda () (display-line-numbers-mode 0))))
(use-package cape
:straight t
:init
(setq cape-dabbrev-min-length 2)
(setq cape-dabbrev-check-other-buffers 'some)
(add-to-list 'completion-at-point-functions #'cape-dabbrev)
(add-to-list 'completion-at-point-functions #'cape-file)
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent)
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify)
(defun corfu-enable-always-in-minibuffer ()
"Enable Corfu in the minibuffer if Vertico/Mct are not active."
(unless (or (bound-and-true-p mct--active)
(bound-and-true-p vertico--input)
(eq (current-local-map) read-passwd-map))
;; (setq-local corfu-auto nil) ;; Enable/disable auto completion
(setq-local corfu-echo-delay nil ;; Disable automatic echo and popup
corfu-popupinfo-delay nil)
(corfu-mode 1)))
(add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1))
Consult provides search and navigation commands based on the Emacs completion function completing-read. Completion allows you to quickly select an item from a list of candidates. Consult offers asynchronous and interactive consult-grep and consult-ripgrep commands, and the line-based search command consult-line
(use-package consult
:straight t
:init
(setq completion-in-region-function #'consult-completion-in-region)
(keymap-global-set "C-s" 'consult-line)
(keymap-set minibuffer-local-map "C-r" 'consult-history))
(use-package corfu
:straight t
:custom
(corfu-cycle t)
(corfu-auto t)
(corfu-auto-prefix 2)
(corfu-on-exact-match 'insert)
(corfu-preselect 'prompt)
(corfu-quit-no-match t)
;; Use TAB for cycling, default is `corfu-complete'.
:bind
(:map corfu-map
("TAB" . corfu-next)
([tab] . corfu-next)
("S-TAB" . corfu-previous)
([backtab] . corfu-previous))
:init
(global-corfu-mode))
(use-package dabbrev
:custom
(dabbrev-upcase-means-case-search t)
(dabbrev-check-all-buffers nil)
(dabbrev-check-other-buffers t)
(dabbrev-friend-buffer-function 'dabbrev--same-major-mode-p)
(dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'")))
(use-package dired-open
:straight t
:config
(setq dired-open-extensions '(("gif" . "sxiv")
("jpg" . "sxiv")
("png" . "sxiv")
("mkv" . "mpv")
("mp4" . "mpv"))))
(use-package peep-dired
:straight t
:after dired
:hook (evil-normalize-keymaps . peep-dired-hook)
:config
(evil-define-key 'normal dired-mode-map (kbd "h") 'dired-up-directory)
(evil-define-key 'normal dired-mode-map (kbd "l") 'dired-open-file) ; use dired-find-file instead if not using dired-open package
(evil-define-key 'normal peep-dired-mode-map (kbd "j") 'peep-dired-next-file)
(evil-define-key 'normal peep-dired-mode-map (kbd "k") 'peep-dired-prev-file))
(use-package dired-sidebar
:straight t
:commands (dired-sidebar-toggle-sidebar)
:init
(add-hook 'dired-sidebar-mode-hook
(lambda ()
(unless (file-remote-p default-directory)
(auto-revert-mode))))
:config
(push 'toggle-window-split dired-sidebar-toggle-hidden-commands)
(push 'rotate-windows dired-sidebar-toggle-hidden-commands)
(setq dired-sidebar-subtree-line-prefix " ")
(setq dired-sidebar-theme 'all-the-icons)
(setq dired-sidebar-use-term-integration t)
(setq dired-sidebar-use-custom-font t))
Drag Stuff is a minor mode for Emacs that makes it possible to drag stuff (words, region, lines) around in Emacs. When ‘drag-stuff-define-keys’ is enabled, then the following keybindings are set: M-up, M-down, M-left, and M-right.
(use-package drag-stuff
:straight t
:init
(drag-stuff-global-mode 1)
(drag-stuff-define-keys))
(use-package eglot
:straight t)
(use-package eglot-booster
:straight (:type git :host github :repo "jdtsmith/eglot-booster")
:after eglot
:config
(eglot-booster-mode))
(with-eval-after-load 'eglot
(setq completion-category-defaults nil))
Embark makes it easy to choose a command to run based on what is near point, both during a minibuffer completion session (in a way familiar to Helm or Counsel users) and in normal buffers. Bind the command embark-act to a key and it acts like prefix-key for a keymap of actions (commands) relevant to the target around point.
(use-package embark
:straight t
:init
;; Optionally replace the key help with a completing-read interface
(setq prefix-help-command #'embark-prefix-help-command)
;; Show the Embark target at point via Eldoc. You may adjust the
;; Eldoc strategy, if you want to see the documentation from
;; multiple providers. Beware that using this can be a little
;; jarring since the message shown in the minibuffer can be more
;; than one line, causing the modeline to move up and down:
;; (add-hook 'eldoc-documentation-functions #'embark-eldoc-first-target)
;; (setq eldoc-documentation-strategy #'eldoc-documentation-compose-eagerly)
:config
;; Hide the mode line of the Embark live/completions buffers
(add-to-list 'display-buffer-alist
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
nil
(window-parameters (mode-line-format . none)))))
;; Consult users will also want the embark-consult package.
(use-package embark-consult
:straight t ; only need to install it, embark loads it after consult if found
:hook
(embark-collect-mode . consult-preview-at-point-mode))
(use-package evil
:straight t
:init ;; tweak evil's configuration before loading it
(setq evil-want-integration t ;; This is optional since it's already set to t by default.
evil-want-keybinding nil
evil-vsplit-window-right t
evil-split-window-below t
evil-undo-system 'undo-redo) ;; Adds vim-like C-r redo functionality
(evil-mode))
(use-package evil-collection
:after evil
:straight t
:config
;; Do not uncomment this unless you want to specify each and every mode
;; that evil-collection should works with. The following line is here
;; for documentation purposes in case you need it.
;; (setq evil-collection-mode-list '(calendar dashboard dired ediff info magit ibuffer))
(add-to-list 'evil-collection-mode-list 'help) ;; evilify help mode
(evil-collection-init))
(straight-use-package 'evil-tutor)
;; Using RETURN to follow links in Org/Evil
;; Unmap keys in 'evil-maps if not done, (setq org-return-follows-link t) will not work
(with-eval-after-load 'evil-maps
(define-key evil-motion-state-map (kbd "SPC") nil)
(define-key evil-motion-state-map (kbd "RET") nil)
(define-key evil-motion-state-map (kbd "TAB") nil))
;; Setting RETURN key in org-mode to follow links
(setq org-return-follows-link t)
(use-package eshell-toggle
:straight t
:custom
(eshell-toggle-size-fraction 3)
(eshell-toggle-use-projectile-root t)
(eshell-toggle-run-command nil)
(eshell-toggle-init-function #'eshell-toggle-init-ansi-term))
(use-package eshell-syntax-highlighting
:straight t
:after esh-mode
:config
(eshell-syntax-highlighting-global-mode +1))
;; eshell-syntax-highlighting -- adds fish/zsh-like syntax highlighting.
;; eshell-rc-script -- your profile for eshell; like a bashrc for eshell.
;; eshell-aliases-file -- sets an aliases file for the eshell.
(setq eshell-rc-script (concat user-emacs-directory "eshell/profile")
eshell-aliases-file (concat user-emacs-directory "eshell/aliases")
eshell-history-size 5000
eshell-buffer-maximum-lines 5000
eshell-hist-ignoredups t
eshell-scroll-to-bottom-on-input t
eshell-destroy-buffer-when-process-dies t
eshell-visual-commands'("bash" "fish" "htop" "ssh" "top" "zsh"))
(defun efs/set-font-faces ()
(message "Setting faces!")
(set-face-attribute 'default nil :font "JetBrains Mono" :height 135)
;; Set the fixed pitch face
(set-face-attribute 'fixed-pitch nil :font "JetBrains Mono" :height 135)
;; Set the variable pitch face
(set-face-attribute 'variable-pitch nil :font "Ubuntu" :height 135 :weight 'regular))
(if (daemonp)
(add-hook 'after-make-frame-functions
(lambda (frame)
(setq doom-modeline-icon t)
(with-selected-frame frame
(efs/set-font-faces))))
(efs/set-font-faces))
Install luacheck
from your Linux distro’s repositories for flycheck to work correctly with lua files. Install python-pylint
for flycheck to work with python files. Haskell works with flycheck as long as haskell-ghc
or haskell-stack-ghc
is installed. For more information on language support for flycheck, read this.
(use-package flycheck
:straight t
:defer t
:diminish
:init (global-flycheck-mode))
git-timemachine is a program that allows you to move backwards and forwards through a file’s commits. ‘SPC g t’ will open the time machine on a file if it is in a git repo. Then, while in normal mode, you can use ‘CTRL-j’ and ‘CTRL-k’ to move backwards and forwards through the commits.
(use-package git-timemachine
:straight t
:hook (evil-normalize-keymaps . git-timemachine-hook)
:config
(evil-define-key 'normal git-timemachine-mode-map (kbd "C-<down>") 'git-timemachine-show-previous-revision)
(evil-define-key 'normal git-timemachine-mode-map (kbd "C-<up>") 'git-timemachine-show-next-revision))
(straight-use-package 'helpful)
;; Note that the built-in `describe-function' includes both functions
;; and macros. `helpful-function' is functions only, so we provide
;; `helpful-callable' as a drop-in replacement.
;; TODO replace C-h with SPACE
(global-set-key (kbd "C-h f") #'helpful-callable)
(global-set-key (kbd "C-h v") #'helpful-variable)
(global-set-key (kbd "C-h k") #'helpful-key)
(global-set-key (kbd "C-h x") #'helpful-command)
;; Lookup the current symbol at point. C-c C-d is a common keybinding
;; for this in lisp modes.
(global-set-key (kbd "C-c C-d") #'helpful-at-point)
;; Look up *F*unctions (excludes macros).
;;
;; By default, C-h F is bound to `Info-goto-emacs-command-node'. Helpful
;; already links to the manual, if a function is referenced there.
(global-set-key (kbd "C-h F") #'helpful-function)
(use-package hl-todo
:straight t
:hook ((org-mode . hl-todo-mode)
(prog-mode . hl-todo-mode))
:config
(setq hl-todo-highlight-punctuation ":"
hl-todo-keyword-faces
'(("TODO" . "#FF0000")
("FIXME" . "#FF0000")
("DEBUG" . "#A020F0")
("GOTCHA" . "#FF4500")
("STUB" . "#1E90FF")))
;; (keymap-set hl-todo-mode-map "C-c p" #'hl-todo-previous)
;; (keymap-set hl-todo-mode-map "C-c n" #'hl-todo-next)
;; (keymap-set hl-todo-mode-map "C-c o" #'hl-todo-occur)
;; (keymap-set hl-todo-mode-map "C-c i" #'hl-todo-insert)
(use-package aggressive-indent
:straight t
:init
(global-aggressive-indent-mode 1))
(global-display-line-numbers-mode -1)
(setq-default display-line-numbers-grow-only t
display-line-numbers-width 2)
;; Enable line numbers for some modes
(dolist (mode '(prog-mode-hook
conf-mode-hook))
(add-hook mode (lambda () (display-line-numbers-mode t))))
Magit is a full-featured git client for Emacs.
(straight-use-package 'magit)
(use-package marginalia
:after vertico
:straight t
:custom
(marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil))
:init
(marginalia-mode 1))
(use-package doom-modeline
:straight t
:init (doom-modeline-mode 1))
(straight-use-package 'nerd-icons)
(use-package nerd-icons-completion
:straight t
:after marginalia
:config
(nerd-icons-completion-mode)
(add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup))
(use-package orderless
:straight t
:custom
(completion-styles '(orderless basic))
(completion-category-defaults nil)
(completion-category-overrides
'((file (styles basic partial-completion)))))
(use-package org
:straight (:type built-in)
:config
(setq org-agenda-files '("~/org")
org-ellipsis " ▾"
org-src-preserve-indentation t
org-src-fontify-natively t
org-src-tab-acts-natively t))
;; Automatically tangle our Emacs.org config file when we save it
(defun efs/org-babel-tangle-config ()
(when (string-equal (file-name-directory (buffer-file-name))
(expand-file-name user-emacs-directory))
;; Dynamic scoping to the rescue
(let ((org-confirm-babel-evaluate nil))
(org-babel-tangle))))
(add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'efs/org-babel-tangle-config)))
(setq org-confirm-babel-evaluate nil
org-confirm-elisp-link-function nil
org-link-shell-confirm-function nil)
(with-eval-after-load 'org
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(python . t)
(shell . t)
(org . t)
(latex . t)
(sqlite . t)))
(push '("conf-unix" . conf-unix) org-src-lang-modes))
(use-package org-modern
:straight t
:after org
:init
(global-org-modern-mode))
(use-package org-tempo
:after org
(add-to-list 'org-structure-template-alist '("sh" . "src shell"))
(add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
(add-to-list 'org-structure-template-alist '("py" . "src jupyter-python")))
(use-package ranger
:straight t
:after dired
:init
(ranger-override-dired-mode t)
:config
(setq ranger-cleanup-eagerly t
ranger-show-hidden t
ranger-modify-header t
ranger-footer-delay 0.2
ranger-preview-delay 0.040
ranger-parent-depth 2
ranger-width-parents 0.12
ranger-max-parent-width 0.12
ranger-preview-file t
ranger-max-preview-size 300))
(straight-use-package 'catppuccin-theme)
(load-theme 'catppuccin :no-confirm)
(catppuccin-set-color 'base "#1E1E2E") ;; change base to #000000 for the currently active flavor
(catppuccin-set-color 'crust "#11111B" 'mocha) ;; change crust to #222222 for frappe
(catppuccin-reload)
(use-package nix-mode
:straight t
:mode "\\.nix\\'")
(use-package vertico
:straight t
:bind (:map vertico-map
("C-j" . vertico-next)
("C-k" . vertico-previous)
("C-f" . vertico-exit)
:map minibuffer-local-map
("M-h" . backward-kill-word))
:custom
(vertico-cycle t)
:init
(vertico-mode)
(setq vertico-cycle t))
;; just for looks
(use-package vertico-posframe
:straight t
:custom
(vertico-posframe-parameters
'((left-fringe . 8)
(right-fringe . 8))))
(use-package vterm
:straight t
:config
(setq shell-file-name "/usr/bin/zsh"
vterm-max-scrollback 5000))
(use-package vterm-toggle
:straight t
:after vterm
:config
;; When running programs in Vterm and in 'normal' mode, make sure that ESC
;; kills the program as it would in most standard terminal programs.
(evil-define-key 'normal vterm-mode-map (kbd "<escape>") 'vterm--self-insert)
(setq vterm-toggle-fullscreen-p nil)
(setq vterm-toggle-scope 'project)
(add-to-list 'display-buffer-alist
'((lambda (buffer-or-name _)
(let ((buffer (get-buffer buffer-or-name)))
(with-current-buffer buffer
(or (equal major-mode 'vterm-mode)
(string-prefix-p vterm-buffer-name (buffer-name buffer))))))
(display-buffer-reuse-window display-buffer-at-bottom)
;;(display-buffer-reuse-window display-buffer-in-direction)
;;display-buffer-in-direction/direction/dedicated is added in emacs27
;;(direction . bottom)
;;(dedicated . t) ;dedicated is supported in emacs27
(reusable-frames . visible)
(window-height . 0.4))))
(use-package which-key
:straight t
:init
(which-key-mode 1)
:diminish
:config
(setq which-key-side-window-location 'bottom
which-key-sort-order #'which-key-key-order-alpha
which-key-allow-imprecise-window-fit nil
which-key-sort-uppercase-first nil
which-key-add-column-padding 1
which-key-max-display-columns nil
which-key-min-display-lines 6
which-key-side-window-slot -10
which-key-side-window-max-height 0.25
which-key-idle-delay 0.8
which-key-max-description-length 25
which-key-allow-imprecise-window-fit nil
which-key-separator " → " ))
(global-set-key (kbd "C-=") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
(global-set-key (kbd "<C-wheel-up>") 'text-scale-increase)
(global-set-key (kbd "<C-wheel-down>") 'text-scale-decrease)
;; Make gc pauses faster by decreasing the threshold.
(setq gc-cons-threshold (* 2 1000 1000))