summaryrefslogtreecommitdiff
path: root/dot_config/emacs/lisp/emacs-config.el
diff options
context:
space:
mode:
authorSakamoto <me@sakamoto.network>2026-08-16 15:34:00 -0500
committerSakamoto <me@sakamoto.network>2026-08-16 15:34:00 -0500
commitd51beea88d300cb5066bb92a8148cad52fa1091d (patch)
tree4357b4958c19dddd304a0d6ee77994fb9f12c118 /dot_config/emacs/lisp/emacs-config.el
parenta623fed63460d6d810605ce1ce858a58a5b222f7 (diff)
downloaddotfiles-d51beea88d300cb5066bb92a8148cad52fa1091d.tar.xz
dotfiles-d51beea88d300cb5066bb92a8148cad52fa1091d.zip
update
Diffstat (limited to 'dot_config/emacs/lisp/emacs-config.el')
-rw-r--r--dot_config/emacs/lisp/emacs-config.el280
1 files changed, 280 insertions, 0 deletions
diff --git a/dot_config/emacs/lisp/emacs-config.el b/dot_config/emacs/lisp/emacs-config.el
new file mode 100644
index 0000000..bfc15ee
--- /dev/null
+++ b/dot_config/emacs/lisp/emacs-config.el
@@ -0,0 +1,280 @@
+(use-package emacs
+ :ensure nil
+ :custom
+ (user-mail-address "me@sakamoto.network")
+ (user-full-name "Sakamoto")
+ (mml-secure-openpgp-sign-with-sender t)
+ (message-sendmail-envelope-from 'header)
+ (auto-save-default nil) ;; Disable automatic saving of buffers.
+ (column-number-mode t) ;; Display the column number in the mode line.
+ (create-lockfiles nil) ;; Prevent the creation of lock files when editing.
+ (delete-by-moving-to-trash t) ;; Move deleted files to the trash instead of permanently deleting them.
+ (delete-selection-mode 1) ;; Enable replacing selected text with typed text.
+ (display-line-numbers-type 'relative) ;; Use relative line numbering in programming modes.
+ (global-auto-revert-non-file-buffers t) ;; Automatically refresh non-file buffers.
+ (history-length 100) ;; Set the length of the command history.
+ (indent-tabs-mode nil) ;; Disable the use of tabs for indentation (use spaces instead).
+ (inhibit-startup-message t) ;; Disable the startup message when Emacs launches.
+ (initial-scratch-message "") ;; Clear the initial message in the *scratch* buffer.
+ (ispell-program-name "hunspell")
+ (ispell-dictionary "en_US")
+ (shr-use-colors nil)
+ (blink-cursor-mode nil)
+ (make-backup-files nil) ;; Disable creation of backup files.
+ (pixel-scroll-precision-mode t) ;; Enable precise pixel scrolling.
+ (pixel-scroll-precision-use-momentum nil) ;; Disable momentum scrolling for pixel precision.
+ (fill-column 80) ;; Set column fill
+ (ring-bell-function 'ignore) ;; Disable the audible bell.
+ (split-width-threshold 300) ;; Prevent automatic window splitting if the window width exceeds 300 pixels.
+ (switch-to-buffer-obey-display-actions t) ;; Make buffer switching respect display actions.
+ (tab-always-indent 'complete) ;; Make the TAB key complete text instead of just indenting.
+ (tab-width 4) ;; Set the tab width to 4 spaces.
+ (treesit-font-lock-level 4) ;; Use advanced font locking for Treesit mode.
+ (truncate-lines t) ;; Enable line truncation to avoid wrapping long lines.
+ (global-visual-line-mode 1) ;; Soft wrap text
+ (global-visual-wrap-prefix-mode t)
+ (use-dialog-box nil) ;; Disable dialog boxes in favor of minibuffer prompts.
+ (use-short-answers t) ;; Use short answers in prompts for quicker responses (y instead of yes)
+ (warning-minimum-level :emergency) ;; Set the minimum level of warnings to display.
+ (help-window-select t)
+ (repeat-mode 1)
+ (scroll-conservatively 101)
+ (epg-pinentry-mode 'loopback)
+ (view-read-only t) ;; Enter view mode on read-only files
+ (imenu-auto-rescan t) ;; Automatically update imenu entries based on current buffer/file
+ (minibuffer-visible-completions t) ;; Use arrow keys to select completion candidates
+
+ :hook ;; Add hooks to enable specific features in certain modes.
+ (prog-mode . display-line-numbers-mode) ;; Enable line numbers in programming modes.
+ (text-mode . display-line-numbers-mode)
+
+ :config
+ ;; By default emacs gives you access to a lot of *special* buffers, while navigating with [b and ]b,
+ ;; this might be confusing for newcomers. This settings make sure ]b and [b will always load a
+ ;; file buffer. To see all buffers use <leader> SPC, <leader> b l, or <leader> b i.
+ (defun skip-these-buffers (_window buffer _bury-or-kill)
+ "Function for `switch-to-prev-buffer-skip'."
+ (string-match "\\*[^*]+\\*" (buffer-name buffer)))
+ (setq switch-to-prev-buffer-skip 'skip-these-buffers)
+
+ (set-face-attribute 'default nil :family "Departure Mono" :height 120)
+
+ ;; Save manual customizations to a separate file instead of cluttering `init.el'.
+ ;; You can M-x customize, M-x customize-group, or M-x customize-themes, etc.
+ ;; The saves you do manually using the Emacs interface would overwrite this file.
+ ;; The following makes sure those customizations are in a separate file.
+ (setq custom-file (locate-user-emacs-file "custom-vars.el")) ;; Specify the custom file path.
+ (load custom-file 'noerror 'nomessage) ;; Load the custom file quietly, ignoring errors.
+
+ ;; Makes Emacs vertical divisor the symbol │ instead of |.
+ (set-display-table-slot standard-display-table 'vertical-border (make-glyph-code ?│))
+
+ :init ;; Initialization settings that apply before the package is loaded.
+ (tool-bar-mode -1) ;; Disable the tool bar for a cleaner interface.
+ (menu-bar-mode -1) ;; Disable the menu bar for a more streamlined look.
+
+ (when scroll-bar-mode
+ (scroll-bar-mode -1)) ;; Disable the scroll bar if it is active.
+
+ (global-auto-revert-mode 1) ;; Enable global auto-revert mode to keep buffers up to date with their corresponding files.
+ (recentf-mode 1) ;; Enable tracking of recently opened files.
+
+ (setq history-delete-duplicates t)
+ (savehist-mode 1) ;; Enable saving of command history.
+
+ (save-place-mode 1) ;; Enable saving the place in files for easier return.
+ (winner-mode 1) ;; Enable winner mode to easily undo window configuration changes.
+ (xterm-mouse-mode 1) ;; Enable mouse support in terminal mode.
+ (file-name-shadow-mode 1) ;; Enable shadowing of filenames for clarity.
+
+ (auth-source-pass-enable) ;; Use password-store instead of authinfo
+
+ (midnight-mode 1) ;; Cleanup every 3 days
+
+ ;; Set the default coding system for files to UTF-8.
+ (modify-coding-system-alist 'file "" 'utf-8))
+
+(use-package windmove
+ :ensure nil
+ :init
+ (windmove-default-keybindings 'meta))
+
+(use-package window
+ :ensure nil ;; This is built-in, no need to fetch it.
+ :custom
+ (display-buffer-alist
+ '(
+ ;; ("\\*.*e?shell\\*"
+ ;; (display-buffer-in-side-window)
+ ;; (window-height . 0.25)
+ ;; (side . bottom)
+ ;; (slot . -1))
+
+ ("\\*\\(Backtrace\\|Warnings\\|Compile-Log\\|[Hh]elp\\|Messages\\|Bookmark List\\|Ibuffer\\|Occur\\|eldoc.*\\)\\*"
+ (display-buffer-in-side-window)
+ (window-height . 0.25)
+ (side . bottom)
+ (slot . 0))
+
+ ;; Example configuration for the LSP help buffer,
+ ;; keeps it always on bottom using 25% of the available space:
+ ("\\*\\(lsp-help\\)\\*"
+ (display-buffer-in-side-window)
+ (window-height . 0.25)
+ (side . bottom)
+ (slot . 0))
+
+ ;; Configuration for displaying various diagnostic buffers on
+ ;; bottom 25%:
+ ("\\*\\(Flymake diagnostics\\|xref\\|ivy\\|Swiper\\|Completions\\)"
+ (display-buffer-in-side-window)
+ (window-height . 0.25)
+ (side . bottom)
+ (slot . 1))
+ )))
+
+(use-package ibuffer
+ :ensure nil
+ :bind ([remap list-buffers] . ibuffer))
+
+(use-package dired
+ :ensure nil ;; This is built-in, no need to fetch it.
+ :bind
+ (:map dired-mode-map ("." . dired-omit-mode))
+ :hook
+ (dired-mode . dired-omit-mode)
+ :init
+ (with-eval-after-load 'dired (require 'dired-x))
+ :custom
+ (dired-omit-files "^\\.[a-zA-Z0-9]+")
+ (dired-listing-switches "-lah --group-directories-first") ;; Display files in a human-readable format and group directories first.
+ (dired-guess-shell-alist-user
+ '(("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv --really-quiet" "xdg-open" "open") ;; Open audio and video files with `mpv'.
+ (".*" "open" "xdg-open")))
+ (dired-dwim-target t) ;; Enable "do what I mean" for target directories.
+ (dired-kill-when-opening-new-dired-buffer t) ;; Close the previous buffer when opening a new `dired' instance.
+ (dired-auto-revert-buffer t)
+ (dired-mouse-drag-files t)
+ :config
+ (when (eq system-type 'darwin)
+ (let ((gls (executable-find "gls"))) ;; Use GNU ls on macOS if available.
+ (when gls
+ (setq insert-directory-program gls)))))
+
+(use-package isearch
+ :ensure nil ;; This is built-in, no need to fetch it.
+ :config
+ (setq isearch-lazy-count t) ;; Enable lazy counting to show current match information.
+ (setq lazy-count-prefix-format "(%s/%s) ") ;; Format for displaying current match count.
+ (setq lazy-count-suffix-format nil) ;; Disable suffix formatting for match count.
+ (setq search-whitespace-regexp ".*?") ;; Allow searching across whitespace.
+ :bind (("C-s" . isearch-forward) ;; Bind C-s to forward isearch.
+ ("C-r" . isearch-backward))) ;; Bind C-r to backward isearch.
+
+(use-package dictionary
+ :ensure nil
+ :bind (("C-c L" . dictionary-lookup-definition))
+ :config
+ (setq dictionary-server "dict.org"))
+
+(use-package whitespace
+ :init
+ (dolist (hook '(text-mode-hook))
+ (add-hook hook #'whitespace-mode))
+ (add-hook 'before-save-hook #'whitespace-cleanup)
+ :config
+ (setq whitespace-line-column 80) ;; limit line length
+ (setq whitespace-style '(face tabs empty trailing)))
+
+(use-package eldoc
+ :ensure nil ;; This is built-in, no need to fetch it.
+ :config
+ (setq eldoc-idle-delay 0) ;; Automatically fetch doc help
+ (setq eldoc-echo-area-use-multiline-p nil) ;; We use the "K" floating help instead
+ ;; set to t if you want docs on the echo area
+ (setq eldoc-echo-area-display-truncation-message nil)
+ :init
+ (global-eldoc-mode))
+
+(use-package completion-preview
+ :ensure nil
+ :hook (after-init . global-completion-preview-mode)
+ :bind
+ ( :map completion-preview-active-mode-map
+ ("M-n" . completion-preview-next-candidate)
+ ("M-p" . completion-preview-prev-candidate)
+ ("M-<return>" . completion-preview-insert)
+ ("<tab>" . completion-preview-complete))
+ :custom
+ (completion-preview-minimum-symbol-length 2) ; Show the preview already after two symbol characters
+ (completion-preview-exact-match-only nil) ; If t, only show suggestion if there is only one candidate
+ (completion-preview-idle-delay 0.3) ; If non-nil, wait this many idle seconds before displaying preview
+
+ :config
+ (with-eval-after-load 'org
+ ;; Add Org mode's custom 'self-insert-command' to completion-previews
+ (push 'org-self-insert-command completion-preview-commands)
+ )
+ ;; Disable completion preview in Org tables (Emacs 31+)
+ (defun my/detect-org-table ()
+ "Return true if point in Org table."
+ (and (derived-mode-p 'org-mode) (org-at-table-p)))
+ (add-hook 'completion-preview-inhibit-functions
+ #'my/detect-org-table))
+
+(use-package tramp
+ :ensure nil
+ :commands (sudo-find-file sudo-this-file)
+ :bind ("C-c f s" . sudo-find-file)
+ :config
+ (defun sudo-find-file (file)
+ "Open FILE as root."
+ (interactive "FOpen file as root: ")
+ (when (file-writable-p file)
+ (user-error "File is user writeable, aborting sudo"))
+ (find-file (if (file-remote-p file)
+ (concat "/" (file-remote-p file 'method) ":"
+ (file-remote-p file 'user) "@" (file-remote-p file 'host)
+ "|sudo:root@"
+ (file-remote-p file 'host) ":" (file-remote-p file 'localname))
+ (concat "/sudo:root@localhost:" file))))
+ (defun sudoedit ()
+ "Open the current file as root."
+ (interactive)
+ (sudo-find-file (file-truename buffer-file-name)))
+ (setq remote-file-name-inhibit-locks t
+ remote-file-name-inhibit-auto-save-visited t
+ tramp-copy-size-limit (* 1024 1024))
+ (connection-local-set-profile-variables
+ 'remote-direct-async-process '((tramp-direct-async-process . t)))
+ (connection-local-set-profiles
+ '(:application tramp :protocol "scp") 'remote-direct-async-process)
+ (with-eval-after-load 'compile
+ (remove-hook 'compilation-mode-hook
+ #'tramp-compile-disable-ssh-controlmaster-options)))
+
+(use-package project
+ :ensure nil
+ :config
+ (setq project-vc-extra-root-markers '(".project")))
+
+(use-package proced
+ :ensure nil
+ :custom
+ (proced-auto-update-flag 'visible)
+ (proced-enable-color-flag t))
+
+(use-package flyspell
+ :disabled ;; TODO: Remove on Emacs 31
+ :ensure nil
+ :config
+ (flyspell-delay-use-timer t)
+ :hook
+ (text-mode . flyspell-mode)
+ (prog-mode . flyspell-prog-mode))
+
+(use-package hippie-exp
+ :ensure nil
+ :bind ([remap dabbrev-expand] . hippie-expand))
+
+(provide 'emacs-config)