From 5e46231fbc3b86cc01659aa2ed85ef3f5b7b592c Mon Sep 17 00:00:00 2001 From: rh17s15 Date: Tue, 24 Mar 2026 02:13:41 +0100 Subject: [PATCH] looked through emacs-bedrock and emacs better-defaults and added approprate stuff --- .emacs | 13 -- .emacs.custom.el | 15 --- custom.el | 21 ++++ init.el | 309 +++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 321 insertions(+), 37 deletions(-) delete mode 100644 .emacs delete mode 100644 .emacs.custom.el diff --git a/.emacs b/.emacs deleted file mode 100644 index 0e2d2ad..0000000 --- a/.emacs +++ /dev/null @@ -1,13 +0,0 @@ -(menu-bar-mode 0) -(tool-bar-mode 0) -(column-number-mode 1) -(scroll-bar-mode 0) -(show-paren-mode 1) -(global-display-line-numbers-mode) - - -(setq display-line-numbers 'relative) - - -;; stopped at 34:00 -;; https://youtu.be/81MdyDYqB-A?si=-4pP_hQlBVvFRF2W&t=2040 diff --git a/.emacs.custom.el b/.emacs.custom.el deleted file mode 100644 index db19e88..0000000 --- a/.emacs.custom.el +++ /dev/null @@ -1,15 +0,0 @@ -(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. - '(custom-safe-themes - '("9c6aa7eb1bde73ba1142041e628827492bd05678df4d9097cda21b1ebcb8f8b9" - default)) - '(package-selected-packages '(dracula-theme))) -(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. - ) diff --git a/custom.el b/custom.el index e69de29..e24a173 100644 --- a/custom.el +++ b/custom.el @@ -0,0 +1,21 @@ +;;; -*- lexical-binding: t -*- +(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. + '(custom-safe-themes + '("9c6aa7eb1bde73ba1142041e628827492bd05678df4d9097cda21b1ebcb8f8b9" + default)) + '(package-selected-packages + '(cape company consult corfu-terminal dracula-theme eat + emacs-everywhere flycheck-languagetool hl-todo kind-icon + magit marginalia multiple-cursors orderless paredit + rainbow-mode vertico)) + '(safe-local-variable-directories '("/home/mia/.emacs.d/"))) +(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. + ) diff --git a/init.el b/init.el index 57531bc..6fa569c 100644 --- a/init.el +++ b/init.el @@ -1,19 +1,310 @@ +;; add melpa +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) +(package-initialize) + +;; remove menu bar, tool bar, scroll bar (menu-bar-mode 0) (tool-bar-mode 0) -(column-number-mode 1) (scroll-bar-mode 0) + +;; highlight parens when on them (show-paren-mode 1) + +;; better line numbers (global-display-line-numbers-mode) (setq display-line-numbers 'relative) -;; (message (mapconcat 'identity (list "b" "asdf") "/")) +;; y or n instead of yes or no +(setopt use-short-answers t) -(message (replace-regexp-in-string "/[^/]+$" "/custom.el" user-init-file)) +;; dynamic loading of file in init dir to put custom +(setq custom-file (replace-regexp-in-string "/[^/]+$" "/custom.el" user-init-file)) +(load custom-file) -;; (setq custom-file "~/.emacs.d/custom.el") -;; (load custom-file) -;; initially wanted to load theme through custom, i think below is cleaner though -(use-package dracula-theme :ensure t :config (load-theme 'dracula t)) +;; enable dracula theme +(use-package dracula-theme :ensure t :config (load-theme 'dracula)) -;; stopped at 34:00 -;; https://youtu.be/81MdyDYqB-A?si=-4pP_hQlBVvFRF2W&t=2040 +;; add time in modeline +(setopt display-time-format "%a %d %T") +(setopt display-time-interval 1) +(display-time-mode) +;; add column number in modeline +(column-number-mode 1) + +;; add which key +(use-package which-key :ensure t :hook after-init) +(which-key-mode) + +;; install and add hook(s) for paredit mode +(use-package paredit :ensure t :hook after-init) + +(defun turn-on-paredit () + (interactive) + (paredit-mode)) + +(add-hook 'emacs-lisp-mode-hook 'turn-on-paredit) + +(use-package emacs-everywhere :ensure t :defer t :hook after-init) + +;; --- from better-defaults --- +;; ibuffer as default buffer list +(global-set-key (kbd "C-x C-b") 'ibuffer) + +;; regex isearches as default +(global-set-key (kbd "C-s") 'isearch-forward-regexp) +(global-set-key (kbd "C-r") 'isearch-backward-regexp) +(global-set-key (kbd "C-M-s") 'isearch-forward) +(global-set-key (kbd "C-M-r") 'isearch-backward) + +;; apropos? +(setq apropos-do-all t) + +;; ignore case for file name, buffer name, competion +(setq read-file-name-completion-ignore-case t) +(setq read-buffer-completion-ignore-case t) +(setq completion-ignore-case t) + +;; --- from emacs bedrock --- + +;; Automatically reread from disk if the underlying file changes +(setopt auto-revert-avoid-polling t) +;; Some systems don't do file notifications well; see +;; https://todo.sr.ht/~ashton314/emacs-bedrock/11 +(setopt auto-revert-interval 5) +(setopt auto-revert-check-vc-info t) +(global-auto-revert-mode) + + +;; Move through windows with Ctrl- +(windmove-default-keybindings 'control) ; You can use other modifiers here + +;; Fix archaic defaults +(setopt sentence-end-double-space nil) + +;; magit <3 +(use-package magit + :ensure t + :bind (("C-x g" . magit-status))) + +;; (add-hook 'prog-mode 'electric-pair-mode) + + +;; completion stuff + +;; Vertico: better vertical completion for minibuffer commands +(use-package vertico + :ensure t + :init + ;; You'll want to make sure that e.g. fido-mode isn't enabled + (vertico-mode)) + +(use-package vertico-directory + :ensure nil + :after vertico + :bind (:map vertico-map + ("M-DEL" . vertico-directory-delete-word))) + +(use-package consult + :ensure t + :bind ( + ;; Drop-in replacements + ("C-x b" . consult-buffer) ; orig. switch-to-buffer + ("M-y" . consult-yank-pop) ; orig. yank-pop + ;; Searching + ("M-s r" . consult-ripgrep) + ("M-s l" . consult-line) ; Alternative: rebind C-s to use + ("M-s s" . consult-line) ; consult-line instead of isearch, bind + ("M-s L" . consult-line-multi) ; isearch to M-s s + ("M-s o" . consult-outline) + ;; Isearch integration + :map isearch-mode-map + ("M-e" . consult-isearch-history) ; orig. isearch-edit-string + ("M-s e" . consult-isearch-history) ; orig. isearch-edit-string + ("M-s l" . consult-line) ; needed by consult-line to detect isearch + ("M-s L" . consult-line-multi) ; needed by consult-line to detect isearch + ) + :config + ;; Narrowing lets you restrict results to certain groups of candidates + (setq consult-narrow-key "<")) + +;; Vertico: better vertical completion for minibuffer commands +(use-package vertico + :ensure t + :init + ;; You'll want to make sure that e.g. fido-mode isn't enabled + (vertico-mode)) + +(use-package vertico-directory + :ensure nil + :after vertico + :bind (:map vertico-map + ("M-DEL" . vertico-directory-delete-word))) + +;; Marginalia: annotations for minibuffer +(use-package marginalia + :ensure t + :config + (marginalia-mode)) + +;; Corfu: Popup completion-at-point +(use-package corfu + :ensure t + :init + (global-corfu-mode) + :bind + (:map corfu-map + ("SPC" . corfu-insert-separator) + ("C-n" . corfu-next) + ("C-p" . corfu-previous))) + +;; Part of corfu +(use-package corfu-popupinfo + :after corfu + :ensure nil + :hook (corfu-mode . corfu-popupinfo-mode) + :custom + (corfu-popupinfo-delay '(0.25 . 0.1)) + (corfu-popupinfo-hide nil) + :config + (corfu-popupinfo-mode)) + +;; Make corfu popup come up in terminal overlay +(use-package corfu-terminal + :if (not (display-graphic-p)) + :ensure t + :config + (corfu-terminal-mode)) + +;; Fancy completion-at-point functions; there's too much in the cape package to +;; configure here; dive in when you're comfortable! +(use-package cape + :ensure t + :init + (add-to-list 'completion-at-point-functions #'cape-dabbrev) + (add-to-list 'completion-at-point-functions #'cape-file)) + +;; Pretty icons for corfu +(use-package kind-icon + :if (display-graphic-p) + :ensure t + :after corfu + :config + (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter)) + +;; Orderless: powerful completion style +(use-package orderless + :ensure t + :config + (setq completion-styles '(orderless))) + + + + +;; highlight todo +(use-package hl-todo :ensure t :defer t :hook (prog-mode . hl-todo-mode)) + +(setq hl-todo-keyword-faces + '(("TODO" . "#FF0000") + ("FIXME" . "#FF0000") + ("DEBUG" . "#A020F0") + ("GOTCHA" . "#FF4500") + ("STUB" . "#1E90FF"))) +(add-hook 'after-init-hook 'hl-todo-mode) + +;; with magit +(with-eval-after-load 'magit + (add-hook 'magit-log-wash-summary-hook + #'hl-todo-search-and-highlight t) + (add-hook 'magit-revision-wash-message-hook + #'hl-todo-search-and-highlight t)) + + ;; make color codes be highlighted in their color +(use-package rainbow-mode :ensure t :defer t :hook (prog-mode . rainbow-mode)) +(add-hook 'after-init-hook 'rainbow-mode) + + +;; doesnt work yet? +;; it should only do these when ispell is loaded +;; idk +;; (eval-after-load "ispell" +;; '(progn +;; (setq ispell-really-hunspell) +;; (setq ispell-program-name "hunspell") +;; (setq ispell-dictionary "en_US,de_DE") +;; (ispell-set-spellchecker-params) +;; (ispell-hunspell-add-multi-dic "en_US,de_DE"))) + + + + + +(use-package flycheck :ensure t :defer t :hook after-init) +;; (use-package flycheck-languagetool +;; :ensure t +;; :hook (text-mode . flycheck-languagetool-setup) +;; :init +;; (setq flycheck-languagetool-server-jar "~/.languagetool-server.jar")) + + +(use-package company :ensure t :defer t :hook after-init) +(add-hook 'after-init-hook 'global-company-mode) + + +;;; multiple cursors +(use-package multiple-cursors + :ensure t + :defer t + :hook after-init + :bind ( + ( "C-S-c" . mc/edit-lines) + ( "C->" . mc/mark-next-like-this) + ( "C-<" . mc/mark-previous-like-this) + ( "C-c C-<" . mc/mark-all-like-this) + ( "C-\"" . mc/skip-to-next-like-this) + ( "C-:" . mc/skip-to-previous-like-this) + ) + ) + + +;; make emacs remember last session +(setq save-place-file (concat user-emacs-directory ".saveplace")) +;; (setq desktop-dirname (concat user-emacs-directory ".desktop.d")) +;; (setq-default save-place t) +;; (require 'saveplace) +(save-place-mode 1) +(desktop-save-mode 1) + +(setq recentf-save-file (concat user-emacs-directory ".recentf")) +;; Save history of minibuffer +(savehist-mode) +(setq savehist-file (concat user-emacs-directory ".history")) + + +;; Helpful resources: +;; +;; - https://www.masteringemacs.org/article/seamlessly-merge-multiple-documentation-sources-eldoc + +(use-package eglot + ;; no :ensure t here because it's built-in + ;; Configure hooks to automatically turn-on eglot for selected modes + ; :hook + ; (((python-mode ruby-mode elixir-mode) . eglot-ensure)) + :custom + (eglot-send-changes-idle-time 0.1) + (eglot-extend-to-xref t) ; activate Eglot in referenced non-project files + :config + (fset #'jsonrpc--log-event #'ignore) ; massive perf boost---don't log every event + ;; Sometimes you need to tell Eglot where to find the language server + ; (add-to-list 'eglot-server-programs + ; '(haskell-mode . ("haskell-language-server-wrapper" "--lsp"))) + ) + +(with-eval-after-load 'eglot + (add-to-list 'eglot-server-programs + '(text-mode . ("harper-ls" "--stdio")) + '(markdown-mode . ("harper-ls" "--stdio")) + )) + +;; flycheck told me to do this: +(provide 'init) +;;; init.el ends here