From 096dc8f0f3bb93c71175cb5cfeb54802c30eaab7 Mon Sep 17 00:00:00 2001 From: Jack Foltz Date: Mon, 15 Oct 2018 18:28:02 -0400 Subject: [PATCH] Add emacs dotfiles --- lain/.emacs.d/config.org | 710 +++++++++++++++++++++++++++++++++++++++++++++++ lain/.emacs.d/init.el | 22 ++ 2 files changed, 732 insertions(+) create mode 100644 lain/.emacs.d/config.org create mode 100755 lain/.emacs.d/init.el diff --git a/lain/.emacs.d/config.org b/lain/.emacs.d/config.org new file mode 100644 index 0000000..2eab325 --- /dev/null +++ b/lain/.emacs.d/config.org @@ -0,0 +1,710 @@ +* Emacs Config +** Font +Set the font to something nice that will display ligntures +#+BEGIN_SRC emacs-lisp +(add-to-list 'default-frame-alist '(font . "Fira Code 12")) +(set-face-attribute 'default t :font "Fira Code 12") +#+END_SRC + +** Customize file +Makes it so the customize data isn't schlunked in my init.el +#+BEGIN_SRC emacs-lisp +(setq custom-file (concat user-emacs-directory "_customize.el")) +(load custom-file t) +#+END_SRC + +** Remove menu bar +Disable the useless cruft at the top of the screen +#+BEGIN_SRC emacs-lisp +(menu-bar-mode 0) +(tool-bar-mode 0) +(scroll-bar-mode -1) +#+END_SRC + +** Show matching parenthesis +Shows matching parenthesis +#+BEGIN_SRC emacs-lisp +(require 'paren) +(set-face-background 'show-paren-match (face-background 'default)) +(set-face-foreground 'show-paren-match "#def") +(set-face-attribute 'show-paren-match nil :weight 'extra-bold) +(setq show-paren-delay 0) +(show-paren-mode) +#+END_SRC + +** Show columns +#+BEGIN_SRC emacs-lisp +(setq column-number-mode t) +#+END_SRC + +** Transparency +Sets the window's transparency. +The first number in the alpha section applies when the window is +active, the second when it's inactive. +#+BEGIN_SRC emacs-lisp +(set-frame-parameter (selected-frame) 'alpha 85) +(add-to-list 'default-frame-alist '(alpha . 85)) +#+END_SRC + +** Scrolling +#+BEGIN_SRC emacs-lisp +(setq scroll-conservatively 100) ;; don't scroll a metric boatload when bottom is hit +#+END_SRC + +** Disable bell +Shut up, emacs. +#+BEGIN_SRC emacs-lisp +(setq ring-bell-function 'ignore) +#+END_SRC + +** Show relative line numbers +#+BEGIN_SRC emacs-lisp +(unless (version< emacs-version "26.1") +(setq display-line-numbers-type 'relative) +(setq linum-format " %3d ") +(global-display-line-numbers-mode t)) +#+END_SRC + +** y or n prompts +Make yes-or-no prompts ask for y or n instead +#+BEGIN_SRC emacs-lisp +(defalias 'yes-or-no-p 'y-or-n-p) +#+END_SRC + +** Tabs are spaces?! +#+BEGIN_SRC emacs-lisp +(setq-default indent-tabs-mode nil) +(setq-default tab-width 4) +(setq indent-line-function 'insert-tab) +#+END_SRC + +** Keep backup files out of the way +By default, emacs makes files like =file~= and =#file#= and clutters up +my projects. Instead, store them in =/tmp=! +#+BEGIN_SRC emacs-lisp +(setq backup-directory-alist + `((".*" . ,temporary-file-directory))) +(setq auto-save-file-name-transforms + `((".*" ,temporary-file-directory t))) +#+END_SRC +* Package Repo Config +** Repo Location +Let's start by configuring the repositories +#+BEGIN_SRC emacs-lisp + (require 'package) + + (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/") + ("marmalade" . "https://marmalade-repo.org/packages/") + ("melpa-stable" . "https://stable.melpa.org/packages/") + ("melpa" . "https://melpa.org/packages/") + ("org" . "https://orgmode.org/elpa/"))) + (setq package-enable-at-startup nil) + + (package-initialize) +#+END_SRC + +** use-package +use-package for installing packages +https://github.com/jwiegley/use-package +#+BEGIN_SRC emacs-lisp +(unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package)) + +(eval-when-compile + (require 'use-package)) + +(setq use-package-compute-statistics t) +(setq use-package-always-ensure t) +(setq use-package-always-pin "melpa-stable") +(setq use-package-verbose t) +#+END_SRC + +* General Packages Configuration +** Modeline cleanup +Adds support for =:diminish= in use-package declarations, +basically hides a mode from the modeline. +#+BEGIN_SRC emacs-lisp +(use-package diminish) +#+END_SRC + +** Keybind completion +Pops up a buffer that helps you navigate and complete commands +#+BEGIN_SRC emacs-lisp +(use-package which-key + :diminish + :config + (which-key-mode)) +#+END_SRC + +** Keybind Manager +General manages my keybindings. + +#+BEGIN_SRC emacs-lisp +(use-package general + :pin melpa) +#+END_SRC + +*** Leader definitions +Create a leader key, like the \ in vim. +In this case, =SPC= is used as a leader. Following the leader, +different buttons bring you to different options. +See [[https://github.com/noctuid/general.el#which-key-integration][here]] for which-key integration information + +#+BEGIN_SRC emacs-lisp +(general-create-definer foltz-leader-def + :keymaps 'override + :states 'normal + :prefix "SPC" + "m" '(:ignore t :which-key "major-mode...") + "o" '(:ignore t :which-key "org-mode...") + "g" '(:ignore t :which-key "git...") + "h" '(:ignore t :which-key "help...") + "b" '(:ignore t :which-key "buffer...") + "w" '(:ignore t :which-key "window...") + "f" '(:ignore t :which-key "file...")) +#+END_SRC + +**** m - major-modes +#+BEGIN_SRC emacs-lisp +(general-create-definer foltz-major-def + :states 'normal + :prefix "SPC m") +#+END_SRC + +**** o - org-mode +#+BEGIN_SRC emacs-lisp +(general-create-definer foltz-org-def + :keymaps 'override + :states +'normal + :prefix "SPC o") +#+END_SRC + +**** g - git +#+BEGIN_SRC emacs-lisp +(general-create-definer foltz-git-def + :states 'normal + :keymaps 'override + :prefix "SPC g") +#+END_SRC + +**** h - help +#+BEGIN_SRC emacs-lisp +(general-create-definer foltz-help-def + :states 'normal + :keymaps 'override + :prefix "SPC h") + +(foltz-help-def + "?" 'help-for-help + "h" 'help-for-help + "k" 'describe-key) +#+END_SRC + +**** b - buffer +#+BEGIN_SRC emacs-lisp +(general-create-definer foltz-buffer-def + :states 'normal + :keymaps 'override + :prefix "SPC b") + +(foltz-buffer-def + "i" 'ibuffer) +#+END_SRC + +**** w - window +#+BEGIN_SRC emacs-lisp +(general-create-definer foltz-window-def + :states 'normal + :keymaps 'override + :prefix "SPC w") + +(foltz-window-def + "o" 'delete-other-windows) +#+END_SRC + +**** f - file +#+BEGIN_SRC emacs-lisp +(general-create-definer foltz-file-def + :states 'normal + :keymaps 'override + :prefix "SPC f") + +(defun foltz-config-visit () + (interactive) + (find-file (concat user-emacs-directory "config.org"))) + +(defun foltz-config-reload () + (interactive) + (org-babel-load-file + (expand-file-name "config.org" user-emacs-directory))) + +(foltz-file-def + "w" 'save-buffer + "r" 'revert-buffer + "e" '(:ignore t :which-key "emacs files") + "e e" 'foltz-config-visit + "e r" 'foltz-config-reload) +#+END_SRC + +** Vim +Evil is pretty much the entirety of Vim in Emacs. +[[https://github.com/Somelauw/evil-org-mode][evil-org]] adds nice bindings to org-mode. + +#+BEGIN_SRC emacs-lisp +(use-package evil + :after general + :diminish undo-tree-mode + :init + (setq evil-want-integration nil) + (setq evil-want-keybinding nil) + + :config + (evil-mode t) + + :custom + (evil-shift-width 4 "Set indent to 4 spaces")) + +(use-package evil-leader + :after evil + :init + (defun foltz-window-split () + (interactive) + (evil-window-split) + (evil-window-down 1)) + (defun foltz-window-vsplit () + (interactive) + (evil-window-vsplit) + (evil-window-right 1)) + + :general + (:keymaps 'override + :states 'normal + "U" 'undo-tree-visualize) + (foltz-window-def + "-" 'foltz-window-split + "=" 'foltz-window-vsplit + "h" 'evil-window-left + "j" 'evil-window-down + "k" 'evil-window-up + "l" 'evil-window-right + "H" 'evil-window-far-left + "J" 'evil-window-move-very-bottom + "K" 'evil-window-move-very-top + "L" 'evil-window-far-right + "<" 'evil-window-decrease-width + ">" 'evil-window-increase-width + "^" 'evil-window-decrease-height + "%" 'evil-window-increase-height + "n" 'evil-window-new + "c" 'evil-window-delete + "w" 'evil-window-next + "W" 'evil-window-prev + "r" 'evil-window-rotate-downwards + "|" 'evil-window-set-width + "_" 'evil-window-set-height) + + :config + (global-evil-leader-mode)) + +(use-package evil-org + :after (evil org) + :hook (org-mode . evil-org-mode) + :config + (add-hook 'evil-org-mode (lambda () + (evil-org-set-key-theme + '(textobjects insert navigation + additional shift todo calendar))))) +#+END_SRC + +** Startup dashboard +Show a cool custom buffer on startup +#+BEGIN_SRC emacs-lisp +(use-package dashboard + :diminish page-break-lines-mode + + :config + (dashboard-setup-startup-hook) + (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) + + :custom + (dashboard-startup-banner 'logo) + (dashboard-banner-logo-title "Welcome to Electronic Macs") + (dashboard-items + '((recents . 5) + (agenda) + (bookmarks . 5) + (registers . 5)))) +#+END_SRC + +** Folder tree +A cool toggleable directory structure sidebar +It also needs icon fonts, installed with =M-x all-the-icons-install-fonts= +#+BEGIN_SRC emacs-lisp +(use-package all-the-icons) +(use-package neotree + :after all-the-icons + :commands neotree-toggle + :general + (foltz-leader-def + :states 'normal + "t" 'neotree-toggle) + :custom + (neo-theme (if (display-graphic-p) 'icons 'arrow))) +#+END_SRC +** Organization +*** org-mode +Keep org-mode up to date straight from the cow's utters. +If the manual is not on your computer, it's [[https://orgmode.org/manual/][here]]. +#+BEGIN_SRC emacs-lisp +(use-package org + :pin org + :mode ("\\.org\\'" . org-mode) + :hook (org-mode . org-indent-mode) + + :init + ;