From 13ec4b472c148ecc6dd6d7cfa95af95d7ce0451f Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Sat, 29 Dec 2018 10:55:28 -0500 Subject: [PATCH] work on custom emacs setup --- .gitignore | 3 ++ emacs.d/core.el | 48 ++++++++++++++++++++++++++ emacs.d/custom.el | 17 ++++++++++ emacs.d/funcs.el | 6 ++++ emacs.d/init.el | 14 ++++++++ emacs.d/layers.el | 2 ++ emacs.d/layers/python/init.el | 22 ++++++++++++ emacs.d/packages.el | 63 +++++++++++++++++++++++++++++++++++ emacs.d/startup.el | 27 +++++++++++++++ emacs.d/theme.el | 3 ++ 10 files changed, 205 insertions(+) create mode 100644 emacs.d/core.el create mode 100644 emacs.d/custom.el create mode 100644 emacs.d/funcs.el create mode 100644 emacs.d/init.el create mode 100644 emacs.d/layers.el create mode 100644 emacs.d/layers/python/init.el create mode 100644 emacs.d/packages.el create mode 100644 emacs.d/startup.el create mode 100644 emacs.d/theme.el diff --git a/.gitignore b/.gitignore index a3390b1..2ed2466 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ *.elc config/ zshrc.d/.env.*.zsh +emacs.d/elpa +emacs.d/anaconda-mode +emacs.d/*.eld diff --git a/emacs.d/core.el b/emacs.d/core.el new file mode 100644 index 0000000..dae25db --- /dev/null +++ b/emacs.d/core.el @@ -0,0 +1,48 @@ +;; Configure customization +(setq custom-file "~/.emacs.d/custom.el") +(load custom-file) + +;; Hide startup message +(setq inhibit-startup-message t) + +;; Configure package and use-package +(require 'package) + +(add-to-list 'package-archives + '("melpa-stable" . "https://stable.melpa.org/packages/") t) + +(package-initialize) + +(when (not package-archive-contents) + (package-refresh-contents)) + +(unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package)) + +(require 'use-package) +(setq use-package-always-ensure t) + +;; Disable backup files and auto-saving +(setq backup-inhibited t) +(setq auto-save-default nil) + +;; revert buffers automatically when underlying files are changed externally +(global-auto-revert-mode t) + +;; Whitespace +;; Newline at end of file +(setq require-final-newline t) +(add-hook 'before-save-hook 'whitespace-cleanup) +(whitespace-mode) + +;; Subword mode +(global-subword-mode) + +;; Enable global line numbers +(global-linum-mode t) + + +;; Custom functions +;; DEV: Load this last +(load "~/.emacs.d/funcs.el") diff --git a/emacs.d/custom.el b/emacs.d/custom.el new file mode 100644 index 0000000..4f55687 --- /dev/null +++ b/emacs.d/custom.el @@ -0,0 +1,17 @@ +(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. + '(custom-safe-themes + (quote + ("5f27195e3f4b85ac50c1e2fac080f0dd6535440891c54fcfa62cdcefedf56b1b" default))) + '(package-selected-packages + (quote + (helm-gtags ggtags smartparens helm-ag flymake-python-pyflakes flycheck company-anaconda anaconda-mode osx-clipboard diminish ws-butler company company-mode helm-projectile ivy ag projectile helm use-package)))) +(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. + ) diff --git a/emacs.d/funcs.el b/emacs.d/funcs.el new file mode 100644 index 0000000..1a699b9 --- /dev/null +++ b/emacs.d/funcs.el @@ -0,0 +1,6 @@ +(defun enable-flycheck () + ;; Flycheck + ;; http://www.flycheck.org/en/latest/index.html + (use-package flycheck + :config + (flycheck-mode))) diff --git a/emacs.d/init.el b/emacs.d/init.el new file mode 100644 index 0000000..2f30a9a --- /dev/null +++ b/emacs.d/init.el @@ -0,0 +1,14 @@ +;; Startup optimizations +(load "~/.emacs.d/startup.el") + +;; Configure core required setup +(load "~/.emacs.d/core.el") + +;; Configure theme +(load "~/.emacs.d/theme.el") + +;; Configure global packages +(load "~/.emacs.d/packages.el") + +;; Configure layers +(load "~/.emacs.d/layers.el") diff --git a/emacs.d/layers.el b/emacs.d/layers.el new file mode 100644 index 0000000..eb69ec1 --- /dev/null +++ b/emacs.d/layers.el @@ -0,0 +1,2 @@ +;; Load layers +(load "~/.emacs.d/layers/python/init.el") diff --git a/emacs.d/layers/python/init.el b/emacs.d/layers/python/init.el new file mode 100644 index 0000000..21f00f5 --- /dev/null +++ b/emacs.d/layers/python/init.el @@ -0,0 +1,22 @@ +(add-hook 'python-mode-hook + (lambda () + ;; Anaconda mode + ;; https://github.com/proofit404/anaconda-mode + (use-package anaconda-mode + :diminish anaconda-mode + :config + (anaconda-mode) + (anaconda-eldoc-mode)) + + ;; Company anaconda + ;; https://github.com/proofit404/company-anaconda + (use-package company-anaconda + :init + (eval-after-load "company" + '(add-to-list 'company-backends 'company-anaconda))) + (use-package eldoc + :diminish eldoc-mode + :config + (eldoc-mode)) + + (enable-flycheck))) diff --git a/emacs.d/packages.el b/emacs.d/packages.el new file mode 100644 index 0000000..28930bf --- /dev/null +++ b/emacs.d/packages.el @@ -0,0 +1,63 @@ +;; Global packages + +;; Configure osx-clipboard +;; https://github.com/joddie/osx-clipboard-mode +(use-package osx-clipboard + :diminish osx-clipboard-mode + :config + (osx-clipboard-mode t)) + +;; Configure helm +;; https://emacs-helm.github.io/helm/ +(use-package helm + :diminish helm-mode + :bind (("M-x" . helm-M-x) + ("C-x C-f" . helm-find-files)) + :config + (use-package helm-ag) + (helm-mode 1)) + + +;; Configure projectile +;; https://www.projectile.mx/en/latest/ +(use-package projectile + :diminish projectile-mode + :config + (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) + (projectile-mode +1) + ;; Use helm-projectile + (use-package helm-projectile + :config + (setq projectile-switch-project-action 'helm-projectile) + (helm-projectile-on))) + + +;; Configure company-mode +;; http://company-mode.github.io/ +(use-package company + :diminish company-mode + :init + (setq company-idle-delay 0.2 + company-minimum-prefix-length 2 + company-require-match nil + company-dabbrev-ignore-case nil + company-dabbrev-downcase nil) + :config + (global-company-mode)) + + +;; Configure ws-butler +;; https://github.com/lewang/ws-butler +(use-package ws-butler) + + +;; Configure diminish +;; https://github.com/myrjola/diminish.el +(use-package diminish) + + +;; Smartparens +;; https://github.com/Fuco1/smartparens +(use-package smartparens + :config + (smartparens-global-mode)) diff --git a/emacs.d/startup.el b/emacs.d/startup.el new file mode 100644 index 0000000..32255d7 --- /dev/null +++ b/emacs.d/startup.el @@ -0,0 +1,27 @@ +;; Startup optimizations + +;; Set garbage collection threshold +;; https://www.reddit.com/r/emacs/comments/3kqt6e/2_easy_little_known_steps_to_speed_up_emacs_start/ +(setq gc-cons-threshold-original gc-cons-threshold + gc-cons-percentage-original gc-cons-percentage) +(setq gc-cons-threshold (* 1024 1024 100) + gc-cons-percentage 0.6) + +;; Set file-name-handler-alist +;; https://www.reddit.com/r/emacs/comments/3kqt6e/2_easy_little_known_steps_to_speed_up_emacs_start/ +(setq file-name-handler-alist-original file-name-handler-alist) +(setq file-name-handler-alist nil) + +;; Set deferred timer to reset them +;; https://emacs.stackexchange.com/a/34367 +(run-with-idle-timer + 5 nil + (lambda () + (setq gc-cons-threshold gc-cons-threshold-original) + (setq gc-cons-percentage gc-cons-percentage-original) + (setq file-name-handler-alist file-name-handler-alist-original) + (makunbound 'gc-cons-threshold-original) + (makunbound 'gc-cons-percentage-original) + (makunbound 'file-name-handler-alist-original) + (message "gc-cons-threshold and file-name-handler-alist restored"))) + diff --git a/emacs.d/theme.el b/emacs.d/theme.el new file mode 100644 index 0000000..5ca9615 --- /dev/null +++ b/emacs.d/theme.el @@ -0,0 +1,3 @@ +(use-package monokai-theme + :config + (load-theme 'monokai t))