   (define-key stupid-map (kbd "C-c") nil))
 
 ;; Flycheck for code linting
-(use-package flycheck)
+(use-package flycheck
+  :ensure t
+  :init
   (add-hook 'after-init-hook #'global-flycheck-mode)
+  :config
   (unbreak-stupid-map flycheck-mode-map)
   (define-key flycheck-mode-map (kbd "C-c C-n") 'flycheck-next-error)
-  (define-key flycheck-mode-map (kbd "C-c C-p") 'flycheck-previous-error)
-
-;; C coding style
-(setq c-default-style "linux"
-      c-basic-offset tab-width
-      c-block-comment-prefix "* ")
-(global-set-key (kbd "M-RET") 'c-indent-new-comment-line)
-
-(load-lazy '(c-turn-on-eldoc-mode) "c-eldoc"
-  (setq c-eldoc-buffer-regenerate-time 15))
-(load-after 'cc-mode
+  (define-key flycheck-mode-map (kbd "C-c C-p") 'flycheck-previous-error))
+
+
+
+(use-package c-eldoc
+  :commands (c-turn-on-eldoc-mode)
+  :config
+  (setq c-eldoc-buffer-regenerate-time 15)
+  )
+
+(use-package cc-mode
+  :bind ("M-RET" . c-indent-new-comment-line)
+  :config
   (add-hook 'c++-mode-hook 'c-turn-on-eldoc-mode)
-  (add-hook 'c-mode-hook   'c-turn-on-eldoc-mode))
+  (add-hook 'c-mode-hook   'c-turn-on-eldoc-mode)
+  ;; C coding style
+  (setq c-default-style "linux"
+        c-basic-offset tab-width
+        c-block-comment-prefix "* "))
 
 ;; show what function we're in
-(use-package which-func)
-(which-function-mode 1)
-
-(load-after 'auto-complete-config
-  (add-hook 'c-mode-hook
-            (lambda ()
-              (add-to-list 'ac-sources 'ac-source-c-headers)
-              (add-to-list 'ac-sources 'ac-source-c-header-symbols t))))
+(use-package which-func
+  :ensure t
+  :init
+  (which-function-mode 1))
 
 ;; load ESS for R
 ;; (setq load-path (cons "/usr/share/emacs/site-lisp/ess" load-path))
-(add-to-list 'auto-mode-alist '("\\.jl$" . julia-mode)
-(load-lazy '(R R-mode julia-mode) "ess-site"
-  (setq inferior-julia-program-name "julia")))
+(use-package ess-site
+  :mode (("\\.jl$" . julia-mode)
+         ("\\.R$"  . R-mode))
+  :commands (R R-mode julia-mode)
+  :config
+  (setq inferior-julia-program-name "julia")
+  )
 
 ;; auctex
 (use-package auctex

            (dired-do-kill-lines))
        (progn (revert-buffer) ; otherwise just revert to re-show
               (set (make-local-variable 'dired-dotfiles-show-p) t)))))

  (define-key dired-mode-map (kbd ".") 'dired-dotfiles-toggle)

  ;; open by extension
  (setq dired-open-extensions '(
                                ("djvu" . "zathura")

  )

;; markdown
(use-package markdown-mode
  :ensure t
  :mode (("\\.md$"        . markdown-mode)
         ("\\.mkd$"       . markdown-mode)
         ("\\.pdc$"       . markdown-mode)
         ("\\.markdown$"  . markdown-mode)
         ("\\bREADME$$"   . markdown-mode))
  :config
  (setq markdown-command "pandoc --smart -f markdown -t html")
  (setq markdown-css-paths `(,(expand-file-name "markdown.css" "~/.pandoc/css/markdown.css")))
  (setq markdown-enable-math t)
  ;; add pandoc hook
  (add-hook 'markdown-mode-hook 'turn-on-pandoc)
  (add-hook 'pandoc-mode-hook 'pandoc-load-default-settings))

;; yaml
(use-package yaml-mode
  :ensure t
  :mode (("\\.yaml$" . yaml-mode)
         ("\\.yml$" . yaml-mode)))

;; muflax-notes
(use-package notes-mode
  :mode "\\.notes$")


;; Automatic Math preview toggle in org-mode
;; Source: http://goo.gl/WLYzxp
(defvar org-latex-fragment-last nil
  "Holds last fragment/environment you were on.")
;; FIXME Pretty janky right now
(defun org-latex-fragment-toggle ()
  "Toggle a latex fragment image "
  (and (eq 'org-mode major-mode)
