2024-10-03 20:26:12 -04:00
|
|
|
#+TITLE: Emacs Configuration
|
|
|
|
#+AUTHOR: Mars (@pupbrained)
|
|
|
|
#+EMAIL: mars@pupbrained.xyz
|
|
|
|
|
|
|
|
* Basic Setup
|
|
|
|
|
|
|
|
** Server
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(require 'bind-key)
|
|
|
|
(load "server")
|
|
|
|
(unless (server-running-p) (server-start))
|
|
|
|
#+end_src
|
|
|
|
|
2024-10-05 00:40:51 -04:00
|
|
|
** Auto-Save
|
2024-10-03 20:26:12 -04:00
|
|
|
|
2024-10-05 00:40:51 -04:00
|
|
|
*** Disable Built-In Auto-Save and Backup
|
2024-10-03 20:26:12 -04:00
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
2024-10-04 21:53:37 -04:00
|
|
|
(setq auto-save-default nil
|
|
|
|
make-backup-files nil)
|
2024-10-03 20:26:12 -04:00
|
|
|
#+end_src
|
|
|
|
|
2024-10-05 00:40:51 -04:00
|
|
|
*** Enable Real Auto-Save
|
2024-10-03 20:26:12 -04:00
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(use-package real-auto-save
|
|
|
|
:ensure t
|
2024-10-04 21:53:37 -04:00
|
|
|
:hook
|
|
|
|
(prog-mode . real-auto-save-mode)
|
2024-10-03 20:26:12 -04:00
|
|
|
:config
|
2024-10-04 21:53:37 -04:00
|
|
|
(setq real-auto-save-interval 1))
|
2024-10-03 20:26:12 -04:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** No Scratch On Open
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(setq initial-scratch-message nil)
|
|
|
|
(setq initial-buffer-choice nil)
|
2024-10-04 19:01:46 -04:00
|
|
|
|
2024-10-03 20:26:12 -04:00
|
|
|
(add-hook 'emacs-startup-hook
|
|
|
|
(lambda ()
|
|
|
|
(when (and (get-buffer "*scratch*")
|
|
|
|
(not (eq (current-buffer) (get-buffer "*scratch*"))))
|
|
|
|
(kill-buffer "*scratch*"))))
|
|
|
|
#+end_src
|
|
|
|
|
2024-10-04 19:01:46 -04:00
|
|
|
** Dirvish
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
2024-10-04 21:40:04 -04:00
|
|
|
(add-hook 'dired-mode-hook 'dired-omit-mode)
|
|
|
|
|
|
|
|
(defun my/dirvish-create-file ()
|
|
|
|
"Create a new file in the current directory."
|
|
|
|
(interactive)
|
|
|
|
(let ((new-file (read-file-name "New file name: " (dired-current-directory))))
|
|
|
|
(if (file-exists-p new-file)
|
|
|
|
(message "File already exists!")
|
|
|
|
(write-region "" nil new-file)
|
|
|
|
(revert-buffer) ;; Refresh the directory listing
|
|
|
|
(message "File created: %s" new-file))))
|
|
|
|
|
2024-10-04 19:01:46 -04:00
|
|
|
(use-package dirvish
|
|
|
|
:ensure t
|
2024-10-04 21:40:04 -04:00
|
|
|
:init
|
2024-10-04 19:01:46 -04:00
|
|
|
(dirvish-override-dired-mode)
|
2024-10-04 21:40:04 -04:00
|
|
|
:config
|
|
|
|
(dirvish-peek-mode)
|
2024-10-04 19:01:46 -04:00
|
|
|
(dirvish-side-follow-mode)
|
2024-10-04 22:24:03 -04:00
|
|
|
(setq dired-listing-switches "-al --human-readable --group-directories-first"
|
2024-10-04 21:53:37 -04:00
|
|
|
dired-mouse-drag-files t
|
2024-10-04 22:24:03 -04:00
|
|
|
dired-omit-files (rx (or (seq bol (? ".") "#")
|
|
|
|
(seq bol "." eol)
|
|
|
|
(seq bol ".git" eol)))
|
|
|
|
dirvish-emerge-groups '(("Recent files" (predicate . recent-files-2h))
|
|
|
|
("Documents" (extensions "pdf" "tex" "bib" "epub"))
|
|
|
|
("Video" (extensions "mp4" "mkv" "webm"))
|
|
|
|
("Pictures" (extensions "jpg" "png" "svg" "gif"))
|
|
|
|
("Audio" (extensions "mp3" "flac" "wav" "ape" "aac"))
|
|
|
|
("Archives" (extensions "gz" "rar" "zip")))
|
2024-10-04 21:53:37 -04:00
|
|
|
dirvish-attributes '(vc-state subtree-state nerd-icons collapse git-msg file-time file-size)
|
|
|
|
dirvish-mode-line-format '(:left (sort symlink) :right (omit yank index))
|
2024-10-04 22:24:03 -04:00
|
|
|
dirvish-mode-line-height 25
|
2024-10-04 21:53:37 -04:00
|
|
|
dirvish-subtree-state-style 'nerd
|
|
|
|
mouse-drag-and-drop-region-cross-program t))
|
2024-10-04 19:01:46 -04:00
|
|
|
|
|
|
|
;; Addtional syntax highlighting for dired
|
|
|
|
(use-package diredfl
|
|
|
|
:ensure t
|
|
|
|
:hook
|
|
|
|
((dired-mode . diredfl-mode)
|
|
|
|
(dirvish-directory-view-mode . diredfl-mode))
|
|
|
|
:config
|
|
|
|
(set-face-attribute 'diredfl-dir-name nil :bold t))
|
|
|
|
|
2024-10-04 21:40:04 -04:00
|
|
|
(use-package nerd-icons
|
|
|
|
:ensure t
|
|
|
|
:custom
|
|
|
|
(nerd-icons-font-family "Maple Mono NF"))
|
2024-10-04 19:01:46 -04:00
|
|
|
|
|
|
|
(use-package ns-auto-titlebar
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(when (eq system-type 'darwin) (ns-auto-titlebar-mode)))
|
|
|
|
#+end_src
|
|
|
|
|
2024-10-04 22:24:03 -04:00
|
|
|
** Doom Modeline
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(use-package doom-modeline
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(doom-modeline-mode))
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** Nix
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(use-package nix-mode
|
|
|
|
:mode "\\.nix\\'")
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** Org Mode Templates
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
;; Inhibits autopairs from running for <> in org mode
|
|
|
|
(add-hook 'org-mode-hook
|
|
|
|
(lambda ()
|
|
|
|
(setq-local electric-pair-inhibit-predicate
|
|
|
|
`(lambda (c) (if (char-equal c ?<) t (,electric-pair-inhibit-predicate c))))))
|
|
|
|
|
|
|
|
(require 'org-tempo)
|
|
|
|
(add-to-list 'org-modules 'org-tempo t)
|
|
|
|
|
|
|
|
(defun org-babel-edit-prep:emacs-lisp (babel-info)
|
|
|
|
(setq-local buffer-file-name (->> babel-info caddr (alist-get :tangle)))
|
|
|
|
(lsp))
|
|
|
|
#+end_src
|
|
|
|
|
2024-10-03 20:26:12 -04:00
|
|
|
** Fix Indents + Enable Autopairs
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(electric-indent-mode 1)
|
|
|
|
(electric-pair-mode 1)
|
|
|
|
(setq c-basic-offset 2)
|
2024-10-05 00:40:51 -04:00
|
|
|
|
|
|
|
(setq-default tab-width 2)
|
2024-10-03 20:26:12 -04:00
|
|
|
(setq-default indent-tabs-mode nil)
|
2024-10-05 00:40:51 -04:00
|
|
|
(setq-default standard-indent 2)
|
|
|
|
(global-set-key (kbd "TAB") 'indent-for-tab-command)
|
2024-10-03 20:26:12 -04:00
|
|
|
|
|
|
|
(use-package evil
|
|
|
|
:ensure t
|
|
|
|
:init
|
2024-10-04 21:53:37 -04:00
|
|
|
(setq evil-split-window-below t
|
|
|
|
evil-undo-system 'undo-tree
|
|
|
|
evil-vsplit-window-right t
|
|
|
|
evil-want-C-i-jump nil
|
|
|
|
evil-want-C-u-scroll t
|
|
|
|
evil-want-integration t
|
|
|
|
evil-want-integration t
|
|
|
|
evil-want-keybinding nil)
|
2024-10-03 20:26:12 -04:00
|
|
|
:config
|
2024-10-05 00:40:51 -04:00
|
|
|
(evil-mode 1)
|
2024-10-05 01:25:11 -04:00
|
|
|
(evil-define-key 'normal 'global (kbd "K") #'eldoc-box-help-at-point)
|
2024-10-05 01:31:57 -04:00
|
|
|
(evil-define-key 'normal 'global (kbd "gg") #'magit-status)
|
2024-10-05 01:25:11 -04:00
|
|
|
(evil-define-key 'normal 'global (kbd "gp") #'diff-hl-show-hunk)
|
|
|
|
(evil-define-key 'normal 'global (kbd "gr") #'diff-hl-revert-hunk)
|
|
|
|
(evil-define-key 'normal 'global (kbd "gs") #'diff-hl-stage-current-hunk))
|
2024-10-03 20:26:12 -04:00
|
|
|
|
2024-10-04 19:01:46 -04:00
|
|
|
(use-package evil-collection
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(evil-collection-init))
|
|
|
|
|
|
|
|
(use-package evil-leader
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(global-evil-leader-mode)
|
|
|
|
(setq evil-leader/leader "<SPC>")
|
|
|
|
(evil-leader/set-key "a" #'eglot-code-actions)
|
2024-10-04 21:40:04 -04:00
|
|
|
(evil-leader/set-key "bb" #'switch-to-buffer)
|
2024-10-04 19:01:46 -04:00
|
|
|
(evil-leader/set-key "bd" #'kill-this-buffer)
|
|
|
|
(evil-leader/set-key "e" #'dirvish-side))
|
|
|
|
|
2024-10-04 22:29:50 -04:00
|
|
|
(use-package catppuccin-theme
|
|
|
|
:ensure t
|
|
|
|
:demand t
|
|
|
|
:config
|
|
|
|
(load-theme 'catppuccin t))
|
|
|
|
|
|
|
|
(setq auto-save-default nil
|
|
|
|
make-backup-files nil)
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** LSP
|
|
|
|
|
|
|
|
*** Eglot
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
2024-10-03 20:26:12 -04:00
|
|
|
(use-package eglot
|
2024-10-04 22:24:03 -04:00
|
|
|
:hook
|
|
|
|
(prog-mode . eglot-ensure)
|
2024-10-05 00:40:51 -04:00
|
|
|
:config
|
2024-10-04 22:24:03 -04:00
|
|
|
(add-hook 'emacs-lisp-mode-hook 'eglot-ensure)
|
|
|
|
(add-hook 'c-mode-hook 'hide-ifdef-mode)
|
|
|
|
(add-hook 'c++-mode-hook 'hide-ifdef-mode))
|
|
|
|
|
|
|
|
(setq-default eglot-workspace-configuration
|
|
|
|
'((haskell
|
|
|
|
(plugin
|
|
|
|
(stan
|
|
|
|
(globalOn . :json-false)))))) ;; disable stan
|
|
|
|
|
|
|
|
(defun my/eglot-format-buffer-on-save ()
|
|
|
|
"Format the current buffer if Eglot is active."
|
|
|
|
(when (bound-and-true-p eglot--managed-p)
|
|
|
|
(eglot-format-buffer)))
|
|
|
|
|
|
|
|
(add-hook 'before-save-hook #'my/eglot-format-buffer-on-save)
|
2024-10-05 00:40:51 -04:00
|
|
|
|
|
|
|
;; Load posframe for popups
|
|
|
|
(use-package eldoc-box :ensure t)
|
2024-10-04 22:29:50 -04:00
|
|
|
#+end_src
|
2024-10-04 22:24:03 -04:00
|
|
|
|
2024-10-04 22:29:50 -04:00
|
|
|
*** TreeSitter
|
2024-10-03 20:26:12 -04:00
|
|
|
|
2024-10-04 22:29:50 -04:00
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(use-package tree-sitter
|
2024-10-03 20:26:12 -04:00
|
|
|
:ensure t
|
2024-10-04 22:29:50 -04:00
|
|
|
:hook
|
|
|
|
(prog-mode . tree-sitter-hl-mode)
|
2024-10-03 20:26:12 -04:00
|
|
|
:config
|
2024-10-04 22:29:50 -04:00
|
|
|
(global-tree-sitter-mode))
|
2024-10-03 20:26:12 -04:00
|
|
|
|
2024-10-04 22:29:50 -04:00
|
|
|
(use-package tree-sitter-langs
|
|
|
|
:ensure t)
|
2024-10-03 20:26:12 -04:00
|
|
|
#+end_src
|
2024-10-04 19:01:46 -04:00
|
|
|
|
|
|
|
** Rainbow Delimiters
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(use-package rainbow-delimiters
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** Disable Bars
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(menu-bar-mode -1)
|
|
|
|
(scroll-bar-mode -1)
|
|
|
|
(tool-bar-mode -1)
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** Line Numbers
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(global-display-line-numbers-mode t)
|
|
|
|
|
|
|
|
(setq display-line-numbers-type 'relative)
|
|
|
|
|
2024-10-04 21:40:04 -04:00
|
|
|
(dolist (mode
|
|
|
|
'(term-mode-hook
|
|
|
|
vterm-mode-hook
|
|
|
|
shell-mode-hook
|
|
|
|
org-mode-hook
|
|
|
|
dirvish-setup-hook
|
|
|
|
eshell-mode-hook))
|
2024-10-04 19:01:46 -04:00
|
|
|
(add-hook mode (lambda () (display-line-numbers-mode 0))))
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** Vim-Style Scrolling
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(setq scroll-step 3
|
|
|
|
scroll-conservatively 9999)
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** System-Specific Settings
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(cond
|
|
|
|
((eq system-type 'darwin)
|
2024-10-04 21:53:37 -04:00
|
|
|
(set-face-attribute 'default nil :font "Iosevka Comfy-14")
|
|
|
|
(set-face-attribute 'fixed-pitch nil :font "Iosevka Comfy-14")
|
|
|
|
(set-face-attribute 'variable-pitch nil :font "Iosevka Comfy Motion Duo-16")
|
2024-10-04 19:01:46 -04:00
|
|
|
(setq default-frame-alist '((font . "Iosevka Comfy-14"))))
|
|
|
|
((eq system-type 'gnu/linux)
|
2024-10-05 00:40:51 -04:00
|
|
|
(set-face-attribute 'default nil :font "Iosevka Comfy Medium-12")
|
|
|
|
(set-face-attribute 'fixed-pitch nil :font "Iosevka Comfy Medium-12")
|
2024-10-05 01:25:11 -04:00
|
|
|
(set-face-attribute 'variable-pitch nil :font "Iosevka Comfy Motion Duo Md-14")
|
2024-10-04 21:53:37 -04:00
|
|
|
(setq default-frame-alist
|
2024-10-05 00:40:51 -04:00
|
|
|
'((font . "Iosevka Comfy Medium-12")
|
2024-10-04 21:53:37 -04:00
|
|
|
(undecorated . t)))))
|
2024-10-04 19:01:46 -04:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** Use Short Answers
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(setq use-short-answers t)
|
|
|
|
#+end_src
|
|
|
|
|
2024-10-04 21:40:04 -04:00
|
|
|
** Enable ctrl+c/ctrl+v
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(cua-mode 1)
|
|
|
|
#+end_src
|
|
|
|
|
2024-10-04 19:01:46 -04:00
|
|
|
** Undo Tree
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(use-package undo-tree
|
|
|
|
:ensure t
|
|
|
|
:demand t
|
|
|
|
:config
|
|
|
|
(global-undo-tree-mode)
|
|
|
|
(setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo"))))
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** Dashboard
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(use-package dashboard
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(dashboard-setup-startup-hook)
|
2024-10-04 21:53:37 -04:00
|
|
|
(setq dashboard-startup-banner 'logo
|
|
|
|
dashboard-center-content t
|
|
|
|
dashboard-vertically-center-content t
|
|
|
|
dashboard-startup-banner 'logo
|
|
|
|
initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))))
|
2024-10-04 21:40:04 -04:00
|
|
|
#+end_src
|
|
|
|
|
2024-10-04 22:24:03 -04:00
|
|
|
** Git Integration
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(use-package transient :ensure t)
|
|
|
|
|
|
|
|
(use-package magit
|
|
|
|
:ensure t
|
|
|
|
:commands magit-status magit-blame magit-version
|
|
|
|
:init
|
|
|
|
(defadvice magit-status (around magit-fullscreen activate)
|
|
|
|
(window-configuration-to-register :magit-fullscreen) ad-do-it
|
|
|
|
(delete-other-windows))
|
|
|
|
:config
|
|
|
|
(setq magit-branch-arguments nil
|
2024-10-05 01:29:55 -04:00
|
|
|
magit-completing-read-function 'magit-ivy-completing-read
|
2024-10-04 22:24:03 -04:00
|
|
|
magit-default-tracking-name-function 'magit-default-tracking-name-branch-only
|
|
|
|
magit-push-always-verify nil
|
2024-10-05 01:31:57 -04:00
|
|
|
magit-restore-window-configuration t))
|
2024-10-04 22:24:03 -04:00
|
|
|
|
2024-10-05 01:25:11 -04:00
|
|
|
(use-package diff-hl
|
|
|
|
:ensure t
|
|
|
|
:hook ((magit-post-refresh . diff-hl-magit-post-refresh))
|
|
|
|
:config
|
|
|
|
(global-diff-hl-mode))
|
|
|
|
|
2024-10-04 22:24:03 -04:00
|
|
|
(use-package git-gutter
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(global-git-gutter-mode +1))
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
** Direnv
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(use-package direnv
|
|
|
|
:config
|
|
|
|
(direnv-mode))
|
|
|
|
#+end_src
|
|
|
|
|
2024-10-04 21:40:04 -04:00
|
|
|
** Better M-x
|
|
|
|
|
|
|
|
*** Ivy Mode (Completions)
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(setq ivy-ignore-buffers '("\\` " "\\`\\*"))
|
|
|
|
|
|
|
|
(use-package ivy
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(ivy-mode)
|
2024-10-04 21:53:37 -04:00
|
|
|
(setq ivy-use-virtual-buffers t
|
|
|
|
enable-recursive-minibuffers t))
|
2024-10-04 21:40:04 -04:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
*** Amx Mode (Better Interface)
|
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
(use-package amx
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(amx-mode))
|
2024-10-04 19:01:46 -04:00
|
|
|
#+end_src
|
|
|
|
|
2024-10-04 21:53:37 -04:00
|
|
|
** Org Mode Improvements
|
2024-10-04 19:50:51 -04:00
|
|
|
|
|
|
|
#+begin_src emacs-lisp
|
2024-10-04 21:53:37 -04:00
|
|
|
(add-hook 'org-mode-hook 'visual-line-mode)
|
2024-10-04 19:50:51 -04:00
|
|
|
|
2024-10-04 21:40:04 -04:00
|
|
|
(use-package mixed-pitch
|
|
|
|
:hook
|
|
|
|
(org-mode . mixed-pitch-mode))
|
|
|
|
|
|
|
|
(use-package org-modern
|
|
|
|
:ensure t
|
|
|
|
:hook (org-mode . org-modern-mode)
|
|
|
|
:config
|
2024-10-04 21:53:37 -04:00
|
|
|
(setq org-ellipsis "…")
|
2024-10-04 21:40:04 -04:00
|
|
|
(setq org-modern-star 'replace))
|
|
|
|
|
|
|
|
(use-package org-modern-indent
|
|
|
|
:ensure (org-modern-indent :type git :host github :repo "jdtsmith/org-modern-indent")
|
|
|
|
:config
|
|
|
|
(add-hook 'org-mode-hook #'org-modern-indent-mode 90))
|
2024-10-04 19:50:51 -04:00
|
|
|
#+end_src
|