Files
emacs/init.el

239 lines
7.1 KiB
EmacsLisp

;; General Config --------------------------------------------------------------
(setq inhibit-startup-message t) ;; turn off splash screen
(scroll-bar-mode -1) ;; disable scroll bar
(tool-bar-mode -1) ;; disable toolbar
(tooltip-mode -1) ;; disable tooltips
(menu-bar-mode -1) ;; disable menu bar
(setq visible-bell t) ;; visual indicator instead of noise on bells
;;line numbers - relative
(setq display-line-numbers-type 'relative)
(global-display-line-numbers-mode)
;;disable file backups
(setq make-backup-files nil)
(setq create-lockfiles nil)
;; always follow symlinks without asking
(setq vc-follows-symlinks t
find-file-visit-truename t)
;; Package Manager -------------------------------------------------------------
(require 'package)
(setq package-archives '(("melpa" . "https://melpa.org/packages/")
("elpa" . "https://elpa.gnu.org/packages/")))
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
;; Style/Theme stuff ----------------------------------------------------------
;; Theme
(use-package gruvbox-theme
:ensure t
:config
(load-theme 'gruvbox-dark-hard t))
;;icons are required for modeline
(use-package all-the-icons
:ensure t
:if (display-graphic-p))
;;change delimeters to different colors to help identify them
(use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode))
;; Replace the line at the bottom with something more stylish
(use-package doom-modeline
:ensure t
:init (doom-modeline-mode 1)
:config
(setq doom-modeline-height 15))
;; Completion/Search/Navigation Shenanigans -----------------------------------
;;completions
(use-package vertico
:ensure t
:init
(vertico-mode))
;;completion commands
(use-package consult
:ensure t
:bind (("C-x b" . consult-buffer)
("C-s" . consult-line)
("M-y" . consult-yank-pop)))
;;fuzzy matching
(use-package orderless
:ensure t
:config
(setq completion-styles '(orderless basic)
completion-category-defaults nil))
;;minibuffer annotations
(use-package marginalia
:ensure t
:init
(marginalia-mode))
;;actions on minibuffer candidates
(use-package embark
:ensure t
:bind (("C-." . embark-act)
("M-." . embark-dwim)))
(use-package embark-consult
:ensure t)
(use-package which-key
:init (which-key-mode)
:diminish which-key-mode
:config
(setq which-key-idle-delay 1))
;; Key Binding Configuration ---------------------------------------------------
;; Make ESC quit prompts
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
(use-package general
:config
(general-create-definer rh/leader-keys
:keymaps '(normal insert visual emacs)
:prefix "SPC"
:global-prefix "C-SPC")
(rh/leader-keys
"t" '(:ignore t :which-key "toggles")
"tt" '(consult-theme :which-key "choose theme")
"f" '(:ignore t :which-key "files")
"ff" '(find-file :which-key "find file")
"fr" '(consult-recent-file :which-key "recent files")
"fb" '(consult-buffer :which-key "switch buffer")
"o" '(:ignore t :which-key "org")
"oa" '(org-agenda :which-key "agenda")
"oc" '(org-capture :which-key "capture")
"ol" '(org-store-link :which-key "store link")
"oi" '(org-insert-link :which-key "insert link")
"ot" '(org-todo :which-key "cycle todo")
"os" '(org-schedule :which-key "schedule")
"od" '(org-deadline :which-key "deadline")
"oT" '(org-time-stamp :which-key "timestamp")
"op" '(org-priority :which-key "priority")
"ox" '(org-toggle-checkbox :which-key "toggle checkbox")
"o-" '(org-ctrl-c-minus :which-key "insert item/cycle list type")
"or" '(org-refile :which-key "refile")))
(use-package evil
:init
(setq evil-want-integration t)
(setq evil-want-keybinding nil)
(setq evil-want-C-u-scroll t)
(setq evil-want-C-i-jump nil)
:config
(evil-mode 1)
(define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state)
(define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char-and-join)
;; Use visual line motions even outside of visual-line-mode buffers
(evil-global-set-key 'motion "j" 'evil-next-visual-line)
(evil-global-set-key 'motion "k" 'evil-previous-visual-line)
(evil-set-initial-state 'messages-buffer-mode 'normal)
(evil-set-initial-state 'dashboard-mode 'normal))
(use-package evil-collection
:after evil
:config
(evil-collection-init))
(use-package hydra)
(defhydra hydra-text-scale (:timeout 4)
"scale text"
("j" text-scale-increase "in")
("k" text-scale-decrease "out")
("f" nil "finished" :exit t))
(rh/leader-keys
"ts" '(hydra-text-scale/body :which-key "scale text"))
;; Projectile Configuration ----------------------------------------------------
(use-package projectile
:diminish projectile-mode
:config (projectile-mode)
:bind-keymap
("C-c p" . projectile-command-map)
:init
(when (file-directory-p "~/src")
(setq projectile-project-search-path '("~/src")))
(setq projectile-switch-project-action #'projectile-dired))
(use-package consult-projectile
:ensure t
:bind (("C-c h" . consult-projectile)))
;; Magit Configuration ---------------------------------------------------------
(use-package magit
:commands (magit-status magit-get-current-branch)
:bind (("C-x g" . magit-status)
("C-x M-g" . magit-dispatch)
("C-c M-g" . magit-file-dispatch))
:custom
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)
;; Show refined diffs for current hunk only (better performance)
(magit-diff-refine-hunk t)
;; Don't automatically revert file-visiting buffers
(magit-auto-revert-mode nil)
;; Use default terminal for SSH (if relevant)
(magit-process-find-password-functions '(magit-process-password-auth-source)))
;; IDK what this stuff is but it shows up automatically ------------------------
(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.
'(package-selected-packages
'(ag all-the-icons company consult-projectile dap-mode doom-modeline
embark-consult evil-collection flycheck general gruvbox-theme
helpful hydra lsp-mode lsp-ui magit marginalia
modern-cpp-font-lock orderless org-bullets org-modern
rainbow-delimiters slime slime-company smartparens treemacs
treemacs-projectile vertico yasnippet yasnippet-snippets)))
(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.
)
;; Org Mode Configuration ------------------------------------------------------
(defun rh/org-mode-setup ()
(org-indent-mode)
(visual-line-mode 1))
(use-package org
:hook (org-mode . rh/org-mode-setup)
:config
(setq org-agenda-files (directory-files-recursively "~/org" "\\.org$")))
;; Development Environment ------------------------------------------------------
(load (expand-file-name "dev-settings.el" user-emacs-directory))