From 19061287b95a2c63f6ef1b7e825077649ed8bc42 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Fri, 27 Mar 2020 10:57:19 -0500 Subject: [PATCH] WIP emacs config --- apps/emacs/.gitignore | 3 + apps/emacs/config.el | 103 ++++++++++++++++++++++++ apps/emacs/config.org | 180 ++++++++++++++++++++++++++++++++++++++++++ apps/emacs/config~ | 17 ++++ apps/emacs/init.el | 14 ++++ setup.bash | 2 +- 6 files changed, 318 insertions(+), 1 deletion(-) create mode 100644 apps/emacs/.gitignore create mode 100644 apps/emacs/config.el create mode 100644 apps/emacs/config.org create mode 100644 apps/emacs/config~ create mode 100644 apps/emacs/init.el diff --git a/apps/emacs/.gitignore b/apps/emacs/.gitignore new file mode 100644 index 0000000..4a60648 --- /dev/null +++ b/apps/emacs/.gitignore @@ -0,0 +1,3 @@ +/auto-save-list +/elpa +*~ diff --git a/apps/emacs/config.el b/apps/emacs/config.el new file mode 100644 index 0000000..51b17b9 --- /dev/null +++ b/apps/emacs/config.el @@ -0,0 +1,103 @@ +(require 'use-package-ensure) +(setq use-package-always-ensure t) + +(use-package auto-compile :config (auto-compile-on-load-mode)) +(setq load-prefer-newer t) + +(setq evil-want-abbrev-expand-on-insert-exit nil) + +(use-package evil + :config + (evil-mode 1)) + +(use-package evil-collection + :after evil) + +(use-package evil-surround + :config + (global-evil-surround-mode 1)) + +(use-package evil-org + :after org + :config + (add-hook 'org-mode-hook 'evil-org-mode) + (add-hook 'evil-org-mode-hook + (lambda () (evil-org-set-key-theme))) + (require 'evil-org-agenda) + (evil-org-agenda-set-keys)) + +(use-package key-chord :after evil) +(key-chord-mode 1) +(key-chord-define evil-insert-state-map "jk" 'evil-normal-state) + +(defun lytedev/reload-config () + (interactive) + (load-file "~/.emacs")) +(global-set-key (kbd "C-x M-r") 'lytedev/reload-config) + +(tool-bar-mode 0) +(menu-bar-mode 1) ;; Keep the menu while I'm a newb. +(scroll-bar-mode -1) + +(set-window-scroll-bars (minibuffer-window) nil nil) + +(use-package monokai-theme) +(let ((line (face-attribute 'mode-line :underline))) + (set-face-attribute 'mode-line nil :overline line) + (set-face-attribute 'mode-line-inactive nil :overline line) + (set-face-attribute 'mode-line-inactive nil :underline nil) + (set-face-attribute 'mode-line nil :box nil) + (set-face-attribute 'mode-line-inactive nil :box nil) + (set-face-attribute 'mode-line-inactive nil :background "#f9f2d9")) + +(defun lytedev/apply-theme () + (interactive) + (load-theme 'monokai t)) + +;; (if (daemonp) +;; (add-hook 'after-make-frame-functions (lambda (frame) (with-selected-frame frame + +(use-package moody + :config + (setq x-underline-at-descent-line t) + (moody-replace-mode-line-buffer-identification) + (moody-replace-vc-mode)) + +(setq lytedev/default-font "Iosevka Type") +(setq lytedev/default-font-size 10) +(setq lytedev/min-font-size 4) +(setq lytedev/current-font-size lytedev/default-font-size) + +(setq lytedev/font-change-increment 1.1) + +(defun lytedev/font-code () + (concat lytedev/default-font "-" (number-to-string lytedev/current-font-size))) + +(defun lytedev/set-font-size () + (let ((font-code (lytedev/font-code))) + (if (assoc 'font default-frame-alist) + (setcdr (assoc 'font default-frame-alist) font-code) + (add-to-list 'default-frame-alist (cons 'font font-code))) + (set-frame-font font-code))) + +(defun lytedev/reset-font-size () + (interactive) + (setq lytedev/current-font-size lytedev/default-font-size) + (lytedev/set-font-size)) + +(defun lytedev/increase-font-size () + (interactive) + (setq lytedev/current-font-size (ceiling (* lytedev/current-font-size lytedev/font-change-increment))) + (lytedev/set-font-size)) + +(defun lytedev/decrease-font-size () + (interactive) + (setq lytedev/current-font-size (max lytedev/min-font-size (floor (/ lytedev/current-font-size lytedev/font-change-increment)))) + (lytedev/set-font-size)) + +(define-key global-map (kbd "C-+") 'lytedev/increase-font-size) +(define-key global-map (kbd "C--") 'lytedev/decrease-font-size) +(define-key global-map (kbd "C-0") 'lytedev/reset-font-size) + +;; NOTE: I have no clue what this does... yet. +(global-prettify-symbols-mode t) diff --git a/apps/emacs/config.org b/apps/emacs/config.org new file mode 100644 index 0000000..23099b8 --- /dev/null +++ b/apps/emacs/config.org @@ -0,0 +1,180 @@ +#+TITLE: emacs config +#+AUTHOR: Daniel "lytedev" Flanagan +#+EMAIL: daniel@lyte.dev + +I have very little idea what I'm doing. Here goes! + +* Meta + +User information. + +#+begin_src +(setq user-full-name "Daniel Flanagan" + user-mail-address "daniel@lyte.dev" + calendar-location-name "Kansas City, MO") +#+end_src + +* Package Setup + +Make sure packages in use are installed. + +#+begin_src emacs-lisp +(require 'use-package-ensure) +(setq use-package-always-ensure t) +#+end_src + +... and that we compile them. + +#+begin_src emacs-lisp +(use-package auto-compile :config (auto-compile-on-load-mode)) +(setq load-prefer-newer t) +#+end_src + +* Setup a text editor + +Get vimmy with it. + +#+begin_src emacs-lisp +(setq evil-want-abbrev-expand-on-insert-exit nil) + +(use-package evil + :config + (evil-mode 1)) + +(use-package evil-collection + :after evil) + +(use-package evil-surround + :config + (global-evil-surround-mode 1)) + +(use-package evil-org + :after org + :config + (add-hook 'org-mode-hook 'evil-org-mode) + (add-hook 'evil-org-mode-hook + (lambda () (evil-org-set-key-theme))) + (require 'evil-org-agenda) + (evil-org-agenda-set-keys)) +#+end_src + +Map the `jk` chord to escape. + +#+begin_src emacs-lisp +(use-package key-chord :after evil) +(key-chord-mode 1) +(key-chord-define evil-insert-state-map "jk" 'evil-normal-state) +#+end_src + +And so that I can iterate quickly while writing this, setup the chord `r` to reload my config. + +#+begin_src emacs-lisp +(defun lytedev/reload-config () + (interactive) + (load-file "~/.emacs")) +(global-set-key (kbd "C-x M-r") 'lytedev/reload-config) +#+end_src + +Kill GUI elements unnecessary for my usage. + +#+begin_src emacs-lisp +(tool-bar-mode 0) +(menu-bar-mode 1) ;; Keep the menu while I'm a newb. +(scroll-bar-mode -1) +#+end_src + +Kill minibuffer scroll bars. + +#+begin_src emacs-lisp +(set-window-scroll-bars (minibuffer-window) nil nil) +#+end_src + +** Editor + +Setup a decent theme. + +#+begin_src emacs-lisp +(use-package monokai-theme) +(let ((line (face-attribute 'mode-line :underline))) + (set-face-attribute 'mode-line nil :overline line) + (set-face-attribute 'mode-line-inactive nil :overline line) + (set-face-attribute 'mode-line-inactive nil :underline nil) + (set-face-attribute 'mode-line nil :box nil) + (set-face-attribute 'mode-line-inactive nil :box nil) + (set-face-attribute 'mode-line-inactive nil :background "#f9f2d9")) + +(defun lytedev/apply-theme () + (interactive) + (load-theme 'monokai t)) +#+end_src + +... and make it work in daemon mode. + +#+begin_src emacs-lisp +;; (if (daemonp) +;; (add-hook 'after-make-frame-functions (lambda (frame) (with-selected-frame frame +#+end_src + +Setup a pretty modeline. + +#+begin_src emacs-lisp +(use-package moody + :config + (setq x-underline-at-descent-line t) + (moody-replace-mode-line-buffer-identification) + (moody-replace-vc-mode)) +#+end_src + +Setup the best font and bindings to adjust its size on the fly. + +#+begin_src emacs-lisp +(setq lytedev/default-font "Iosevka Type") +(setq lytedev/default-font-size 10) +(setq lytedev/min-font-size 4) +(setq lytedev/current-font-size lytedev/default-font-size) + +(setq lytedev/font-change-increment 1.1) + +(defun lytedev/font-code () + (concat lytedev/default-font "-" (number-to-string lytedev/current-font-size))) + +(defun lytedev/set-font-size () + (let ((font-code (lytedev/font-code))) + (if (assoc 'font default-frame-alist) + (setcdr (assoc 'font default-frame-alist) font-code) + (add-to-list 'default-frame-alist (cons 'font font-code))) + (set-frame-font font-code))) + +(defun lytedev/reset-font-size () + (interactive) + (setq lytedev/current-font-size lytedev/default-font-size) + (lytedev/set-font-size)) + +(defun lytedev/increase-font-size () + (interactive) + (setq lytedev/current-font-size (ceiling (* lytedev/current-font-size lytedev/font-change-increment))) + (lytedev/set-font-size)) + +(defun lytedev/decrease-font-size () + (interactive) + (setq lytedev/current-font-size (max lytedev/min-font-size (floor (/ lytedev/current-font-size lytedev/font-change-increment)))) + (lytedev/set-font-size)) + +(define-key global-map (kbd "C-+") 'lytedev/increase-font-size) +(define-key global-map (kbd "C--") 'lytedev/decrease-font-size) +(define-key global-map (kbd "C-0") 'lytedev/reset-font-size) +#+end_src + +** Misc + +NOTE: What exactly does this get me? + +#+begin_src emacs-lisp +;; NOTE: I have no clue what this does... yet. +(global-prettify-symbols-mode t) +#+end_src + +* To Do + +1. Setup theme +2. Setup an editor diff --git a/apps/emacs/config~ b/apps/emacs/config~ new file mode 100644 index 0000000..ae24e3d --- /dev/null +++ b/apps/emacs/config~ @@ -0,0 +1,17 @@ +;; Configure package.el to include MELPA. +(require 'package) +(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t) +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) +(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t) +(package-initialize) + +;; Ensure that use-package is installed. +;; +;; If use-package isn't already installed, it's extremely likely that this is a +;; fresh installation! So we'll want to update the package repository and +;; install use-package before loading the literate configuration. +(when (not (package-installed-p 'use-package)) + (package-refresh-contents) + (package-install 'use-package)) + +(org-babel-load-file "~/.emacs.d/config.org") diff --git a/apps/emacs/init.el b/apps/emacs/init.el new file mode 100644 index 0000000..1fda508 --- /dev/null +++ b/apps/emacs/init.el @@ -0,0 +1,14 @@ +;; Setup package archives. +(require 'package) +(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/") t) +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) +(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t) +(package-initialize) + +;; Setup `use-package`. +(when (not (package-installed-p 'use-package)) + (package-refresh-contents) + (package-install 'use-package)) + +;; Load the bulk of our configuration from a fancy org file. +(org-babel-load-file "~/.emacs.d/config.org") diff --git a/setup.bash b/setup.bash index 9f9ff17..c9ba53f 100755 --- a/setup.bash +++ b/setup.bash @@ -48,7 +48,7 @@ links=( "apps/neovim/" "$HOME/.vim" "apps/neovim/init.vim" "$HOME/.vimrc" "bin/lib/colors/vim" "$XDG_CONFIG_HOME/nvim/colors/base16-donokai.vim" - "apps/emacs/config" "$HOME/.emacs" + "apps/emacs/" "$HOME/.emacs.d" # gtk configuration files "apps/de/gtk/2rc" "$HOME/.gtkrc-2.0"