init.el
changeset 82 12cf67bc486c
parent 78 7d7662fcc8d1
child 84 2ad7a42a31f7
equal deleted inserted replaced
81:4da7819d1a1c 82:12cf67bc486c
     3 
     3 
     4 ;;;; General ;;;;
     4 ;;;; General ;;;;
     5 (add-to-list 'load-path "~/.emacs.d/elisp")   ; set default emacs load path
     5 (add-to-list 'load-path "~/.emacs.d/elisp")   ; set default emacs load path
     6 
     6 
     7 (setq-default
     7 (setq-default
       
     8  gc-cons-threshold 20000000                   ; gc every 20 MB allocated (form flx-ido docs)
     8  ediff-split-window-function
     9  ediff-split-window-function
     9  'split-window-horizontally                   ; diff horizontally
    10  'split-window-horizontally                   ; diff horizontally
    10  inhibit-splash-screen t                      ; disable splash screen
    11  inhibit-splash-screen t                      ; disable splash screen
    11  truncate-lines t                             ; truncate, not wrap, lines
    12  truncate-lines t                             ; truncate, not wrap, lines
    12  indent-tabs-mode nil                         ; only uses spaces for indentation
    13  indent-tabs-mode nil                         ; only uses spaces for indentation
    21 
    22 
    22 (column-number-mode t)                        ; show column numbers
    23 (column-number-mode t)                        ; show column numbers
    23 (delete-selection-mode t)                     ; replace highlighted text
    24 (delete-selection-mode t)                     ; replace highlighted text
    24 (windmove-default-keybindings)                ; move between windows with shift-arrow
    25 (windmove-default-keybindings)                ; move between windows with shift-arrow
    25 (fset 'yes-or-no-p 'y-or-n-p)                 ; replace yes/no prompts
    26 (fset 'yes-or-no-p 'y-or-n-p)                 ; replace yes/no prompts
    26 ;; (global-hl-line-mode t)                    ; highlight current line
       
    27 
    27 
    28 
    28 
    29 ;;; Coding
    29 ;;; Coding
    30 (which-func-mode t)                           ; show current function
    30 (which-func-mode t)                           ; show current function
    31 (show-paren-mode t)                           ; show matching paren
       
    32 (transient-mark-mode t)                       ; show highlighting
    31 (transient-mark-mode t)                       ; show highlighting
    33 (global-font-lock-mode t)                     ; syntax highlighting
    32 (global-font-lock-mode t)                     ; syntax highlighting
    34 (global-set-key (kbd "C-c c") 'compile)       ; compile
    33 (global-set-key (kbd "C-c c") 'compile)       ; compile
    35 (global-set-key (kbd "C-c r") 'recompile)     ; recompile
    34 (global-set-key (kbd "C-c r") 'recompile)     ; recompile
    36 (global-set-key (kbd "C-c a") 'align-regexp)  ; align
    35 (global-set-key (kbd "C-c a") 'align-regexp)  ; align
    55   (unless is-mac (menu-bar-mode -1))          ; remove menu bar
    54   (unless is-mac (menu-bar-mode -1))          ; remove menu bar
    56   (visual-line-mode t)                        ; word wrap break on whitespace
    55   (visual-line-mode t)                        ; word wrap break on whitespace
    57   (set-default-font (if is-mac "Ubuntu Mono-12" "Ubuntu Mono-10.5")))
    56   (set-default-font (if is-mac "Ubuntu Mono-12" "Ubuntu Mono-10.5")))
    58 
    57 
    59 
    58 
    60 ;;;; Mode-Specific ;;;;
    59 ;;;; Packages ;;;;
       
    60 
       
    61 (require 'package-require)
       
    62 (package-require '(company exec-path-from-shell expand-region
       
    63  smex markdown-mode markdown-mode+ ix hgignore-mode move-text paredit
       
    64  rainbow-delimiters rainbow-mode json-mode json-reformat
       
    65  solarized-theme terraform-mode visual-regexp yasnippet yaml-mode
       
    66  zencoding-mode))
       
    67 
       
    68 
       
    69 ;;; custom requires
       
    70 (require 'haskell-init)
       
    71 (require 'javascript-init)
       
    72 (require 'c-init)
       
    73 (require 'ansible-init)
       
    74 
    61 
    75 
    62 ;;; text-mode
    76 ;;; text-mode
    63 (add-hook 'fundamental-mode-hook 'flyspell-mode)      ; spellcheck text
    77 (add-hook 'fundamental-mode-hook 'flyspell-mode)      ; spellcheck text
    64 (add-hook 'fundamental-mode-hook 'turn-on-auto-fill)  ; autofill text
    78 (add-hook 'fundamental-mode-hook 'turn-on-auto-fill)  ; autofill text
    65 
       
    66 
       
    67 ;;; ido-mode
       
    68 (ido-mode t)                                          ; file/buffer selector
       
    69 (setq-default
       
    70  ido-enable-flex-matching t                           ; fuzzy matching for ido mode
       
    71  ido-create-new-buffer 'always                        ; create new buffer without prompt
       
    72  ido-everywhere t                                     ; use ido where possible
       
    73  ido-max-window-height 1)                             ; max ido window height
       
    74 
    79 
    75 
    80 
    76 ;;; whitespace-mode
    81 ;;; whitespace-mode
    77 (global-whitespace-mode t)                            ; show whitespace
    82 (global-whitespace-mode t)                            ; show whitespace
    78 (add-hook 'before-save-hook 'whitespace-cleanup)      ; cleanup whitespace on exit
    83 (add-hook 'before-save-hook 'whitespace-cleanup)      ; cleanup whitespace on exit
   109     ("HTML" (mode . html-mode))
   114     ("HTML" (mode . html-mode))
   110     ("CSS" (mode . css-mode))
   115     ("CSS" (mode . css-mode))
   111     ("C++" (mode . c++-mode)))))
   116     ("C++" (mode . c++-mode)))))
   112 (add-hook
   117 (add-hook
   113  'ibuffer-mode-hook
   118  'ibuffer-mode-hook
   114  (lambda ()
   119  (lambda () (ibuffer-switch-to-saved-filter-groups "default")))
   115    (ido-mode t)
       
   116    (ibuffer-switch-to-saved-filter-groups "default")))
       
   117 
       
   118 
       
   119 ;;;; Requires and Packages ;;;;
       
   120 
       
   121 ;;; packages
       
   122 (require 'package-require)
       
   123 (package-require '(ace-jump-mode company exec-path-from-shell
       
   124 expand-region smex hgignore-mode ido-at-point markdown-mode
       
   125 hgignore-mode move-text paredit rainbow-delimiters rainbow-mode
       
   126 json-mode json-reformat solarized-theme terraform-mode
       
   127 visual-regexp yasnippet yaml-mode zencoding-mode))
       
   128 
   120 
   129 
   121 
   130 ;;; shell
   122 ;;; shell
   131 (global-set-key (kbd "C-c s") 'eshell)  ; start shell
   123 (global-set-key (kbd "C-c s") 'eshell)  ; start shell
   132 (exec-path-from-shell-copy-env "PYTHONPATH")
   124 (exec-path-from-shell-copy-env "PYTHONPATH")
   133 (exec-path-from-shell-initialize)
   125 (exec-path-from-shell-initialize)
   134 (eshell)
   126 (eshell)
   135 (add-hook 'eshell-mode-hook (lambda () (setenv "TERM" "emacs")))
   127 (add-hook 'eshell-mode-hook (lambda () (setenv "TERM" "emacs")))
   136 
   128 
   137 
   129 
   138 ;;; custom requires
       
   139 (require 'haskell-init)
       
   140 (require 'javascript-init)
       
   141 (require 'c-init)
       
   142 (require 'ansible-init)
       
   143 
       
   144 
       
   145 ;;; ido / smex / completion
   130 ;;; ido / smex / completion
   146 (ido-at-point-mode)
   131 (setq-default
       
   132  ido-enable-flex-matching t                           ; fuzzy matching for ido mode
       
   133  ido-create-new-buffer 'always                        ; create new buffer without prompt
       
   134  ido-max-window-height 1                              ; max ido window height
       
   135  ido-everywhere t                                     ; use ido where possible
       
   136  ido-use-faces nil)
       
   137 (ido-mode t)                                          ; file/buffer selector
       
   138 (flx-ido-mode t)
   147 (global-set-key (kbd "M-/") 'completion-at-point)
   139 (global-set-key (kbd "M-/") 'completion-at-point)
   148 (global-set-key (kbd "M-x") 'smex)
   140 (global-set-key (kbd "M-x") 'smex)
   149 (global-set-key (kbd "M-X") 'smex-major-mode-commands)
   141 (global-set-key (kbd "M-X") 'smex-major-mode-commands)
   150 
   142 
   151 
   143 
   152 ;;; emacs-lisp-mode
   144 ;;; emacs-lisp-mode
   153 (add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode)
   145 (add-hook
   154 
   146  'emacs-lisp-mode-hook
   155 
   147  (lambda ()
   156 ;;; ace-mode
   148    (rainbow-mode)
   157 (define-key global-map (kbd "C-c SPC") 'ace-jump-mode)
   149    (enable-paredit-mode)))
   158 ;; (autoload
       
   159 ;;   'ace-jump-mode-pop-mark
       
   160 ;;   "ace-jump-mode"
       
   161 ;;   "Ace jump back:-)"
       
   162 ;;   t)
       
   163 ;; (eval-after-load "ace-jump-mode"
       
   164 ;;   '(ace-jump-mode-enable-mark-sync))
       
   165 ;; (define-key global-map (kbd "C-x SPC") 'ace-jump-mode-pop-mark)
       
   166 
   150 
   167 
   151 
   168 ;;; company-mode
   152 ;;; company-mode
   169 (add-hook 'after-init-hook 'global-company-mode)
   153 (add-hook 'after-init-hook 'global-company-mode)
   170 (global-set-key (kbd "M-/") 'company-complete)
   154 (global-set-key (kbd "M-/") 'company-complete)
   189  '("8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4"
   173  '("8aebf25556399b58091e533e455dd50a6a9cba958cc4ebb0aab175863c25b9a4"
   190    "d677ef584c6dfc0697901a44b885cc18e206f05114c8a3b7fde674fce6180879" default))
   174    "d677ef584c6dfc0697901a44b885cc18e206f05114c8a3b7fde674fce6180879" default))
   191 (load-theme 'solarized-light)
   175 (load-theme 'solarized-light)
   192 
   176 
   193 
   177 
       
   178 ;;; show-paren-mode - needs to be loaded after theme
       
   179 (setq-default
       
   180  show-paren-style 'expression
       
   181  show-paren-delay 0)
       
   182 (set-face-attribute
       
   183  'show-paren-match nil
       
   184  :background (face-background 'highlight)
       
   185  :foreground (face-foreground 'highlight))
       
   186 (show-paren-mode t)
       
   187 
       
   188 
   194 ;;; yasnippets
   189 ;;; yasnippets
   195 (setq-default yas-prompt-functions '(yas-ido-prompt yas-dropdown-prompt)) ; use ido for multiple snippets
   190 (setq-default yas-prompt-functions '(yas-ido-prompt yas-dropdown-prompt)) ; use ido for multiple snippets
   196 (yas-global-mode t)
   191 (yas-global-mode t)
   197 
   192 
   198 
   193 
   199 ;;; markdown-mode
   194 ;;; markdown-mode
   200 (add-hook 'markdown-mode-hook 'flyspell-mode)
   195 (add-hook 'markdown-mode-hook 'flyspell-mode)
   201 (setq-default
   196 (setq-default markdown-command "pandoc -f markdown_github")
   202  markdown-command "pandoc -f markdown_github")
       
   203 
   197 
   204 
   198 
   205 ;;; html-mode
   199 ;;; html-mode
   206 (add-to-list 'auto-mode-alist '("\\.tpl\\'" . html-mode))
   200 (add-to-list 'auto-mode-alist '("\\.tpl\\'" . html-mode))
   207 (add-hook
   201 (add-hook