emacs.d / init.el

;; emacs configuration

(push "/usr/local/bin" exec-path)
(push "/usr/local/share/python" exec-path)
(push "/usr/local/Cellar/go/1.0.3/bin" exec-path)

(setenv "GOROOT" "/usr/local/Cellar/go/1.0.3")

(setq make-backup-files nil)
(setq auto-save-default nil)
(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)
(setq inhibit-startup-message t)

(fset 'yes-or-no-p 'y-or-n-p)

(delete-selection-mode t)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(blink-cursor-mode t)
(show-paren-mode t)
(column-number-mode t)
(set-fringe-style -1)
(tooltip-mode -1)

(global-linum-mode 1)
(define-key global-map (kbd "RET") 'newline-and-indent)
(global-set-key "\C-x\C-m" 'execute-extended-command)
(global-set-key (kbd "\C-x\C-b") 'ibuffer)

(set-frame-font "Menlo-12")

(require 'ido)
(ido-mode t)

(require 'uniquify)
(setq uniquify-buffer-name-style 'forward)

(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
(add-to-list 'load-path "~/.emacs.d/custom")

(unless (require 'el-get nil t)
  (url-retrieve
   "https://github.com/dimitri/el-get/raw/master/el-get-install.el"
   (lambda (s)
     (end-of-buffer)
     (eval-print-last-sexp))))

(setq el-get-sources
      '((:name cobalt-theme
               :type git
               :url "git://github.com/nickewing/color-theme-cobalt.git")
        (:name puppet_syntax-emacs
               :type git
               :url "git://github.com/puppetlabs/puppet-syntax-emacs.git")
        (:name json-mode
               :type git
               :url "https://github.com/joshwnj/json-mode.git")
        (:name auto-complete
               :type git
               :url "https://github.com/auto-complete/auto-complete.git")
        (:name fuzzy
               :type git
               :url "https://github.com/auto-complete/fuzzy-el.git")
        (:name popup
               :type git
               :url "https://github.com/auto-complete/popup-el.git")
        (:name auto-complete-golang
               :type git
               :url "git://github.com/koko1000ban/auto-complete-golang.git")
        (:name monky
               :type git
               :url "git://github.com/ananthakumaran/monky.git")
        (:name js2-mode
               :type git
               :url "https://github.com/mooz/js2-mode.git")))

(setq
 my:el-get-packages
      '(el-get
        python-mode
        color-theme
        django-mode
        nxhtml
        markdown-mode
        go-mode
        magit
        yasnippet
        pymacs
        ropemacs
        flymake-cursor
        yaml-mode
        highlight-indentation
        sunrise-commander))

(setq my:el-get-packages
      (append
       my:el-get-packages
       (loop for src in el-get-sources collect (el-get-source-name src))))

(el-get 'sync my:el-get-packages)


; yasnippet
(add-to-list 'load-path (concat el-get-dir "yasnippet"))
(require 'yasnippet)
(yas-global-mode 1)
(setq yas/root-directory "~/.emacs.d/snippets")
(yas/load-directory yas/root-directory)


; django html mode
(autoload 'django-html-mode "django-html-mode")  
(autoload 'django-mode "django-mode")
(yas/load-directory  (concat el-get-dir "django-mode/snippets"))

; nxtml mode
(setq nxml-child-indent 4)
(setq mumamo-background-colors nil) 
(add-to-list 'auto-mode-alist '("\\.html$" . django-html-mumamo-mode))

; cobalt color theme
(when (string-match "apple-darwin" system-configuration)
  (setq mac-allow-anti-aliasing t))

(require 'color-theme)
(color-theme-initialize)
(load-file "~/.emacs.d/el-get/cobalt-theme/color-theme-cobalt.el")
(if window-system
  (color-theme-cobalt))

; js2-mode
(autoload 'js2-mode "js2-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))

; json-mode
(autoload 'json-mode "json-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.json$" . json-mode))

; yaml-mode
(require 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.yml$" . yaml-mode))
(add-hook 'yaml-mode-hook
          '(lambda ()
             (define-key yaml-mode-map "\C-m" 'newline-and-indent)))

; markdown mode
(autoload 'markdown-mode "markdown-mode.el" 
  "Major mode for editing Markdown files" t)
(setq auto-mode-alist
      (cons '("\\.md" . markdown-mode) auto-mode-alist))

;; Setup puppet-mode for autoloading
(autoload 'puppet-mode "puppet-mode" "Major mode for editing puppet manifests")
(add-to-list 'auto-mode-alist '("\\.pp$" . puppet-mode))

;; Setup ropeemacs
(require 'pymacs)
(pymacs-load "ropemacs" "rope-")

;; flake8 and flymake integration
(when (load "flymake" t)
  (defun flymake-flake8-init ()
    (let* ((temp-file (flymake-init-create-temp-buffer-copy
                       'flymake-create-temp-inplace))
           (local-file (file-relative-name
                        temp-file
                        (file-name-directory buffer-file-name))))
      (list "flake8" (list local-file))))
  (add-to-list 'flymake-allowed-file-name-masks
               '("\\.py\\'" flymake-flake8-init)))
(add-hook 'find-file-hook 'flymake-find-file-hook)
(load-library "flymake-cursor")

; Flyspell - prog mode only
(dolist (hook '(text-mode-hook))
(add-hook hook (lambda () (flyspell-mode 1))))

;; Autocomplete
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories "~/.emacs.d/el-get/auto-complete/dict")
(ac-config-default)
(define-key ac-mode-map (kbd "TAB") 'auto-complete)
(setq ac-auto-start nil)
(add-to-list 'ac-sources 'ac-source-yasnippet)
(ac-ropemacs-initialize)
(add-hook 'python-mode-hook
          (lambda ()
            (add-to-list 'ac-sources 'ac-source-ropemacs)))
; You need gocode for this to work
; Check https://github.com/nsf/gocode
(require 'go-autocomplete)

; Sunrise commander
(require 'sunrise-commander)

; Magit
(global-set-key (kbd "C-x g") 'magit-status)

; Monky
(global-set-key (kbd "C-c h") 'monky-status)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.