dotfiles for my doom-emacs, bash, sway, vim and whatnot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

301 lines
7.5 KiB

;; Customizations are stored here
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
(load custom-file))
(setq backup-directory-alist '(("." . "~/.emacs.d/backup"))
backup-by-copying t ; Don't delink hardlinks
version-control t ; Use version numbers on backups
delete-old-versions t ; Automatically delete excess backups
kept-new-versions 20 ; how many of the newest versions to keep
kept-old-versions 5 ; and how many of the old
)
;; Kickstart package management
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
(package-initialize)
;; use-package to simplify the config file
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure 't)
(defun my/reload-emacs nil
"Reload Emacs configuration."
(interactive)
(load-file "~/.emacs.d/init.el")
(message "Emacs was reloaded."))
;; ==========
;; MINIMALISM
(setq inhibit-startup-message t)
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode -1)
(setq ring-bell-function 'ignore)
(setq scroll-step 1) ;; keyboard scroll one line at a time
(defalias 'yes-or-no-p 'y-or-n-p)
(global-display-line-numbers-mode)
;; =====
;; THEME
(use-package doom-themes
:config (load-theme 'doom-gruvbox t))
;; ================
;; SAVING MY WRISTS
(use-package general)
(use-package evil
:init
(setq evil-want-keybinding nil)
(evil-mode 1))
;; ==========================
;; TRAMP MAGIC FOR CONTAINERS
(require 'tramp)
(push
(cons
"toolbox"
'((tramp-login-program "flatpak-spawn --host toolbox")
(tramp-login-args (("enter" "-c") ("%h")))
(tramp-remote-shell "/bin/sh")
(tramp-remote-shell-args ("-i") ("-c"))))
tramp-methods)
;; (use-package toolbox-tramp
;; :straight (toolbox-tramp :type git
;; :host github
;; :repo "fejfighter/toolbox-tramp"))
;; COMPLETION
(use-package vertico
:init
(vertico-mode))
(use-package orderless
:ensure t
:custom
(completion-styles '(orderless basic))
(completion-category-overrides '((file (styles basic partial-completion)))))
(use-package company
:config (global-company-mode))
;; ===========
;; PROGRAMMING
(use-package eglot
:hook (prog-mode . eglot-ensure))
(electric-pair-mode t)
(setq-default indent-tabs-mode nil)
(add-hook 'prog-mode-hook #'flymake-mode)
(general-define-key :prefix-map 'project-prefix-map "E" 'flymake-show-project-diagnostics)
(setq help-at-pt-display-when-idle t)
(use-package flymake-diagnostic-at-point
:after flymake
:config
(add-hook 'flymake-mode-hook #'flymake-diagnostic-at-point-mode))
(use-package editorconfig
:config
(editorconfig-mode 1))
(use-package magit
:config
(general-define-key :prefix-map 'project-prefix-map "m" 'magit-project-status))
(use-package evil-collection
:after evil
:config
(evil-collection-init))
(use-package yasnippet)
(use-package yasnippet-snippets)
(add-hook 'prog-mode-hook #'yas-minor-mode)
;; ================
;; LANGUAGE SUPPORT
(use-package rust-mode)
(use-package cargo)
(use-package svelte-mode)
(add-to-list 'eglot-server-programs '(svelte-mode . ("svelteserver" "--stdin")))
;; =======
;; WRITING
;; find aspell and hunspell automatically
(cond
;; try hunspell at first
;; if hunspell does NOT exist, use aspell
((executable-find "hunspell")
(setq ispell-program-name "hunspell")
(setq ispell-local-dictionary "en_US")
(setq ispell-local-dictionary-alist
;; Please note the list `("-d" "en_US")` contains ACTUAL parameters passed to hunspell
;; You could use `("-d" "en_US,en_US-med")` to check with multiple dictionaries
'(("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_US") nil utf-8)))
;; new variable `ispell-hunspell-dictionary-alist' is defined in Emacs
;; If it's nil, Emacs tries to automatically set up the dictionaries.
(when (boundp 'ispell-hunspell-dictionary-alist)
(setq ispell-hunspell-dictionary-alist ispell-local-dictionary-alist)))
((executable-find "aspell")
(setq ispell-program-name "aspell")
;; Please note ispell-extra-args contains ACTUAL parameters passed to aspell
(setq ispell-extra-args '("--sug-mode=ultra" "--lang=en_US"))))
;; ======================
;; WHAT BUTTON DO I PRESS
(use-package which-key
:config
(which-key-mode))
;; ======================
;; Making stuff look nice
(use-package doom-modeline
:config (doom-modeline-mode 1))
(tab-bar-mode)
(general-define-key
:prefix-map 'tab-prefix-map
"<tab>" 'tab-switch
"n" 'tab-new
"k" 'tab-close)
(defun my/org-mode-setup ()
(org-indent-mode))
(use-package org
:hook (org-mode . my/org-mode-setup)
:config (my/org-mode-setup))
(use-package org-bullets
:after org
:hook (org-mode . org-bullets-mode))
(setq org-todo-keywords
'((sequence "TODO(t)" "STRT(s)" "|" "DONE(d)")
(sequence "HOLD(h)")
(sequence "|" "KILL(k)")))
(setq org-todo-keyword-faces
'(("TODO" . "yellow") ("STRT" . "green") ("HOLD" . "yellow") ("KILL" . "red")))
(use-package erc-hl-nicks)
;; ============
;; RSS IN EMACS
(use-package elfeed-org)
(use-package elfeed
:init (elfeed-org))
(setq rmh-elfeed-org-files (list "~/org/elfeed.org"))
;; TTRPGs
(use-package org-d20)
;; ========
;; KEY MAPS
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
(general-create-definer my-leader-def
;; :prefix my-leader
:prefix "SPC")
(general-create-definer my-local-leader-def
;; :prefix my-local-leader
:prefix "SPC m")
(my-leader-def
:states '(normal visual)
:keymaps 'override
"w" '(:keymap evil-window-map :which-key "window")
"p" '(:keymap project-prefix-map :which-key "project")
"<tab>" '(:keymap tab-prefix-map :which-key "tabs")
"." 'find-file
"SPC" 'project-find-file
"b" '(:ignore t :which-key "buffer")
"b k" 'kill-current-buffer
"b b" 'persp-switch-to-buffer*
"c" '(:ignore t :which-key "code")
"c a" 'eglot-code-actions
"c b" 'magit-blame
"c e" 'flymake-show-buffer-diagnostics
"c n" 'flymake-goto-next-error
"c p" 'flymake-goto-previous-error
"c r" 'eglot-rename
"s" '(:ignore t :which-key "snippets")
"s i" 'yas-insert-snippet
"+" 'text-scale-increase
"-" 'text-scale-decrease
"X" 'org-capture)
(my-local-leader-def 'normal org-mode-map
"t" 'org-todo
"c" '(:ignore t :which-key "clock")
"c i" 'org-clock-in
"c o" 'org-clock-out)
(general-define-key
:states 'normal
"gc" 'comment-line
"K" 'eldoc)
(general-define-key
:states 'normal
"gc" 'comment-line
"K" 'eldoc)
(general-define-key
:states 'insert
"<tab>" 'indent-for-tab-command)
(general-def 'normal org-mode-map
"<<" 'org-promote-subtree
">>" 'org-demote-subtree
"<tab>" 'org-cycle)
(setq org-default-notes-file "~/org/todo.org")
(setq org-capture-templates
'(("t" "Todo" entry (file+headline "~/org/todo.org" "Inbox")
"* TODO %?\n %i\n %a")
("n" "Note" entry (file+datetree "~/org/notes.org")
"* %?\n")))
(defun my/elfeed-mark-all-as-read ()
"Mark all entries in Elfeed as read."
(interactive)
(mark-whole-buffer)
(elfeed-search-untag-all-unread))
(general-def 'normal elfeed-search-mode-map
"RET" 'elfeed-search-show-entry
"U" 'elfeed-update
"b" 'elfeed-search-browse-url
"/" 'elfeed-search-set-filter
"a" 'elfeed-search-untag-all-unread
"A" 'my/elfeed-mark-all-as-read)