dotfiles/config/emacs.d/init.el
2017-10-16 07:39:58 -07:00

204 lines
5.9 KiB
EmacsLisp

;; init.el
;;
;; Emacs Configuration
;;
;; Author: Kevin Cotugno git@kevincotugno.com
;; Date: 2/22/17
;; Package
(require 'package)
(package-initialize)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives '("melpa-stable" .
"https://stable.melpa.org/packages/"))
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e")
(add-to-list 'exec-path "/usr/local/bin")
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
(setq use-package-always-ensure t)
;; Display
(set-default-font "Source Code Pro-12")
(line-number-mode t)
(global-linum-mode t)
(menu-bar-mode -1)
(tool-bar-mode -1)
(setq inhibit-startup-screen t)
(setq-default truncate-lines t)
(setq-default truncate-partial-width-windows nil)
(setq-default scroll-conservatively 100)
(when (display-graphic-p) (progn
(global-hl-line-mode t)
(scroll-bar-mode -1)))
(global-whitespace-mode)
(setq whitespace-style '(face trailing tabs spaces lines empty indentation
space-after-tab space-before-tab space-mark
tab-mark))
;; End display
;; Auto generated config
(setq custom-file (expand-file-name "auto.el" user-emacs-directory))
(load custom-file 'noerror)
;; End auto generated config
;; Text Formatting
(setq-default standard-indent 8)
(setq-default c-default-style "linux"
c-basic-offset 8
tab-width 8)
(add-hook 'emacs-lisp-mode-hook (lambda ()
(setq indent-tabs-mode nil)))
(add-hook 'ruby-mode-hook (lambda ()
(setq indent-tabs-mode nil)
(setq evil-shift-width 2)
(setq tab-width 2)))
(add-hook 'js-mode-hook (lambda ()
(setq indent-tabs-mode nil)
(setq evil-shift-width 2)
(setq js-indent-level 2)))
(add-hook 'css-mode-hook (lambda ()
(setq indent-tabs-mode nil)
(setq evil-shift-width 2)
(setq tab-width 2)
(setq css-indent-offset 2)))
(add-hook 'org-mode-hook (lambda ()
(setq indent-tabs-mode nil)
(setq tab-width 2)
(setq evil-shift-width 2)))
;; End text Formatting
;; Backup Files
(setq backup-directory-alist `(("." . "~/.emacs.d/backups")))
;; End Backup Files
;; Plugins
;; Themes
(defun flip-background ()
"Flip the frame and terminal background mode.
useful for alternating between light and dark themes"
(interactive)
(let ((mode (if (or (eq (frame-parameter nil 'background-mode) 'dark)
(eq (terminal-parameter nil 'background-mode) 'dark))
(setq mode 'light)
(setq mode 'dark))))
(set-frame-parameter nil 'background-mode mode)
(set-terminal-parameter nil 'background-mode mode)
(dolist (theme custom-enabled-themes)
(enable-theme theme))))
(global-set-key (kbd "<f5>") 'flip-background)
;; Load directories in the .emacs.d/themes directory to the load path
;; TODO Only add directories
(mapcar (lambda (item)
(add-to-list 'custom-theme-load-path item))
(mapcar (lambda (item)
(format "%s/.emacs.d/themes/%s/" (getenv "HOME") item))
(let (files '())
(dolist (val
(directory-files (format "%s/.emacs.d/themes/"
(getenv "HOME")))
files)
(let ((off (string-match "\\." val)))
(unless (and off (eq off 0))
(setq files (cons val files))))))))
(when (load-theme 'solarized t) (flip-background))
;; End themes
(use-package org)
(use-package org-bullets
:config
(add-hook 'org-mode-hook (lambda ()
(org-bullets-mode t))))
(use-package company
:config
(add-hook 'after-init-hook 'global-company-mode))
(use-package evil
:config
(evil-mode t)
(define-key evil-normal-state-map "\C-k" 'evil-normal-state)
(define-key evil-insert-state-map "\C-k" 'evil-normal-state)
(define-key evil-visual-state-map "\C-k" 'evil-normal-state)
(define-key evil-replace-state-map "\C-k" 'evil-normal-state)
(define-key evil-insert-state-map "\C-c\C-c" 'evil-normal-state)
(define-key evil-normal-state-map "\C-i" 'evil-scroll-up)
(define-key evil-visual-state-map "\C-i" 'evil-scroll-up))
(use-package evil-leader
:ensure t
:after evil
:config
(global-evil-leader-mode)
(evil-leader/set-leader "\\"))
(use-package evil-surround
:ensure t)
(use-package evil-org
:ensure t
:after org evil
:config
(add-hook 'org-mode-hook 'evil-org-mode)
(add-hook 'evil-org-mode-hook (lambda () (evil-org-set-key-theme))))
(use-package powerline
:ensure t
:config
(powerline-default-theme))
(use-package magit
:ensure t)
(use-package helm
:ensure t
:config
(helm-mode t))
(use-package helm-projectile
:ensure t
:config
(evil-leader/set-key "p" 'helm-projectile)
(helm-projectile-on))
(require 'mu4e)
(setq mu4e-maildir (concat (getenv "HOME") "/.mail"))
(setq mu4e-drafts-folder "/Drafts")
(setq mu4e-sent-folder "/Sent")
(setq mu4e-trash-folder "/Trash")
(setq mu4e-get-mail-command "offlineimap")
(setq mu4e-compose-reply-to-address "kevin@kevincotugno.com"
user-mail-address "kevin@kevincotugno.com"
user-full-name "Kevin Cotugno")
(setq
message-send-mail-function 'smtpmail-send-it
smtpmail-smtp-server "smtp.cotugno.family"
smtpmail-stream-type 'ssl
smtpmail-smtp-service 587)
(setq message-kill-buffer-on-exit t)
;; End Plugins