From a328b7e240dc6f6edf160ad163dbed68ef95c2ab Mon Sep 17 00:00:00 2001 From: William Carroll Date: Tue, 24 Jan 2017 15:11:11 -0500 Subject: [PATCH] Updates config to use-package --- configs/#.zsh_profile# | 51 ++++ configs/.emacs | 561 ++++++++++++++++++++++------------------- configs/.zsh_profile | 2 +- 3 files changed, 354 insertions(+), 260 deletions(-) create mode 100644 configs/#.zsh_profile# diff --git a/configs/#.zsh_profile# b/configs/#.zsh_profile# new file mode 100644 index 000000000..042fd2f6f --- /dev/null +++ b/configs/#.zsh_profile# @@ -0,0 +1,51 @@ +export PATH=$HOME/bin:/opt/local/bin:/opt/local/sbin:/usr/local/go/bin:/usr/local/sbin:$PATH + +# make vim the default editor for commit messages etc +export EDITOR=$(which vim) + + +echo "Welcome back, $USER" + +# display the space available on each mounted Volume +df -hl + +# use vi bindings for terminal input +set -o vi + +# aliases +source $HOME/pc_settings/aliases.sh + +# functions +source $HOME/pc_settings/functions/index.sh + +# setup keybindings for history functions +source $HOME/pc_settings/scripts/setup_keybindings.sh + + +# BEGIN: bindkeys +bindkey "^R" history-incremental-search-backward + +bindkey -M viins 'jk' vi-cmd-mode +# END: bindkeys + +# export docker env variables +# re-enable this line when using docker otherwise you will receive +# a TLS error since docker-machine won't be running +# eval "$(docker-machine env default)" + +# run cmatrix command for 3 seconds before exiting +#. $HOME/pc_settings/.matrix_intro.sh + +# syntax highlighting for CLI; if not installed, run the following command +# brew install zsh-syntax-highlighting +source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh + +# Regain control of CLI " . evil-force-normal-state) + ("j k" . evil-force-normal-state) + + :map evil-motion-state-map + ("" . nil) + ("" . nil) + ("SPC" . nil) + ("M-." . nil) + ("/" . helm-do-ag-this-file) + ("?" . helm-do-ag-this-file) + + :map evil-normal-state-map + ("" . nil) + ("" . nil) + ("C-h" . evil-window-left) + ("C-l" . evil-window-right) + ("C-k" . evil-window-up) + ("C-j" . evil-window-down) + ("s" . nil) + ("s l" . evil-window-vsplit) + ("s j" . evil-window-split) + ("H" . evil-first-non-blank) + ("L" . evil-end-of-line)) + :init + (setq evil-emacs-state-cursor '("red" box)) + (setq evil-normal-state-cursor '("green" box)) + (setq evil-visual-state-cursor '("orange" box)) + (setq evil-insert-state-cursor '("red" bar)) + (setq evil-replace-state-cursor '("red" bar)) + (setq evil-operator-state-cursor '("red" hollow)) + (global-evil-matchit-mode t) + (global-evil-surround-mode t) + (global-evil-leader-mode t)) + + +;; Evil Leader Settings +(use-package evil-leader + :ensure t + :commands (global-evil-leader-mode) + :config + (evil-leader/set-leader "") + (evil-leader/set-key + "x" 'helm-M-x + "" 'mode-line-other-buffer + "n" 'neotree-project-dir + "b" 'helm-mini)) + + +;; Evil Match-it +(use-package evil-matchit + :ensure t + :commands (global-evil-matchit-mode)) + + +;; Evil Surround +(use-package evil-surround + :ensure t + :commands (global-evil-surround-mode)) + + +;; Flycheck Mix Settings +(use-package flycheck-mix + :ensure t + :init + (flycheck-mix-setup)) + + +;; Flycheck Credo Settings +(use-package flycheck-credo + :ensure t + :init + (flycheck-credo-setup)) + + +;; Popwin Settings +(use-package popwin + :ensure t) + +(defun *-popwin-help-mode-off () + "Turn `popwin-mode' off for *Help* buffers." + + (when (boundp 'popwin:special-display-config) + (customize-set-variable 'popwin:special-display-config + (delq 'help-mode popwin:special-display-config)))) + +(defun *-popwin-help-mode-on () + "Turn `popwin-mode' on for *Help* buffers." + + (when (boundp 'popwin:special-display-config) + (customize-set-variable 'popwin:special-display-config + (add-to-list 'popwin:special-display-config 'help-mode nil #'eq)))) + +(add-hook 'helm-minibuffer-set-up-hook #'*-popwin-help-mode-off) +(add-hook 'helm-cleanup-hook #'*-popwin-help-mode-on) + +(setq display-buffer-function 'popwin:display-buffer) +(setq helm-split-window-preferred-function 'ignore) +(push '("^\*helm .+\*$" :regexp t) popwin:special-display-config) +(push '("^\*helm-.+\*$" :regexp t) popwin:special-display-config) + + +;; Alchemist Settings +(use-package alchemist + :ensure t + :config + (setq alchemist-mix-env "prod") + (setq alchemist-goto-elixir-source-dir "/Users/wpcarro/source_code/elixir") + (setq alchemist-goto-erlang-source-dir "/Users/wpcarro/source_code/otp/") + :init + (linum-mode)) + +(defun custom-erlang-mode-hook () + "Jump to and from Elixir, Erlang, Elixir files." + + (define-key erlang-mode-map (kbd "M-,") 'alchemist-goto-jump-back)) + +(add-hook 'erlang-mode-hook 'custom-erlang-mode-hook) + + +;; NeoTree Settings +(use-package neotree + :ensure t + :bind (:map neotree-mode-map + ("j" . next-line) + ("k" . previous-line) + + ("" . neotree-enter) + ("" . neotree-enter) + + ("C-h" . evil-window-left) + ("C-l" . evil-window-right) + ("C-k" . evil-window-up) + ("C-j" . evil-window-down)) + :init + (hl-line-mode)) + +(defun neotree-project-dir () + "Open NeoTree using the git root." + + (interactive) + (let ((project-dir (projectile-project-root)) + (file-name (buffer-file-name))) + (neotree-toggle) + (if project-dir + (if (neo-global--window-exists-p) + (progn + (neotree-dir project-dir) + (neotree-find file-name))) + (message "Could not find git project root.")))) + + +;; Whitespace Settings +(use-package whitespace + :ensure t + :commands (whitespace-mode) + :config + (setq whitespace-line-column 80) + (setq whitespace-style '(face lines-tail))) + + +;; Helm Settings +(use-package helm + :ensure t + :commands (helm-mode) + :bind ( + ("M-x" . helm-M-x) + ("M-y" . helm-show-kill-ring) + ("C-x b" . helm-mini) + :map helm-map + ("TAB" . helm-execute-persistent-action) + ("C-z" . helm-select-action) + + :term-raw-map + ("M-x" . helm-M-x)) + :init + (setq helm-buffers-fuzzy-matching t) + (setq helm-recentf-fuzzy-match t) + (setq helm-semantic-fuzzy-match t) + (setq helm-imenu-fuzzy-match t) + (setq helm-locate-fuzzy-match t)) + + +;; Helm Projectile Settings +(use-package helm-projectile + :ensure t + :bind ("C-x C-f" . helm-projectile) + :init + (bind-key "C-x p" 'helm-projectile-ag)) + + +;; Company Settings +(use-package company + :config + (setq company-idle-delay 0)) + + +(add-hook 'after-init-hook 'evil-mode) +(add-hook 'after-init-hook 'global-whitespace-mode) +(add-hook 'after-init-hook 'global-hl-line-mode) +(add-hook 'after-init-hook 'global-linum-mode) +(add-hook 'after-init-hook 'global-flycheck-mode) +(add-hook 'after-init-hook 'global-company-mode) +(add-hook 'after-init-hook 'projectile-mode) +(add-hook 'after-init-hook 'helm-mode) +(add-hook 'before-save-hook 'delete-trailing-whitespace) ;; Scrolling Settings @@ -53,10 +312,6 @@ (exec-path-from-shell-initialize)) -;; Trim trailing whitespace on save -(add-hook 'before-save-hook 'delete-trailing-whitespace) - - ;; Emacs backup / autosave files ;; (setq-default make-backup-files nil) (setq backup-directory-alist `(("." . "~/.emacs-tmp"))) @@ -67,212 +322,15 @@ (setq vc-follow-symlinks t) -;; Enable autocompletion -(add-hook 'after-init-hook 'global-company-mode) - -;; Remove company delay -(setq-default company-idle-delay 0) - - -;; View stream of Emacs commands -(require 'command-log-mode) -(global-command-log-mode) - - ;; Commenting / Uncommenting (global-set-key (kbd "C-x C-;") 'comment-or-uncomment-region) -;; Flycheck Settings -(require 'flycheck) -(add-hook 'after-init-hook 'global-flycheck-mode) - - -;; Elixir flycheck compile-time errors -(require 'flycheck-mix) -(require 'flycheck-credo) -(eval-after-load 'flycheck (lambda () (flycheck-credo-setup) (flycheck-mix-setup))) - - -;; Magit Settings -(global-set-key (kbd "C-x g") 'magit-status) -(global-set-key (kbd "C-x M-g") 'magit-dispatch-popup) - - ;; Fullscreen settings (setq ns-use-native-fullscreen nil) (global-set-key (kbd "") 'toggle-frame-fullscreen) -;; Dired Settings -(require 'dired) -(define-key dired-mode-map (kbd "c") 'find-file) - - -;; Helm Settings -(require 'helm) -(require 'helm-config) - -(global-set-key (kbd "C-c h") 'helm-command-prefix) -(global-unset-key (kbd "C-x c")) - -(global-set-key (kbd "M-x") 'helm-M-x) -(global-set-key (kbd "C-x C-f") 'helm-projectile) -(global-set-key (kbd "M-y") 'helm-show-kill-ring) -(global-set-key (kbd "C-x b") 'helm-mini) -(global-set-key (kbd "C-x C-b") 'helm-buffers-list) -(global-set-key (kbd "C-c h o") 'helm-swoop) - -(define-key helm-map (kbd "") 'helm-execute-persistent-action) -(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) -(define-key helm-map (kbd "C-z") 'helm-select-action) - -(setq helm-buffers-fuzzy-matching t - helm-recentf-fuzzy-match t) - -(setq helm-semantic-fuzzy-match t - helm-imenu-fuzzy-match t) - -(setq helm-locate-fuzzy-match t) - -(helm-mode 1) - - -;; Global search in projects -(global-set-key (kbd "C-x p") 'helm-projectile-ack) - - -;; Ansi Term Settings -;; (define-key 'term-mode-map (kbd "C-h") 'window-left) -;; (define-key 'term-mode-map (kbd "C-l") 'window-right) -;; (define-key 'term-mode-map (kbd "C-k") 'window-up) -;; (define-key 'term-mode-map (kbd "C-j") 'window-down) - - -;; disable popwin-mode in an active Helm session It should be disabled -;; otherwise it will conflict with other window opened by Helm persistent -;; action, such as *Help* window. -(require 'popwin) - -(push '("^\*helm.+\*$" :regexp t) popwin:special-display-config) -(add-hook 'helm-after-initialize-hook (lambda () - (popwin:display-buffer helm-buffer t) - (popwin-mode -1))) - -;; Restore popwin-mode after a Helm session finishes. -(add-hook 'helm-cleanup-hook (lambda () (popwin-mode 1))) - -;; Popwin Helm-Swoop workaround -(defvar helm-swoop-split-window-function - (lambda ($buf) - (display-buffer $buf))) - - -;; Add 80 column marker -(require 'whitespace) -(setq whitespace-line-column 80) ;; limit line length -(setq whitespace-style '(face lines-tail)) -(add-hook 'prog-mode-hook 'whitespace-mode) - - -;; Allow `C-x C-s` to write to unmodified buffers, allowing the file to be `touch`'d -(set-buffer-modified-p t) - - -;; Git-Commit prog-mode -;; (add-hook 'git-commit-mode 'prog-mode) - - -;; Projectile Settings -(projectile-mode t) -(setq projectile-completion-system 'helm) -(helm-projectile-on) -(setq projectile-switch-project-action 'helm-projectile) - - -;; Alchemist Settings -(require 'alchemist) -(setq alchemist-mix-env "prod") - -(setq alchemist-goto-elixir-source-dir "/Users/wpcarro/source_code/elixir") -(setq alchemist-goto-erlang-source-dir "/Users/wpcarro/source_code/otp/") - -;; Borrow keybinding from list-mode eval -(define-key global-map (kbd "C-j") nil) -(define-key alchemist-mode-keymap (kbd "C-j") 'alchemist-eval-current-line) - -;; Allow Elixir -> Erlang -> Elixir definition jumping -(defun custom-erlang-mode-hook () - (define-key erlang-mode-map (kbd "M-,") 'alchemist-goto-jump-back)) - -(add-hook 'erlang-mode-hook 'custom-erlang-mode-hook) - -;; Run tests on file writes -;; (setq alchemist-hooks-test-on-save t) - - -;; Evil Settings -(require 'evil) -(require 'evil-leader) - -(defun register-evil-keybindings-for-neotree () - "Registers keybindings for Evil mode for NeoTree plugin." - (evil-define-key 'normal neotree-mode-map (kbd "TAB") 'neotree-enter) - (evil-define-key 'normal neotree-mode-map (kbd "SPC") 'neotree-enter) - (evil-define-key 'normal neotree-mode-map (kbd "q") 'neotree-hide) - (evil-define-key 'normal neotree-mode-map (kbd "RET") 'neotree-enter)) - -;; Evil colored-cursors -(setq evil-emacs-state-cursor '("red" box)) -(setq evil-normal-state-cursor '("green" box)) -(setq evil-visual-state-cursor '("orange" box)) -(setq evil-insert-state-cursor '("red" bar)) -(setq evil-replace-state-cursor '("red" bar)) -(setq evil-operator-state-cursor '("red" hollow)) - - -;; Display column number alongside row number -(column-number-mode t) - -;; NeoTree Settings -(require 'neotree) - -(defun neotree-project-dir () - "Open NeoTree using the git root." - (interactive) - (let ((project-dir (projectile-project-root)) - (file-name (buffer-file-name))) - (neotree-toggle) - (if project-dir - (if (neo-global--window-exists-p) - (progn - (neotree-dir project-dir) - (neotree-find file-name))) - (message "Could not find git project root.")))) - -(global-set-key (kbd "") 'neotree-project-dir) - -(add-hook 'neotree-mode-hook (lambda () (bootstrap-evil-mode) (hl-line-mode)) ) - - -;; Evil Plugins - -;; Evil Match-it -(require 'evil-matchit) -(global-evil-matchit-mode 1) - -;; Evil Surround -(require 'evil-surround) -(global-evil-surround-mode 1) - - -;; Window movement -(global-set-key (kbd "C-c w f") 'windmove-right) -(global-set-key (kbd "C-c w b") 'windmove-left) -(global-set-key (kbd "C-c w p") 'windmove-up) -(global-set-key (kbd "C-c w n") 'windmove-down) - - ;; General Settings ;; Hide the menu-bar (setq ns-auto-hide-menu-bar t) @@ -290,63 +348,48 @@ (set-frame-font "Operator Mono 10") -;; Personalized Evil-mode settings -(defun bootstrap-evil-mode() - "Custom evil-mode settings. This disables Emacs key-bindings found in -`global-map` when inside Vim's `normal` mode. It disables Vim key-bindings -when in Vim's `insert` mode, favoring native Emacs bindings instead." +;; Force save buffers +(defun save-buffer-always () + "Save the buffer even if it is not modified." (interactive) - (evil-local-mode t) + (set-buffer-modified-p t) + (save-buffer)) - ;; Evil-leader - (global-evil-leader-mode) - (evil-leader/set-leader (kbd "SPC")) - - ;; Toggle off Emacs bindings when in Vim `normal` mode except: - ;; * `M-x` - ;; (setcdr global-map nil) - ;; (define-key global-map (kbd "M-x") 'helm-M-x) - - (define-key evil-normal-state-map (kbd "") nil) - - ;; unbind and in normal mode since they're hardly used - (define-key evil-motion-state-map (kbd "RET") nil) - (define-key evil-motion-state-map (kbd "SPC") nil) - (define-key evil-normal-state-map (kbd "M-.") nil) - - ;; use 'helm-swoop for interactive search - (define-key evil-motion-state-map (kbd "/") 'helm-swoop) - (define-key evil-motion-state-map (kbd "?") 'helm-swoop) - - (define-key evil-normal-state-map (kbd "C-h") 'evil-window-left) - (define-key evil-normal-state-map (kbd "C-l") 'evil-window-right) - (define-key evil-normal-state-map (kbd "C-k") 'evil-window-up) - (define-key evil-normal-state-map (kbd "C-j") 'evil-window-down) - - (define-key evil-normal-state-map (kbd "M-l") (lambda () (interactive) (evil-window-vsplit) (evil-window-right 1) )) - (define-key evil-normal-state-map (kbd "M-h") (lambda () (interactive) (evil-window-vsplit) )) - (define-key evil-normal-state-map (kbd "M-j") (lambda () (interactive) (evil-window-split) (evil-window-down 1) )) - (define-key evil-normal-state-map (kbd "M-k") (lambda () (interactive) (evil-window-split) )) - - ;; Plugin-specific keybindings - (register-evil-keybindings-for-neotree) - - ;; Toggle off Vim bindings when in Vim `insert` mode except: - ;; * `` - ;; * `j k` - ;; * `j j` "j" - (setcdr evil-insert-state-map nil) - (define-key evil-insert-state-map (kbd "") 'evil-force-normal-state) - (define-key evil-insert-state-map (kbd "j k") 'evil-force-normal-state) - (define-key evil-insert-state-map (kbd "jj") (lambda () (interactive) (insert "j"))) - - (define-key evil-normal-state-map (kbd "H") 'evil-first-non-blank) - (define-key evil-normal-state-map (kbd "L") 'evil-end-of-line)) +(global-set-key (kbd "C-x C-s") nil) +(global-set-key (kbd "C-x C-s") 'save-buffer-always) -;; Line Numbers in margin for source code mode -(add-hook 'prog-mode-hook 'linum-mode) -(add-hook 'prog-mode-hook 'bootstrap-evil-mode) +;; Upgrade all packages +(defun package-upgrade-all () + "Upgrade all packages automatically without showing *Packages* buffer." + (interactive) + (package-refresh-contents) + (let (upgrades) + (cl-flet ((get-version (name where) + (let ((pkg (cadr (assq name where)))) + (when pkg + (package-desc-version pkg))))) + (dolist (package (mapcar #'car package-alist)) + (let ((in-archive (get-version package package-archive-contents))) + (when (and in-archive + (version-list-< (get-version package package-alist) + in-archive)) + (push (cadr (assq package package-archive-contents)) + upgrades))))) + (if upgrades + (when (yes-or-no-p + (message "Upgrade %d package%s (%s)? " + (length upgrades) + (if (= (length upgrades) 1) "" "s") + (mapconcat #'package-desc-full-name upgrades ", "))) + (save-window-excursion + (dolist (package-desc upgrades) + (let ((old-package (cadr (assq (package-desc-name package-desc) + package-alist)))) + (package-install package-desc) + (package-delete old-package))))) + (message "All packages are up to date")))) + ;; Add transparency (set-frame-parameter (selected-frame) 'alpha '(95 . 95)) diff --git a/configs/.zsh_profile b/configs/.zsh_profile index 331b4b5f8..9f4ad6622 100644 --- a/configs/.zsh_profile +++ b/configs/.zsh_profile @@ -6,6 +6,7 @@ export EDITOR=$(which vim) echo "Welcome back, $USER" + # display the space available on each mounted Volume df -hl @@ -50,4 +51,3 @@ stty -ixon # Run Autojump at shell startup [[ $(brew --prefix)/etc/profile.d/autojump.sh ]] && \ . $(brew --prefix)/etc/profile.d/autojump.sh -