;;; init.el --- Modern Emacs configuration -*- lexical-binding: t -*-
;;; Commentary:
;; Core initialization and package management
;;; Code:
;; Performance and startup optimizations
(setq gc-cons-threshold 100000000) ; 100mb
(setq gc-cons-percentage 0.6)
(add-hook 'focus-out-hook #'garbage-collect)
(setq read-process-output-max (* 1024 1024)) ; 1mb
(setq process-adaptive-read-buffering nil) ; Disable adaptive buffering
;; File handling
;; You already have create-lockfiles nil and backup settings, so skip those
;; Display optimizations
(setq bidi-inhibit-bpa t) ; Disable bidirectional parenthesis
(setq-default bidi-paragraph-direction 'left) ; Disable bidirectional rendering
(setq bidi-display-reordering nil) ; Disable reordering of bidirectional text
(setq inhibit-compacting-font-caches t) ; Don't compact font caches during GC
;; Terminal responsiveness and scrolling behavior
(setq redisplay-skip-fontification-on-input t)
(setq fast-but-imprecise-scrolling t)
(setq echo-keystrokes 0.01)
(setq scroll-conservatively 101)
(setq scroll-margin 0)
(setq scroll-preserve-screen-position nil)
(setq auto-window-vscroll nil)
;; Terminal responsiveness
(setq redisplay-skip-fontification-on-input t)
(setq fast-but-imprecise-scrolling t)
(setq echo-keystrokes 0.01)
;; Minibuffer optimizations (add to your existing completion settings)
(setq enable-recursive-minibuffers t)
(setq read-buffer-completion-ignore-case t)
(setq read-file-name-completion-ignore-case t)
(setq completion-cycle-threshold 3)
(setq completions-detailed t)
;; Basic UI settings without use-package
(menu-bar-mode -1)
(when (fboundp 'tool-bar-mode)
(tool-bar-mode -1))
(when (fboundp 'scroll-bar-mode)
(scroll-bar-mode -1))
(global-eldoc-mode -1)
(delete-selection-mode t)
(save-place-mode t)
;; Basic settings that don't need use-package
(setq inhibit-startup-screen t
use-dialog-box nil
frame-title-format '("Emacs: %f")
icon-title-format "Emacs - %b"
case-fold-search t
column-number-mode t
create-lockfiles nil
current-language-environment "utf-8"
default-input-method "utf-8"
indent-tabs-mode nil
standard-indent 4
large-file-warning-threshold nil)
;; Package setup
(require 'package)
(setq package-archives
'(("gnu" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")))
(setq package-enable-at-startup nil)
(package-initialize)
;; Bootstrap use-package
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
(require 'bind-key)
;; Package list (preserved from original config)
(defvar dws/package-list
'(async
avy
company
company-jedi
diminish
emmet-mode
expand-region
epl
flycheck
go-mode
go-snippets
markdown-mode
magit
multi-term
nginx-mode
org
popup
projectile
python-environment
python-mode
solarized-theme
use-package
web-mode
which-key
vertico
orderless
yaml-mode
yasnippet))
;; Package installation function
(defun dws/install-packages ()
"Install my list of packages."
(interactive)
(unless package-archive-contents
(package-refresh-contents))
(dolist (pkg dws/package-list)
(unless (package-installed-p pkg)
(package-install pkg))))
;; Helper macro for conditional library loading
(defmacro with-library (symbol &rest body)
`(when (require ,symbol nil t)
,@body))
(put 'with-library 'lisp-indent-function 1)
;; UTF-8 configuration
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
(setenv "LANG" "en_US.UTF-8")
;; Path setup
(defvar home-dir (expand-file-name "~"))
(let ((my-paths (list
"/usr/local/go/bin"
"/opt/homebrew/bin"
(concat home-dir "/bin")
(concat home-dir "/python/bin"))))
(dolist (path my-paths)
(add-to-list 'exec-path path)
(setenv "PATH" (concat path path-separator (getenv "PATH")))))
;; Backup settings
(use-package files
:custom
(backup-by-copying nil)
(backup-directory-alist '(("." . "~/.emacs.d/autosaves/")))
(delete-old-versions t)
(kept-new-versions 6)
(kept-old-versions 3))
;; Default simple settings
(setq-default tab-width 4)
(fset 'yes-or-no-p 'y-or-n-p)
;; Load the rest of the configuration
(add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory))
(load "ui-config")
(load "dev-config")
(load "org-config")
(load "shell-config")
(load "keybindings")
;; sometimes yaml still goes back to tabs
(add-hook 'yaml-mode-hook
(lambda ()
(setq indent-tabs-mode nil) ; belt
(setq-local indent-tabs-mode nil) ; and suspenders
(setq yaml-indent-offset 2)))
;; trying to catch when this changes
(add-variable-watcher 'indent-tabs-mode
(lambda (symbol newval operation where)
(message "indent-tabs-mode changed to %s in buffer %s by %s"
newval
(buffer-name where)
operation)))
(provide 'init)
;;; init.el ends here
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(column-number-mode t)
'(custom-safe-themes
'("51ec7bfa54adf5fff5d466248ea6431097f5a18224788d0bd7eb1257a4f7b773" default))
'(tool-bar-mode nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:family "Monaspace Xenon" :foundry "nil" :slant normal :weight regular :height 130 :width normal)))))