Add emacs configuration

This commit is contained in:
caem 2025-05-19 00:08:33 +02:00
parent 226756c745
commit 97a02dcd32
Signed by: caem
GPG key ID: 69A830D03203405F
5 changed files with 213 additions and 0 deletions

View file

@ -0,0 +1,10 @@
;;; early-init.el -*- lexical-binding: t; -*-
;; Copyright © 2025 caem
;; Author: caem <me@caem.dev>
;; URL: https://git.caem.dev/caem/dotfiles
;; Code:
;;; early-init.el ends here

149
.config/emacs/init.el Normal file
View file

@ -0,0 +1,149 @@
;;; init.el -*- lexical-binding: t; -*-
;; Copyright © 2025 caem
;; Author: caem <me@caem.dev>
;; URL: https://git.caem.dev/caem/dotfiles
;; Code:
;; === Package Manager ===
(require 'package)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")
("gnu" . "https://elpa.gnu.org/packages/")))
(package-initialize)
;; === Littering ===
(setq custom-file "~/.emacs.d/custom.el"
backup-by-copying t
backup-directory-alist '(("." . "~/.emacs.d/backups")))
;; === User Interface ===
(setq inhibit-splash-screen t
ring-bell-function 'ignore)
(tool-bar-mode 0)
(menu-bar-mode 0)
(scroll-bar-mode 0)
(tooltip-mode 0)
;; === Appearance ===
(global-hl-line-mode t)
(use-package rainbow-delimiters
:ensure t
:hook (prog-mode . rainbow-delimiters-mode))
(if (display-graphic-p)
(progn
(let ((font-size 11))
(add-to-list 'default-frame-alist
`(font . ,(concat
(cond
((find-font (font-spec :name "Adwaita Mono Nerd Font"))
"Adwaita Mono Nerd Font")
((find-font (font-spec :name "Adwaita Mono"))
"Adwaita Mono")
(t (let ((font (font-get-system-font)))
(if (eq (type-of font) 'font-spec)
(font-get font 'name)
(replace-regexp-in-string " [0-9]+$" "" font)))))
(format "-%d" font-size)))))
(let ((opacity 95))
(set-frame-parameter nil 'alpha-background opacity)
(add-to-list 'default-frame-alist `(alpha-background . ,opacity)))
(use-package darktooth-theme
:ensure t
:config
(load-theme 'darktooth-dark t)
(set-face-background 'hl-line "#262626")))
(progn
(set-face-attribute 'hl-line nil :background
(let ((bg (face-attribute 'default ':background)))
(if (string= "unspecified-bg" bg)
"#1c1c1c"
(format "#%x" (+ 1118481 (string-to-number
(substring bg 1) 16))))))))
;; === Scrolling ===
(setq display-line-numbers-type 'relative
compilation-scroll-output t
scroll-step 1
scroll-margin 8)
(global-display-line-numbers-mode t)
;; === Searching ===
(use-package helm
:ensure t
:bind (("M-x" . helm-M-x)
("C-x C-f" . helm-find-files))
:config
(require 'helm-autoloads)
(require 'helm)
(helm-mode 1))
;; === Treesitter ===
(use-package tree-sitter
:ensure t)
(use-package tree-sitter-langs
:ensure t)
(global-tree-sitter-mode)
(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode)
;; === Completions ===
(use-package lsp-mode
:ensure t
:init (setq lsp-keymap-prefix "C-c l")
:hook (prog-mode . lsp)
:commands lsp)
(use-package lsp-ui
:ensure t
:commands lsp-ui-mode)
(use-package company
:ensure t
:hook (after-init-hook . global-company-mode))
;; --- Lsp servers ---
(use-package elsa
:ensure t
:config (elsa-lsp-register))
(use-package lsp-pyright
:ensure t
:custom (lsp-pyright-langserver-command "basedpyright")
:hook (python-mode . (lambda ()
(require 'lsp-pyright)
(lsp))))
;; === Major Modes ===
(setq-default indent-tabs-mode nil)
;; --- Term Mode ---
(defun reset-scroll-config ()
(setq-local scroll-margin 0))
(add-hook 'term-mode-hook #'reset-scroll-config)
;; --- Lisp Modes ---
(use-package paredit
:ensure nil
:hook
((emacs-lisp-mode . enable-paredit-mode)
(scheme-mode . enable-paredit-mode))
:config
(show-paren-mode 1)
(setq show-paren-style 'parenthesis))
(add-hook 'emacs-lisp-mode-hook (lambda () (setq tab-width 2)))
(add-hook 'scheme-mode-hook (lambda () (setq tab-wdith 2)))
;; --- C Mode ---
(add-hook 'c-mode-hook (lambda () (setq tab-width 4)))
;; --- Python Mode ---
(add-hook 'python-mode-hook (lambda () (setq tab-width 4)))
;;; init.el ends here

22
.emacs.d/early-init.el Normal file
View file

@ -0,0 +1,22 @@
;;; early-init.el -*- lexical-binding: t; -*-
;; Copyright © 2025 caem
;; Author: caem <me@caem.dev>
;; URL: https://git.caem.dev/caem/dotfiles
;; Commentary:
;; This is a stub early-init file to lead the actual early-init file of my emacs
;; configuration.
;;
;; Refer to init.el in the same directory as this for the rationale behind for
;; having this file where it is and why it is the way that it is.
;; Code:
(require 'xdg)
(load (expand-file-name "emacs/early-init.el" (xdg-config-home)))
;;; early-init.el ends here

30
.emacs.d/init.el Normal file
View file

@ -0,0 +1,30 @@
;;; init.el -*- lexical-binding: t; -*-
;; Copyright © 2025 caem
;; Author: caem <me@caem.dev>
;; URL: https://git.caem.dev/caem/dotfiles
;; Commentary:
;; This is a stub init file to load the actual init file of my emacs
;; configuration.
;;
;; The reason they're seperated is that this allows me to have
;; emacs think that my configuration resides in the ~/.emacs.d directory when in
;; reality all my files are located in ~/.config/emacs. This prevents all the
;; 9 million different things that want to write to my configuration directory
;; from actually writing in my configuration directory. All other ways, even
;; chaning the user-emacs-directory and setting up no-littering are not remotely
;; enough to prevent stuff shitting all over my configuration directory so this
;; is esentially my last resort.
;;
;; I would've much preferred to place this in to
;; ~/.local/share/emacs instead but it's unfortunately not possible so it has to
;; reside in ~/.emacs.d due to load priorities inside of emacs.
;; Code:
(load (expand-file-name "emacs/init.el" (xdg-config-home)))
;;; init.el ends here

2
.gitattributes vendored Normal file
View file

@ -0,0 +1,2 @@
setup linguist-vendored
scripts/** linguist-vendored