From 5da8ddda2a41af386e87d758fdcbcd1542cd333a Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 15 Jul 2014 02:21:56 -0400 Subject: [PATCH] Config file commit --- elisp/evil-ex-registers.el | 65 +++++++++++++++++ elisp/rotate-text.el | 89 +++++++++++++++++++++++ init.el | 62 ++++++++++++++++ init/core-editor.el | 144 +++++++++++++++++++++++++++++++++++++ init/core-keymaps.el | 128 +++++++++++++++++++++++++++++++++ init/core-osx.el | 52 ++++++++++++++ init/core-packages.el | 65 +++++++++++++++++ init/core-project.el | 53 ++++++++++++++ init/core-ui.el | 45 ++++++++++++ init/core.el | 89 +++++++++++++++++++++++ 10 files changed, 792 insertions(+) create mode 100644 elisp/evil-ex-registers.el create mode 100644 elisp/rotate-text.el create mode 100644 init.el create mode 100644 init/core-editor.el create mode 100644 init/core-keymaps.el create mode 100644 init/core-osx.el create mode 100644 init/core-packages.el create mode 100644 init/core-project.el create mode 100644 init/core-ui.el create mode 100644 init/core.el diff --git a/elisp/evil-ex-registers.el b/elisp/evil-ex-registers.el new file mode 100644 index 000000000..6397e7ff5 --- /dev/null +++ b/elisp/evil-ex-registers.el @@ -0,0 +1,65 @@ +;;; evil-ex-registers.el --- Command to paste from register in ex mode + +;; Author: INA Lintaro +;; URL: http://github.com/tarao/evil-plugins +;; Version: 0.1 +;; Keywords: evil, plugin + +;; This file is NOT part of GNU Emacs. + +;;; License: +;; +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Code: + +(require 'evil) +(eval-when-compile (require 'cl)) + +(defalias 'evil-orig-get-register (symbol-function 'evil-get-register)) + +(defun evil-get-spec-register (register &optional noerror) + "Return contents of REGISTER. +Signal an error if empty, unless NOERROR is non-nil. + +Support some registers listed below in addition to +`evil-get-register'. +  the file name under the cursor +  the expanded file name under the cursor +  the word under the cursor +  the WORD under the cursor" + (cond + ((or (= register ?\C-f) ; ^F the filename under the cursor + (= register ?\C-p)) ; ^P the expanded filename under the cursor + (let ((file (thing-at-point 'filename))) + (or (and file (= register ?\C-p) (expand-file-name file)) file))) + ((or (= register ?\C-w) ; ^W the word under the cursor + (= register ?\C-a)) ; ^A the WORD under the cursor + (let* ((word (if (= register ?\C-a) #'evil-move-WORD #'evil-move-word)) + (range (evil-inner-object-range nil nil nil nil word))) + (filter-buffer-substring (nth 0 range) (nth 1 range)))) + (t (evil-orig-get-register register noerror)))) + +(defun evil-ex-paste-from-register (&optional register) + "Paste from REGISTER in command line." + (interactive) + (flet ((evil-get-register (register &optional noerror) + (with-current-buffer evil-ex-current-buffer + (evil-get-spec-register register noerror)))) + (if (called-interactively-p 'any) + (call-interactively #'evil-paste-from-register) + (evil-paste-from-register register)))) + +(provide 'evil-ex-registers) +;;; evil-ex-registers.el ends here diff --git a/elisp/rotate-text.el b/elisp/rotate-text.el new file mode 100644 index 000000000..3fb2b2ae1 --- /dev/null +++ b/elisp/rotate-text.el @@ -0,0 +1,89 @@ +;; From + +(defvar rotate-text-rotations + '(("true" "false") + ("yes" "no") + ("left" "right" "top" "bottom") + ("width" "height")) + "List of text rotation sets.") + +(defun rotate-region (beg end) + "Rotate all matches in `rotate-text-rotations' between point and mark." + (interactive "r") + (let ((regexp (rotate-convert-rotations-to-regexp + rotate-text-rotations)) + (end-mark (copy-marker end))) + (save-excursion + (goto-char beg) + (while (re-search-forward regexp (marker-position end-mark) t) + (let* ((found (match-string 0)) + (replace (rotate-next found))) + (replace-match replace)))))) + +(defun rotate-string (string &optional rotations) + "Rotate all matches in STRING using associations in ROTATIONS. +If ROTATIONS are not given it defaults to `rotate-text-rotations'." + (let ((regexp (rotate-convert-rotations-to-regexp + (or rotations rotate-text-rotations))) + (start 0)) + (while (string-match regexp string start) + (let* ((found (match-string 0 string)) + (replace (rotate-next + found + (or rotations rotate-text-rotations)))) + (setq start (+ (match-end 0) + (- (length replace) (length found)))) + (setq string (replace-match replace nil t string)))) + string)) + +(defun rotate-next (string &optional rotations) + "Return the next element after STRING in ROTATIONS." + (let ((rots (rotate-get-rotations-for + string + (or rotations rotate-text-rotations)))) + (if (> (length rots) 1) + (error (format "Ambiguous rotation for %s" string)) + (if (< (length rots) 1) + ;; If we get this far, this should not occur: + (error (format "Unknown rotation for %s" string)) + (let ((occurs-in-rots (member string (car rots)))) + (if (null occurs-in-rots) + ;; If we get this far, this should *never* occur: + (error (format "Unknown rotation for %s" string)) + (if (null (cdr occurs-in-rots)) + (caar rots) + (cadr occurs-in-rots)))))))) + +(defun rotate-get-rotations-for (string &optional rotations) + "Return the string rotations for STRING in ROTATIONS." + (remq nil (mapcar (lambda (rot) (if (member string rot) rot)) + (or rotations rotate-text-rotations)))) + +(defun rotate-convert-rotations-to-regexp (rotations) + (regexp-opt (rotate-flatten-list rotations))) + +(defun rotate-flatten-list (list-of-lists) + "Flatten LIST-OF-LISTS to a single list. +Example: + (rotate-flatten-list '((a b c) (1 ((2 3))))) + => (a b c 1 2 3)" + (if (null list-of-lists) + list-of-lists + (if (listp list-of-lists) + (append (rotate-flatten-list (car list-of-lists)) + (rotate-flatten-list (cdr list-of-lists))) + (list list-of-lists)))) + +(defun rotate-word-at-point () + "Rotate word at point based on sets in `rotate-text-rotations'." + (interactive) + (let ((bounds (bounds-of-thing-at-point 'word)) + (opoint (point))) + (when (consp bounds) + (let ((beg (car bounds)) + (end (copy-marker (cdr bounds)))) + (rotate-region beg end) + (goto-char (if (> opoint end) end opoint)))))) + + +(provide 'rotate-text) diff --git a/init.el b/init.el new file mode 100644 index 000000000..6bcc781d2 --- /dev/null +++ b/init.el @@ -0,0 +1,62 @@ +;;;; core.el - Emacs for the jaded Vimmer +;; +;; Author: Henrik Lissner +;; URL: https://github.com/hlissner/emacs.d +;; +;; These settings set up a very vim-like experience, with some of emacs goodness +;; squeezed in between the cracks. + +(cd "~") ; Default directory, instead of / +(setq load-prefer-newer t) ; Always load newest byte code + +;; Global vars +(defvar my-dir (file-name-directory load-file-name)) +(defvar my-core-dir (expand-file-name "init" my-dir)) +(defvar my-modules-dir (expand-file-name "modules" my-dir)) +(defvar my-themes-dir (expand-file-name "themes" my-dir)) +(defvar my-elisp-dir (expand-file-name "elisp" my-dir)) +(defvar my-tmp-dir (expand-file-name "tmp" my-dir)) + +;; Setup loadpaths +(add-to-list 'load-path my-core-dir) +(add-to-list 'load-path my-modules-dir) +(add-to-list 'load-path my-elisp-dir) +(add-to-list 'custom-theme-load-path my-themes-dir) + +;; Font & color scheme +(load-theme 'brin t) +(defvar my-font "Ubuntu Mono-15") + +;;;;;;;;;;;;;;;;;;;;;;; +;; Bootstrap +;;;;;;;;;;;;;;;;;;;;;;; + +(dolist (module '( + core ; Emacs core settings + core-packages ; package init & management + core-ui ; Look and behavior of the emacs UI + core-editor ; Text/code editor settings and behavior + core-project ; Project navigation settings & packages + core-osx ; OSX-specific settings & functions + core-keymaps ; Global & local keybindings for all modes + + ;; Editor essentials + ; mod-snippets ; Snippet templates + ; mod-git ; GIT tools/settings + ; mod-writer ; Setup/settings for non-code writing + ; mod-shell ; Goodies for running shell in emacs + ; mod-webdev ; Webdev tools (sass, js, etc) + ; mod-gamedev ; Gamedev tools (C++, love2D, html5) + )) + (require module)) + + +;;;; Modes ;;;;;;;;;;;;;;;;;;;;;;;; + +; (associate-mode '(".rb" "RakeFile") 'ruby-mode) +; (associate-mode '(".md" ".markdown") 'markdown-mode) +; (associate-mode ".lua" 'lua-mode) +; (associate-mode ".scss" 'scss-mode) +; (associate-mode ".yml" 'yaml-mode) +; (associate-mode '(".js" ".json") 'js2-mode) +; (associate-mode ".py" 'python-mode) diff --git a/init/core-editor.el b/init/core-editor.el new file mode 100644 index 000000000..46e278bec --- /dev/null +++ b/init/core-editor.el @@ -0,0 +1,144 @@ +(require-package 'evil) +(evil-mode 1) + +(require-packages + '(evil-leader + evil-nerd-commenter ; auto commenting made easy + evil-matchit ; jumping between block delimiters + evil-surround ; surround-with delimiters + evil-numbers ; increment/decrement numbers + evil-exchange ; exchanging two text objects (gx/gX) + evil-space ; mimics ; and , for f, F, t, T w/ space + evil-visualstar ; visual-based * and # + + evil-ex-registers ; paste from registers in ex commands + + auto-complete ; self-explanity + auto-complete-config ; its default config + fuzzy ; fuzzy search engine for auto-complete + + autopair ; delimiter auto-closing + yasnippet + rainbow-delimiters ; colored matching parenthesis + rainbow-mode ; highlight color codes + highlight-indentation ; visual indentation guides + + diminish ; shrinks/removes modeline elements + saveplace ; restore cursor position on buffer load + volatile-highlights ; temporarily highlight changes on undo/yank + anzu ; display current + total matches searching + smex ; less M-x cruft + + rotate-text ; like vim-switch + uniquify ; unique buffer names for identical filenames + recentf ; access to list of recent files + ediff + )) + + +;;;; Editor behavior ;;;;;;;;;;;;;;;; + +(smex-initialize) +(electric-indent-mode +1) +(global-hl-line-mode +1) ; highlight the line +(setq blink-matching-paren nil) ; disable blink-matching-paren +(setq-default + tab-width 4 ; set tab width to 4 for all buffers + indent-tabs-mode nil ; always replace tabs with spaces + tab-always-indent nil) + +;; do not soft-wrap lines +(setq-default truncate-lines t) +(setq truncate-partial-width-windows nil) + +;; Line numbers & rainbow delimiters in all code-related major modes +(add-hook 'prog-mode-hook 'linum-on) +(add-hook 'prog-mode-hook 'rainbow-delimiters-mode) +(add-hook 'prog-mode-hook #'highlight-indentation-mode) + +;; Remove trailing whitespace +(add-hook 'before-save-hook 'delete-trailing-whitespace) + +;; Dynamic linum with +1 padding +(defadvice linum-update-window (around linum-dynamic activate) + (let* ((w (length (number-to-string (count-lines (point-min) (point-max))))) + (linum-format (concat "%" (number-to-string (+ w 1)) "d "))) ad-do-it)) + + +;;;; Init plugins ;;;;;;;;;;;;;;;;;;; + +(global-evil-leader-mode) +(global-evil-matchit-mode 1) +(global-evil-surround-mode 1) +(evil-exchange-install) + +(evil-space-setup "t" ";" ",") +(evil-space-setup "f" ";" ",") +(evil-space-setup "T" "," ";") +(evil-space-setup "F" "," ";") + +(yas-global-mode -1) + +;;#autopair +(autopair-global-mode) +(diminish 'autopair-mode) + +;;#anzu +(global-anzu-mode) +(diminish 'anzu-mode) + +;;#ediff +(setq ediff-window-setup-function 'ediff-setup-windows-plain) + +;;#volatile-highlights +(volatile-highlights-mode t) +(diminish 'volatile-highlights-mode) + +;;#saveplace +(setq-default save-place t) +(setq save-place-file (expand-file-name "saveplace" my-tmp-dir)) + +;;#savehist +(setq savehist-additional-variables + ;; search entries + '(search ring regexp-search-ring) + ;; save every 5 minutes + savehist-autosave-interval 300 + ;; keep the home clean + savehist-file (expand-file-name "savehist" my-tmp-dir)) +(savehist-mode 1) + +;;#diminish +; (diminish 'whole-line-or-region-mode) +(diminish 'undo-tree-mode) +(diminish 'highlight-indentation-mode) + +;;#uniquify +(setq uniquify-buffer-name-style 'forward) +(setq uniquify-separator "/") +(setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified +(setq uniquify-ignore-buffers-re "^\\*") ; don't muck with special buffers + +;;#recentf +(recentf-mode 1) +(setq recentf-max-menu-items 50) + + +;;;; Auto-completion ;;;;;;;;;;;;;; + +(ac-config-default) +(ac-linum-workaround) ; Fix line number flux bug +(diminish 'auto-complete-mode) + +(add-hook 'prog-mode-hook 'enable-path-completion) +(setq ac-auto-show-menu nil ; Suggestions box must be invoked manually (see core-keymaps.el) + ac-use-menu-map t ; Enable ac-menu-map map when menu is open + ac-us-quick-help nil) ; Don't show tooltips unless invoked (see core-keymaps.el) + +(defun enable-path-completion () + (add-to-list 'ac-sources 'ac-source-filename) + (add-to-list 'ac-sources 'ac-source-files-in-current-dir)) + + +;; +(provide 'core-editor) diff --git a/init/core-keymaps.el b/init/core-keymaps.el new file mode 100644 index 000000000..5b3f6051a --- /dev/null +++ b/init/core-keymaps.el @@ -0,0 +1,128 @@ +(require-package 'key-chord) +(key-chord-mode 1) +(setq key-chord-two-keys-delay 0.5) + +;; Global keymaps ;;;;;;;;;;;;;;; + +(gmap (kbd "C-x C-p") 'package-list-packages) +(gmap (kbd "M-x") 'smex) +(gmap (kbd "M-X") 'smex-major-mode-commands) + +(if (is-osx) (progn + (gmap (kbd "s-+") 'text-scale-increase) + (gmap (kbd "s--") 'text-scale-decrease) + + (map (kbd "C-c o") 'send-to-finder) + (map (kbd "C-c u") 'send-to-transmit) + (map (kbd "C-c l") 'send-to-launchbar) + (map (kbd "C-c L") 'send-dir-to-launchbar) + (emap 'normal (kbd "C-c e") 'eval-buffer) + (emap 'visual (kbd "C-c e") 'eval-region) +)) + +(map (kbd "C-c t") (lambda() (interactive) (eshell t))) +(map (kbd "C-c g") 'magit-status) +(map (kbd "") 'evil-numbers/inc-at-pt) +(map (kbd "") 'evil-numbers/dec-at-pt) + +(map (kbd "s-o") 'ido-find-file) +(map (kbd "s-p") 'projectile-switch-project) +(map (kbd "s-f") 'projectile-find-file) +(map (kbd "s-F") 'projectile-ag) +(map (kbd "s-R") 'projectile-recentf) + +(define-key evil-ex-completion-map (kbd "C-r") #'evil-ex-paste-from-register) + + +;; Local keymaps ;;;;;;;;;;;;;;;; + +(evil-leader/set-leader ",") +(evil-leader/set-key + "e" 'my-conf-edit + "E" 'my-conf-find + "/" 'imenu + "\\" 'toggle-speedbar + ";" 'helm-imenu + "," 'ido-switch-buffer + "=" 'align-regexp) + +(nmap ";" 'exil-ex) + +;; Easy escape from insert mode +(ichmap "jj" 'evil-normal-state) + +;; Moving rows rather than lines (in case of wrapping) +(nmap "j" 'evil-next-visual-line) +(nmap "k" 'evil-previous-visual-line) + +;; Commenting lines +(nmap "gcc" 'evilnc-comment-or-uncomment-lines) +(vmap "gc" 'evilnc-comment-or-uncomment-lines) + +;; Enable TAB to do matchit (won't work in visual) +(evil-define-key 'normal evil-matchit-mode-map (kbd "TAB") 'evilmi-jump-items) + +;; Delete without yanking +(evil-define-operator evil-destroy (beg end type register yank-handler) + (evil-delete beg end type ?_ yank-handler)) +(nmap "X" 'evil-destroy) +(nmap "Y" 'copy-to-end-of-line) ; nnoremap Y y$ +(nmap "zz" 'kill-this-buffer) ; Close buffer + +;; vnoremap < >gv +(vmap (kbd "<") + (lambda () + (interactive) + (evil-shift-left (region-beginning) (region-end)) + (evil-normal-state) + (evil-visual-restore))) +(vmap (kbd ">") + (lambda () + (interactive) + (evil-shift-right (region-beginning) (region-end)) + (evil-normal-state) + (evil-visual-restore))) + +;; Sets fn-delete to be right-delete +(imap (kbd "") 'evil-delete-char) + +;; Buffer navigation +(nmap "[b" 'previous-buffer) +(nmap "]b" 'next-buffer) + +;; winner-mode: window layout undo/redo (see init-core.el) +(nmap (kbd "C-w u") 'winner-undo) +(nmap (kbd "C-w C-r") 'winner-redo) + +;; Make ESC quit all the things +(nmap [escape] 'keyboard-quit) +(vmap [escape] 'keyboard-quit) +(define-key minibuffer-local-map [escape] 'minibuffer-quit) +(define-key minibuffer-local-ns-map [escape] 'minibuffer-quit) +(define-key minibuffer-local-completion-map [escape] 'minibuffer-quit) +(define-key minibuffer-local-must-match-map [escape] 'minibuffer-quit) +(define-key minibuffer-local-isearch-map [escape] 'minibuffer-quit) +(global-set-key [escape] 'evil-exit-emacs-state) + +;; Restore bash-esque C-w/C-a/C-e in insert mode and the minibuffer +(dolist (x (list minibuffer-local-map evil-insert-state-map)) + (define-key x (kbd "C-w") 'backward-kill-word) + (define-key x (kbd "C-a") 'move-beginning-of-line) + (define-key x (kbd "C-e") 'move-end-of-line) + (define-key x (kbd "C-u") 'backward-kill-line)) + +;; Auto-completion +(imap (kbd "C-SPC") 'ac-fuzzy-complete) +(imap (kbd "C-S-SPC") 'ac-quick-help) + +;; see elisp/rotate-text.el +(nmap (kbd "RET") 'rotate-word-at-point) +(vmap (kbd "RET") 'rotate-region) + + +;;;; Ex Commands ;;;;;;;;;;;;;;;; + +(cmap "e[dit]" 'ido-find-file) + +(provide 'core-keymaps) diff --git a/init/core-osx.el b/init/core-osx.el new file mode 100644 index 000000000..9b042d772 --- /dev/null +++ b/init/core-osx.el @@ -0,0 +1,52 @@ +;; OSX-specific functionality +(if (is-osx) (progn + + ;; Ignore .DS_Store files with ido mode + (add-to-list 'ido-ignore-files "\\.DS_Store") + + (if window-system (progn + (setq ns-use-native-fullscreen nil) + (global-set-key (kbd "s-") 'toggle-frame-fullscreen) + + (x-focus-frame nil) + ;; Don't open files from the workspace in a new frame + (setq ns-pop-up-frames nil) + )) + + ;; Send current file to OSX apps + (defun open-file-with (path &optional appName) + (if (not (string= "" appName)) + (setq appName (concat "-a " appName ".app"))) + (shell-command (concat "open " appName " " path))) + + (defun open-with (appName) + (interactive) + (open-file-with (buffer-file-name) appName)) + + (defun send-to-transmit () (open-with "Transmit")) + (defun send-to-launchbar () (open-with "LaunchBar")) + (defun send-dir-to-launchbar () (open-file-with default-directory "LaunchBar")) + (defun send-dir-to-finder () (open-file-with default-directory "Finder")) + (defun open-in-terminal () (ansi-term "/bin/zsh")) + + (after 'evil + (gmap (kbd "s-/") 'evilnc-comment-or-uncomment-lines) + (gmap (kbd "s-w") 'evil-window-delete) + + ;; Fast scrolling + (nmap (kbd "s-j") "jjjjj") + (nmap (kbd "s-k") "kkkkk") + + ;; Newlines from insert mode + (imap (kbd "") 'evil-open-below) + (imap (kbd "") 'evil-open-above) + + ;; Fix OSX text navigation shortcuts + (imap (kbd "") 'move-beginning-of-line) + (imap (kbd "") 'move-end-of-line) + (imap (kbd "") 'backward-kill-line) + ) +)) + +;; +(provide 'core-osx) diff --git a/init/core-packages.el b/init/core-packages.el new file mode 100644 index 000000000..bb478e6b0 --- /dev/null +++ b/init/core-packages.el @@ -0,0 +1,65 @@ +;; Package management bootstrap +(setq package-user-dir "~/.emacs.d/vendor/") +(setq package-enable-at-startup nil) +(setq package-archives '(("melpa" . "http://melpa.milkbox.net/packages/") + ("org" . "http://orgmode.org/elpa/") + ("marmalade" . "http://marmalade-repo.org/packages/") + ("gnu" . "http://elpa.gnu.org/packages/"))) + +(let ((default-directory my-elisp-dir)) + (normal-top-level-add-to-load-path '(".")) + (normal-top-level-add-subdirs-to-load-path)) + +(package-initialize) + +;; Run a body of code *after* a package is ready +(defmacro after (feature &rest body) + "After FEATURE is loaded, evaluate BODY." + (declare (indent defun)) + (if (fboundp 'with-eval-after-load) + `(with-eval-after-load ,feature ,@body) + `(eval-after-load ,feature '(progn ,@body)))) + +;; Check if a package is installed; if load is t, load it too. +;; Works for packages bundled with emacs too! +(defun require-package (package &optional dont_load) + (unless (require package nil 'noerror) + (init-package package dont_load))) + +;; List version of require-package +(defun require-packages (packages &optional dont_load) + (dolist (pkg packages) (require-package pkg dont_load))) + +;; Install the package if it isn't already, and require it, unless +;; told others. +(defun init-package (package &optional dont_load) + (unless (package-installed-p package) + (unless (assoc package package-archive-contents) + (package-refresh-contents)) + (package-install package)) + (if (not dont_load) (require package))) + +;; Associate an extension with a mode, and install the necessary +;; package for it. +;; +;; TODO: Rewrite this +(defun associate-mode (ext mode) + (let* ((mode_name (symbol-name mode)) + (env_mode_name (concat "env-" mode_name ".el")) + (mode_path (expand-file-name env_mode_name my-modules-dir))) + + (condition-case nil + (init-package mode t) + (error nil)) + + (autoload mode mode_name) + (if (file-exists-p mode_path) + (autoload mode env_mode_name))) + + (if (typep ext 'list) + (dolist (e ext) + (add-to-list 'auto-mode-alist `(,(format "\\%s\\'" e) . ,mode))) + (add-to-list 'auto-mode-alist `(,(format "\\%s\\'" ext) . ,mode)))) + +;; +(provide 'core-packages) diff --git a/init/core-project.el b/init/core-project.el new file mode 100644 index 000000000..b6e2a7485 --- /dev/null +++ b/init/core-project.el @@ -0,0 +1,53 @@ +(require-packages + '(ido-ubiquitous ; enhances ido-everywhere + projectile ; project search (like ctrlp) + helm ; augments search of, well, anything + grizzl ; better searching engine for projectile + ag ; the_silver_searcher support + sr-speedbar ; Speedbar, w/o the separate frame + flx-ido ; Enhances ido's flex matching + )) + +;;#dired +(setq dired-recursive-deletes 'always + dired-recursive-copies 'always + + ;; if there is a dired buffer displayed in the next window, use its + ;; current subdir, instead of the current subdir of this dired buffer + dired-dwim-target t) + +;; ido remaps its keys every time it's invoked, this screws with +;; custom mappings. So we've gotta neuter ido. +(defun ido-init-completion-maps ()) + +(setq ido-common-completion-map (make-sparse-keymap)) +(setq ido-file-dir-completion-map (make-sparse-keymap)) +(setq ido-file-completion-map (make-sparse-keymap)) +(setq ido-buffer-completion-map (make-sparse-keymap)) + +(set-keymap-parent ido-common-completion-map minibuffer-local-map) +(set-keymap-parent ido-file-dir-completion-map ido-common-completion-map) +(set-keymap-parent ido-file-completion-map ido-file-dir-completion-map) +(set-keymap-parent ido-buffer-completion-map ido-common-completion-map) + +(ido-mode 1) +(ido-everywhere 1) +(flx-ido-mode 1) +(setq ido-use-faces nil + ido-confirm-unique-completion t + ido-case-fold t + ido-enable-tramp-completion nil + ido-enable-flex-matching t + ido-create-new-buffer 'always + ido-enable-tramp-completion t + ido-enable-last-directory-history t) + +;;#projectile +(setq projectile-completion-system 'grizzl + projectile-enable-caching t) + +;;#sr-speedbar +(setq speedbar-use-images nil) + +;; +(provide 'core-project) diff --git a/init/core-ui.el b/init/core-ui.el new file mode 100644 index 000000000..fe4080980 --- /dev/null +++ b/init/core-ui.el @@ -0,0 +1,45 @@ + +;;;; UI Behavior ;;;;;;;;;;;;;;;;;;;;;; + +(setq inhibit-startup-screen t) + +(setq scroll-margin 3 + scroll-conservatively 100000 + scroll-preserve-screen-position 1) + +;; mode line settings +(line-number-mode t) +(column-number-mode t) +(size-indication-mode t) + +;; y/n instead of yes/no +(fset 'yes-or-no-p 'y-or-n-p) + +;; make the fringe (gutter) smaller +;; the argument is a width in pixels (the default is 8) +(if (fboundp 'fringe-mode) + (fringe-mode 4)) + + +;;;; GUI Settings ;;;;;;;;;;;;;;;;;;;;; + +; (set-face-attribute 'default t :font 'my-font ) +(add-to-list 'default-frame-alist `(font . ,my-font)) +(add-to-list 'default-frame-alist '(width . 100)) +(add-to-list 'default-frame-alist '(height . 75)) +(add-to-list 'default-frame-alist '(alpha 98 95)) ; *slightly* transparent window + +; (set-face-attribute 'mode-line nil :box '(:line-width 4 :color "#1f2g2a" )) + +(if window-system (progn + (tool-bar-mode -1) + (scroll-bar-mode -1) + + ; Use system clipboard + (setq x-select-enable-clipboard t) + (setq-default line-spacing 1) + (setq ring-bell-function 'ignore) +) (menu-bar-mode -1)) + +;; +(provide 'core-ui) diff --git a/init/core.el b/init/core.el new file mode 100644 index 000000000..a7edf1cd5 --- /dev/null +++ b/init/core.el @@ -0,0 +1,89 @@ +(require 'cl) + +;; Emacs under-the-hood +(prefer-coding-system 'utf-8) +(setq-default gc-cons-threshold 50000000) ; avoid garbage collection (default is only 400k) +(setq make-backup-files nil) ; Don't want any backup files +(setq auto-save-list-file-name nil) ; Don't want any .saves files +(setq auto-save-default nil) ; Don't want any auto saving + +;; If I ever enable bkacups/autosaves, then change where they go +(setq backup-directory-alist `((".*" . ,my-tmp-dir))) +(setq auto-save-file-name-transforms `((".*" ,my-tmp-dir t))) + +;; Always revert buffers if the files were changed +(global-auto-revert-mode 1) + +; window layout undo/redo, keymaps in init-evil.el +(when (fboundp 'winner-mode) (winner-mode 1)) +(setq linum-delay t) + +;;;; My personal minor mode ;;;;;;;; + +(defvar my-mode-map (make-sparse-keymap)) +(define-minor-mode my-mode :keymap my-mode-map) + + +;;;; Commands ;;;;;;;;;;;;;;;;;;;;;; + +(defun minibuffer-quit () + "Abort recursive edit. + In Delete Selection mode, if the mark is active, just deactivate it; + then it takes a second \\[keyboard-quit] to abort the minibuffer." + (interactive) + (if (and delete-selection-mode transient-mark-mode mark-active) + (setq deactivate-mark t) + (when (get-buffer "*Completions*") (delete-windows-on "*Completions*")) + (abort-recursive-edit))) + +;; File navigation defuns +(defun my-conf-edit () + (interactive) + (find-file (expand-file-name "init.el" my-dir))) + +(defun my-conf-find () + (interactive) + (projectile-find-file-in-directory my-dir)) + +;; +(defun copy-to-end-of-line () + (interactive) + (evil-yank (point) (point-at-eol))) + +(defun backward-kill-line () + (interactive) + (evil-delete (point-at-bol) (point))) + +(defun toggle-sidebar () + (interactive) + (sr-speedbar-toggle) + (sr-speedbar-refresh-turn-off)) + + +;;;; Macros ;;;;;;;;;;;;;;;;;;;;;;;; + +;; Vimmish keymapping shortcuts +(defmacro gmap (key command) `(global-set-key ,key ,command)) +(defmacro nmap (key command) `(define-key evil-normal-state-map ,key ,command)) +(defmacro vmap (key command) `(define-key evil-visual-state-map ,key ,command)) +(defmacro imap (key command) `(define-key evil-insert-state-map ,key ,command)) +(defmacro ichmap (key command) `(key-chord-define evil-insert-state-map ,key ,command)) +(defmacro cmap (ex function) `(evil-ex-define-cmd ,ex ,function)) + +;; This one's unique for my own special mappings +(defmacro map (key command) + `(define-key my-mode-map ,key ,command)) +(defmacro emap (mode key command) + `(evil-define-key ,mode my-mode-map ,key ,command)) + +(defmacro is-osx () '(eq system-type 'darwin)) + + +;;;; Defuns ;;;;;;;;;;;;;;;;;;;;;;; + +(defun linum-on () (linum-mode 0)) +(defun linum-off () (linum-mode 0)) + + +;; +(provide 'core)