#+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 ** Disable Built-In Auto-Save and Backup #+begin_src emacs-lisp (setq auto-save-default nil make-backup-files nil) #+end_src ** No Scratch On Open #+begin_src emacs-lisp (setq initial-scratch-message nil) (setq initial-buffer-choice nil) (add-hook 'emacs-startup-hook (lambda () (when (and (get-buffer "*scratch*") (not (eq (current-buffer) (get-buffer "*scratch*")))) (kill-buffer "*scratch*")))) #+end_src ** Dirvish #+begin_src emacs-lisp (add-hook 'dired-mode-hook 'dired-omit-mode) (use-package ethan-wspace :ensure t :config (setq mode-require-final-newline nil) (global-ethan-wspace-mode 1)) (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)))) (use-package dirvish :ensure t :init (dirvish-override-dired-mode) :config (dirvish-peek-mode) (dirvish-side-follow-mode) (setq dired-listing-switches "-al --human-readable --group-directories-first" dired-mouse-drag-files t 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"))) 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)) dirvish-mode-line-height 25 dirvish-subtree-state-style 'nerd mouse-drag-and-drop-region-cross-program t)) ;; 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)) (use-package nerd-icons :ensure t :custom (nerd-icons-font-family "Maple Mono NF")) (use-package ns-auto-titlebar :ensure t :config (when (eq system-type 'darwin) (ns-auto-titlebar-mode))) #+end_src ** Doom Modeline #+begin_src emacs-lisp (use-package doom-modeline :ensure t :config (doom-modeline-mode)) #+end_src ** VTerm #+begin_src emacs-lisp (use-package vterm :ensure t :config (setq vterm-timer-delay 0.01)) (use-package shackle :ensure t :config (setq shackle-rules '(("\\*vterm\\*" :regexp t :popup t :align 'below :size 0.4 :select t))) (shackle-mode 1)) (use-package vterm-toggle :ensure t) #+end_src ** Nix #+begin_src emacs-lisp (use-package nix-mode :mode "\\.nix\\'") #+end_src ** Indents and Autopairs #+begin_src emacs-lisp (electric-indent-mode -1) (electric-pair-mode 1) #+end_src ** Evil Mode #+begin_src emacs-lisp (setq-default evil-auto-indent t indent-line-function 'evil-indent-line indent-tabs-mode nil tab-width 2 org-src-tab-acts-natively t org-indent-indentation-per-level 2 org-indent-mode-turns-on-hiding-stars nil) (defun indent-tabs-hook () (setq tab-width 2 indent-tabs-mode t evil-auto-indent t c-basic-offset 2)) (dolist (hook '(c++-mode-hook c-mode-hook c++-ts-mode-hook c-ts-mode-hook)) (add-hook hook 'indent-tabs-hook)) (use-package evil :ensure t :init (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) :config (evil-mode 1) (setq-default evil-shift-width 2) (evil-define-key 'insert 'global (kbd "TAB") 'tab-to-tab-stop) (evil-define-key 'insert 'global (kbd "C-c") 'cua-copy-region) (evil-define-key 'insert 'global (kbd "C-v") 'cua-paste) (evil-define-key 'insert 'global (kbd "C-x") 'cua-cut-region) (evil-define-key 'normal 'global (kbd "gm") 'magit-status) (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)) (use-package evil-surround :ensure t :config (global-evil-surround-mode 1)) ;; Set whitespace actions. (setq-default whitespace-action '(cleanup auto-cleanup)) (use-package general :ensure t :config (general-define-key :states '(normal visual emacs) :keymaps 'override "K" '(eldoc-box-help-at-point :wk "Hover") "C-t" '(vterm-toggle :wk "Toggle VTerm"))) (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 "") (evil-leader/set-key "bb" #'switch-to-buffer) (evil-leader/set-key "bd" #'kill-this-buffer) (evil-leader/set-key "e" #'dirvish-side) (evil-leader/set-key "d" #'flymake-show-diagnostic) (evil-leader/set-key "n" #'flymake-goto-next-error) (evil-leader/set-key "N" #'flymake-goto-prev-error) (evil-leader/set-key "n" #'flymake-goto-next-error) (evil-leader/set-key "a" #'eglot-code-actions)) #+end_src ** Catppuccin Theme #+begin_src emacs-lisp (use-package catppuccin-theme :ensure t :demand t :config (load-theme 'catppuccin t)) #+end_src ** Disable Autosave and Backup Files #+begin_src emacs-lisp (setq auto-save-default nil make-backup-files nil) #+end_src ** Ligatures #+begin_src emacs-lisp (use-package ligature :config (let ((common-ligatures '("<---" "<--" "<<-" "<-" "->" "-->" "--->" "<->" "<-->" "<--->" "<---->" "