       (package-refresh-contents)
       (package-install 'use-package)))
 
-(require 'cl-lib)
-(defun my-packages (packages)
-  (let* ((melpa-installed-p (lambda (p) (assq p package-alist)))
-         (installed (mapcar melpa-installed-p packages)))
-    (when (cl-some #'not installed)
-      (package-refresh-contents)
-      (cl-mapc (lambda (i p) (unless i
-                               (let ((pkg (assq p package-archive-contents)))
-                                 (when pkg (package-install (cadr pkg))))))
-               installed packages))))
-
-(my-packages '(color-theme-sanityinc-tomorrow
-               evil
-               evil-escape
-               org
-               evil-org
-               helm
-               magit
-               projectile
-               helm-projectile
-               smartparens
-               evil-smartparens
-               web-mode
-               clojure-mode
-               cider
-               clj-refactor
-               rainbow-delimiters
-               smart-mode-line))
-
 (package-initialize)
 
 (require 'use-package)
+;(customize-set-variable 'use-package-verbose t)
+(customize-set-variable 'use-package-always-ensure t)
+
 
 (custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
- '(custom-safe-themes
-   (quote
-    ("c74e83f8aa4c78a121b52146eadb792c9facc5b1f02c917e3dbb454fca931223" default))))
+ )
 
 (custom-set-faces
  ;; custom-set-faces was added by Custom.

 )


(require 'color-theme-sanityinc-tomorrow)
(load-theme 'sanityinc-tomorrow-eighties t)

(require 'evil)
(evil-mode t)

(require 'evil-escape)
(evil-escape-mode)

(require 'org)
(customize-set-variable 'org-log-note-clock-out t)

(require 'evil-org)

(require 'helm-config)
(helm-mode 1)
(define-key global-map [remap find-file] 'helm-find-files)
(define-key global-map [remap occur] 'helm-occur)
(define-key global-map [remap list-buffers] 'helm-buffers-list)
(define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
(global-set-key (kbd "M-x") 'helm-M-x)
(helm-autoresize-mode 1)

(require 'magit)

(setq magit-last-seen-setup-instructions "1.4.0")

(defun org-sync ()
  (interactive)
  (let ((commited (magit-call-git "commit" "-a" "--allow-empty-message" "-m" ""))
        (conflict (magit-call-git "pull" "--rebase")))
    (if (= 0 conflict)
        (when (= 0 commited)
          (magit-run-git-async "push"))
      (magit-status))))


(require 'projectile)
(projectile-global-mode)

(require 'helm-projectile)
(helm-projectile-on)

; smartparens
(require 'smartparens-config)
(smartparens-global-mode t)
(define-key smartparens-mode-map (kbd "C-M-)") 'sp-forward-slurp-sexp)
(define-key smartparens-mode-map (kbd "C-M-0") 'sp-forward-barf-sexp)
(define-key smartparens-mode-map (kbd "C-M-(") 'sp-backward-slurp-sexp)
(define-key smartparens-mode-map (kbd "C-M-9") 'sp-backward-barf-sexp)

; evil-smartparens
(add-hook 'smartparens-enabled-hook #'evil-smartparens-mode)

(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))

; cider
(add-hook 'cider-mode-hook #'eldoc-mode)
(setq nrepl-hide-special-buffers t)

(use-package
 company
 :ensure t
 :demand t
 :bind (:map
        company-active-map

        ("<tab>" . nil)
        ("TAB" . nil)
        ("<C-tab>" . company-complete-common-or-cycle))
 :config
 (customize-set-variable 'company-idle-delay 0.1)
 (customize-set-variable 'company-minimum-prefix-length 1)
 (global-company-mode))

; clj-refactor
;(require 'clj-refactor)
;(add-hook 'clojure-mode-hook (lambda ()
;                               (clj-refactor-mode 1)
;                               (cljr-add-keybindings-with-prefix "C-c C-a")))

(use-package yasnippet
  :config
  (yas-global-mode 1))

(use-package rainbow-delimiters
  :commands rainbow-delimiters-mode
  :init
  (add-hook 'prog-mode-hook #'rainbow-delimiters-mode))

(use-package smart-mode-line
  :config
  (customize-set-variable 'sml/theme 'respectful)
  (sml/setup))

(add-to-list 'auto-mode-alist '("\\.t\\'" . perl-mode))
