init.el
changeset 65 839e0a541c76
parent 64 5183b4466011
child 66 b6182e0be08d
equal deleted inserted replaced
64:5183b4466011 65:839e0a541c76
    50 (when window-system
    50 (when window-system
    51   (tool-bar-mode -1)      ; remove tool bar
    51   (tool-bar-mode -1)      ; remove tool bar
    52   (scroll-bar-mode -1)    ; remove scroll bar
    52   (scroll-bar-mode -1)    ; remove scroll bar
    53   (menu-bar-mode -1)      ; remove menu bar
    53   (menu-bar-mode -1)      ; remove menu bar
    54   (visual-line-mode t)    ; word wrap break on whitespace
    54   (visual-line-mode t)    ; word wrap break on whitespace
    55   (set-frame-font (if is-mac "Ubuntu Mono-14" "Ubuntu Mono-10.5")))
    55   (set-frame-font (if is-mac "Ubuntu Mono-12" "Ubuntu Mono-10.5")))
    56 
    56 
    57 ;;;; Mode-Specific ;;;;
    57 ;;;; Mode-Specific ;;;;
    58 
    58 
    59 ;;; text-mode
    59 ;;; text-mode
    60 (add-hook 'fundamental-mode-hook 'flyspell-mode)      ; spellcheck text
    60 (add-hook 'fundamental-mode-hook 'flyspell-mode)      ; spellcheck text
   116 
   116 
   117 ;; install packages
   117 ;; install packages
   118 (let ((ensure-installed
   118 (let ((ensure-installed
   119        (lambda (name)
   119        (lambda (name)
   120          (unless (package-installed-p name) (package-install name))))
   120          (unless (package-installed-p name) (package-install name))))
   121       (packages '(ac-js2, auto-complete, exec-path-from-shell, expand-region,
   121       (packages '(ac-js2 auto-complete exec-path-from-shell expand-region
   122                   flymake-easy, flymake-hlint, ghc, ghci-completion, haskell-mode,
   122                   flymake-easy flymake-hlint ghc ghci-completion haskell-mode
   123                   js2-mode, multiple-cursors, rainbow-delimiters, rainbow-mode,
   123                   js2-mode multiple-cursors rainbow-delimiters rainbow-mode
   124                   skewer-mode, solarized-theme, visual-regexp, yasnippet,
   124                   skewer-mode solarized-theme visual-regexp yasnippet
   125                   zencoding-mode)))
   125                   zencoding-mode json-mode)))
   126   (mapc ensure-installed packages))
   126   (mapc ensure-installed packages))
   127 
   127 
   128 ;;; requires
   128 ;;; requires
   129 (require 'c-init)             ; c specific elisp
   129 (require 'c-init)             ; c specific elisp
   130 (require 'move-line)          ; move line up or down
   130 (require 'move-line)          ; move line up or down
   131 (require 'uniquify)           ; unique buffer names with dirs
   131 (require 'uniquify)           ; unique buffer names with dirs
   132 (require 'auto-complete-config)
   132 (require 'auto-complete-config)
   133 
   133 
   134 ;;; auto-config-mode
   134 ;;; auto-complete-mode
   135 (ac-config-default)
   135 (ac-config-default)
       
   136 (global-set-key (kbd "M-/") 'auto-complete)
       
   137 (setq-default ac-auto-start nil)
   136 
   138 
   137 ;;; terminal
   139 ;;; terminal
   138 (global-set-key (kbd "C-c s") 'eshell) ; start shell
   140 (global-set-key (kbd "C-c s") 'eshell) ; start shell
   139 (exec-path-from-shell-initialize)
   141 (exec-path-from-shell-initialize)
   140 (eshell)
   142 (eshell)
   157 (setq-default yas-snippet-dirs '("~/.emacs.d/snippets"))
   159 (setq-default yas-snippet-dirs '("~/.emacs.d/snippets"))
   158 (yas-global-mode t)
   160 (yas-global-mode t)
   159 
   161 
   160 ;;; js2-mode
   162 ;;; js2-mode
   161 (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
   163 (add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
   162 (add-hook 'js2-mode-hook '(ac-js2-mode t))
   164 (add-hook 'js2-mode-hook 'ac-js2-mode)
   163 (setq-default ac-js2-evaluate-calls t)
   165 (setq-default ac-js2-evaluate-calls t)
   164 
   166 
   165 ;;; html-mode
   167 ;;; html-mode
   166 (add-to-list 'auto-mode-alist '("\\.tpl\\'" . html-mode))
   168 (add-to-list 'auto-mode-alist '("\\.tpl\\'" . html-mode))
   167 (add-hook
   169 (add-hook
   176 
   178 
   177 ;;; coding-modes map
   179 ;;; coding-modes map
   178 (mapc
   180 (mapc
   179  (lambda (x)
   181  (lambda (x)
   180    (add-hook x
   182    (add-hook x
   181              (lambda ()
   183     (lambda ()
   182                (linum-mode t)
   184       (linum-mode t)
   183                (rainbow-delimiters-mode t)
   185       (rainbow-delimiters-mode t)
   184                (auto-complete-mode t))))
   186       (auto-complete-mode t))))
   185  '(text-mode-hook
   187  '(text-mode-hook
   186    c-mode-common-hook
   188    c-mode-common-hook
   187    python-mode-hook
   189    python-mode-hook
   188    haskell-mode-hook
   190    haskell-mode-hook
   189    js2-mode-hook
   191    js2-mode-hook
   198  'haskell-mode-hook
   200  'haskell-mode-hook
   199  (lambda ()
   201  (lambda ()
   200    (ghc-init)
   202    (ghc-init)
   201    (flymake-mode t)
   203    (flymake-mode t)
   202    (capitalized-words-mode t)
   204    (capitalized-words-mode t)
   203    (turn-on-haskell-indent)
   205    (turn-on-hi2)
   204    (turn-on-haskell-doc-mode)
   206    (turn-on-haskell-doc-mode)
   205    (turn-on-haskell-decl-scan)
   207    (turn-on-haskell-decl-scan)
   206    (imenu-add-menubar-index)
   208    (imenu-add-menubar-index)
   207    (local-set-key (kbd "C-c i") 'haskell-navigate-imports) ; go to imports. prefix to return
   209    (local-set-key (kbd "C-c i") 'haskell-navigate-imports) ; go to imports. prefix to return
   208    (setq
   210    (setq
   209     ghc-ghc-options '("-isrc")
   211     ghc-ghc-options '("-isrc")
   210     haskell-font-lock-haddock t
   212     haskell-font-lock-haddock t
   211     haskell-stylish-on-save t
   213     haskell-stylish-on-save t
   212     haskell-indent-offset 4
   214     hi2-layout-offset 4
       
   215     hi2-left-offset 4
       
   216     haskell-doc-chop-off-context nil
       
   217     haskell-doc-show-global-types t
   213     whitespace-line-column 78)))
   218     whitespace-line-column 78)))
   214 
   219 
   215 ;;; ghci-mode
   220 ;;; ghci-mode
   216 (add-hook 'inferior-haskell-mode-hook 'turn-on-ghci-completion)
   221 (add-hook 'inferior-haskell-mode-hook 'turn-on-ghci-completion)
   217 
   222 
   220 
   225 
   221 ;;; flymake-mode
   226 ;;; flymake-mode
   222 (add-hook
   227 (add-hook
   223  'flymake-mode-hook
   228  'flymake-mode-hook
   224  (lambda ()
   229  (lambda ()
       
   230    (local-set-key (kbd "M-p") 'move-line-up) ; need to override default M-p function
       
   231    (local-set-key (kbd "M-n") 'move-line-down)
   225    (local-set-key (kbd "C-1") 'flymake-display-err-menu-for-current-line)
   232    (local-set-key (kbd "C-1") 'flymake-display-err-menu-for-current-line)
   226    (local-set-key (kbd "C-.") 'flymake-goto-next-error)
   233    (local-set-key (kbd "C-.") 'flymake-goto-next-error)
   227    (local-set-key (kbd "C-,") 'flymake-goto-prev-error)
   234    (local-set-key (kbd "C-,") 'flymake-goto-prev-error)
   228    ))
   235    ))
       
   236 
       
   237 ;;; move-line
       
   238 (global-set-key (kbd "M-p") 'move-line-up)
       
   239 (global-set-key (kbd "M-n") 'move-line-down)
   229 
   240 
   230 ;;; multiple-cursors
   241 ;;; multiple-cursors
   231 (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
   242 (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
   232 (global-set-key (kbd "C->") 'mc/mark-next-like-this)
   243 (global-set-key (kbd "C->") 'mc/mark-next-like-this)
   233 (global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
   244 (global-set-key (kbd "C-<") 'mc/mark-previous-like-this)