12 KiB
12 KiB
Emacs Configuration
Basic Setup
Server
(require 'bind-key)
(load "server")
(unless (server-running-p) (server-start))
Disable Auto-Save and Backup
(I don't like having #file#
and file~
everywhere in my directories)
(setq auto-save-default nil)
(setq make-backup-files nil)
Enable Real Auto Save
(use-package real-auto-save
:ensure t
:config
(setq real-auto-save-interval 1)
(add-hook 'prog-mode-hook 'real-auto-save-mode))
No Scratch On Open
(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*"))))
Fix Indents + Enable Autopairs
(electric-indent-mode 1)
(electric-pair-mode 1)
(setq c-basic-offset 2)
(setq-default indent-tabs-mode nil)
Show Whitespace
(setq whitespace-style '(face tabs spaces trailing lines-tail))
(setq whitespace-display-mappings
'((space-mark ?\ [?\u00B7] [?.])
(tab-mark ?\t [?\u00BB ?\t])))
(add-hook 'prog-mode-hook 'whitespace-mode)
(add-hook 'org-src-mode-hook 'whitespace-mode)
(add-hook 'before-save-hook 'whitespace-cleanup)
Rainbow Delimiters
(use-package rainbow-delimiters
:ensure t
:config
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
Disable Bars
(menu-bar-mode -1)
(scroll-bar-mode -1)
(tool-bar-mode -1)
Line Numbers
(global-display-line-numbers-mode t)
(setq display-line-numbers-type 'relative)
(dolist (mode '(term-mode-hook
vterm-mode-hook
shell-mode-hook
eshell-mode-hook
treemacs-mode-hook))
(add-hook mode (lambda () (display-line-numbers-mode 0))))
Vim-Style Scrolling
(setq scroll-step 3
scroll-margin 3
scroll-conservatively 9999)
System-Specific Settings
(when (eq system-type 'darwin)
(ns-auto-titlebar-mode))
(cond
((eq system-type 'darwin)
(setq default-frame-alist '((font . "Iosevka Comfy-14"))))
((eq system-type 'gnu/linux)
(setq default-frame-alist '((font . "Maple Mono NF-12")
(undecorated . t)))))
Use Short Answers
(setq use-short-answers t)
Package Management
Ligatures
(defvar ligatures-MapleMono
'("--" "---" "==" "===" "!=" "!==" "=!=" "=:=" "=/=" "<=" ">=" "&&" "&&&" "&=" "++" "+++"
"***" ";;" "!!" "??" "?:" "?." "?=" "<:" ":<" ":>" ">:" "<>" "<<<" ">>>" "<<" ">>" "||" "-|"
"_|_" "|-" "||-" "|=" "||=" "##" "###" "####" "#{" "#[" "]#" "#(" "#?" "#_" "#_(" "#:"
"#!" "#=" "^=" "<$>" "<$" "$>" "<+>" "<+ +>" "<*>" "<* *>" "</" "</>" "/>" "<!--"
"<#--" "-->" "->" "->>" "<<-" "<-" "<=<" "=<<" "<<=" "<==" "<=>" "<==>" "==>" "=>"
"=>>" ">=>" ">>=" ">>-" ">-" ">--" "-<" "-<<" ">->" "<-<" "<-|" "<=|" "|=>" "|->" "<-"
"<~~" "<~" "<~>" "~~" "~~>" "~>" "~-" "-~" "~@" "[||]" "|]" "[|" "|}" "{|" "[<" ">]"
"|>" "<|" "||>" "<||" "|||>" "|||>" "<|>" "..." ".." ".=" ".-" "..<" ".?" "::" ":::"
":=" "::=" ":?" ":?>" "//" "///" "/*" "*/" "/=" "//=" "/==" "@_" "__"))
(use-package ligature
:config
(ligature-set-ligatures 'prog-mode ligatures-MapleMono)
(global-ligature-mode t))
Theme
(use-package catppuccin-theme :ensure t :demand t)
(load-theme 'catppuccin t)
Dashboard
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook)
(setq dashboard-startup-banner 'logo)
(setq dashboard-center-content t)
(setq dashboard-vertically-center-content t)
(setq dashboard-startup-banner 'logo)
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
(setq recentf-exclude '("~/.emacs.d/.cache/treemacs-persist")))
Better M-x
Ivy Mode (Completions)
(use-package ivy
:ensure t
:hook (after-init . ivy-mode)
:config
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t))
Amx Mode (Better Interface)
(use-package amx
:ensure t
:hook (after-init . amx-mode))
Modeline
(use-package doom-modeline
:ensure t
:hook (after-init . doom-modeline-mode))
Emoji Support
(use-package emojify :hook (after-init . global-emojify-mode))
Undo Tree
(use-package undo-tree
:demand t
:config
(global-undo-tree-mode)
(setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo"))))
Development Tools
Direnv
(use-package direnv :config (direnv-mode))
Nix
(use-package nix-mode :mode "\\.nix\\'")
(use-package lua-mode :mode "\\.lua\\'")
Treesitter
(use-package treesit-auto
:requires treesit
:config
(setq treesit-auto-install 'prompt)
(global-treesit-auto-mode))
(use-package treesit
:requires treesit
:ensure nil
:config
(mapc #'exordium--add-forward-ts-hook
'(
LaTeX
bash
c
c++
cmake
csharp
css
elisp
go
go-mod
haskell
java
js
json
lua
markdown
python
ruby
rust
scala
toml
typescript
vue
yaml
))
(setq treesit-font-lock-level 4))
(use-package tree-sitter-langs)
(use-package tree-sitter
:diminish
:after (tree-sitter-langs)
:hook
(tree-sitter-after-on . tree-sitter-hl-mode)
:custom
(font-lock-maximum-decoration t)
:config
(when-let ((language-name (alist-get 'ruby-mode
tree-sitter-major-mode-language-alist)))
(add-to-list 'tree-sitter-major-mode-language-alist
(cons 'enh-ruby-mode language-name)))
(add-to-list 'tree-sitter-major-mode-language-alist
(cons 'forge-post-mode 'markdown))
(global-tree-sitter-mode))
Eglot
(add-hook 'prog-mode-hook 'eglot-ensure)
(use-package haskell-mode :ensure t
:hook (haskell-mode . eglot-ensure))
(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)
(use-package web-mode
:ensure t
:mode
(("\\.phtml\\'" . web-mode)
("\\.php\\'" . web-mode)
("\\.tpl\\'" . web-mode)
("\\.[agj]sp\\'" . web-mode)
("\\.as[cp]x\\'" . web-mode)
("\\.erb\\'" . web-mode)
("\\.mustache\\'" . web-mode)
("\\.djhtml\\'" . web-mode)
("\\.vue\\'" . web-mode)))
(use-package vue-mode
:config
(setq mmm-submode-decoration-level 2))
(add-hook 'c-mode-hook 'hide-ifdef-mode)
(add-hook 'c++-mode-hook 'hide-ifdef-mode)
(setq hide-ifdef-initially t)
(setq hide-ifdef-shadow 'font-lock-comment-face)
Corfu Completions
(use-package corfu
:ensure t
:custom
(corfu-cycle t) ;;cycle through all things
(corfu-auto t) ;;autocomplete
(corfu-auto-prefix 1) ;; 2 letters to start autocomplete
(corfu-auto-delay 0.0) ;; idk 0s to start?
:bind (:map corfu-map ("<escape>" . corfu-quit))
:init (global-corfu-mode))
(use-package cape :ensure t)
;; get eglot to play nice with corfu
(advice-add 'eglot-completion-at-point :around #'cape-wrap-buster)
(use-package kind-icon
:ensure t
:after corfu
:custom
(kind-icon-use-icons t)
(kind-icon-default-face 'corfu-default)
(kind-icon-blend-background nil)
(kind-icon-blend-frac 0.08)
:config
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
Sideline
(use-package sideline-flycheck
:hook (flycheck-mode . sideline-mode)
:init
(setq sideline-backends-right '(sideline-flycheck)))
(use-package sideline-flycheck :hook (flycheck-mode . sideline-flycheck-setup))
(use-package sideline-eglot
:init
(setq sideline-backends-right '(sideline-eglot)))
(use-package eglot :hook (eglot-mode . sideline-mode))
VTerm Toggle
(use-package vterm-toggle :ensure t)
(global-set-key (kbd "C-t") 'vterm-toggle)
Evil Mode and Keybindings
Evil Mode
(use-package evil
:ensure t
:init
(setq evil-split-window-below t)
(setq evil-undo-system 'undo-tree)
(setq evil-vsplit-window-right t)
(setq evil-want-C-i-jump nil)
(setq evil-want-C-u-scroll t)
(setq evil-want-integration t)
(setq evil-want-integration t)
(setq evil-want-keybinding nil)
:config
(evil-mode 1))
Evil Collection
(use-package evil-collection
:after evil
:ensure t
:config
(evil-collection-init))
Evil Leader
(use-package evil-leader
:after evil
:config
(global-evil-leader-mode)
(setq evil-leader/leader "<SPC>")
(evil-leader/set-key "a" #'eglot-code-actions)
(evil-leader/set-key "bd" #'kill-this-buffer)
(evil-leader/set-key "e" #'treemacs))
Evil Surround
(use-package evil-surround
:ensure t
:config
(global-evil-surround-mode 1))
Easier Copy/Paste
(global-set-key (kbd "C-S-c") 'kill-ring-save)
(global-set-key (kbd "C-S-v") 'yank)
;; Load posframe for popups
(use-package eldoc-box
:ensure t)
(evil-define-key 'normal 'global (kbd "SPC k") #'eldoc-box-help-at-point)
Org Mode Templates
;; 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))
Tab Management
Intuitive Tabline
(use-package powerline)
(use-package intuitive-tab-line
:load-path "git/intuitive-tab-line-mode"
:custom
(tab-line-tabs-function 'intuitive-tab-line-buffers-list)
(tab-line-switch-cycling t)
:config
(global-tab-line-mode 1)
(recentf-mode 1)
(setq tab-line-separator "")
(setq tab-line-new-button-show nil)
(setq tab-line-close-button-show nil)
(defvar my/tab-height 24)
(defvar my/tab-left (powerline-wave-right 'tab-line nil my/tab-height))
(defvar my/tab-right (powerline-wave-left nil 'tab-line my/tab-height))
(defun my/tab-line-tab-name-buffer (buffer &optional _buffers)
(powerline-render (list my/tab-left
(format "%s" (buffer-name buffer))
my/tab-right)))
(setq tab-line-tab-name-function #'my/tab-line-tab-name-buffer)
(global-set-key (kbd "C-S-<tab>") 'tab-line-switch-to-prev-tab)
(global-set-key (kbd "C-<tab>") 'tab-line-switch-to-next-tab)
(global-set-key (kbd "C-S-t") 'recentf-open-most-recent-file))