 ;; USER CONFIGURABLES ;;
 ;;;;;;;;;;;;;;;;;;;;;;;;
 
-(setq rcirc-server-alist
-      '(("irc.freenode.net" :port 6697 :encryption tls
-         :channels ("#rcirc" "#emacs" "#emacswiki"))))
-(setq gnus-thread-sort-functions
-      '(gnus-thread-sort-by-number
-        gnus-thread-sort-by-date))
+(setq rcirc-server-alist '(("irc.freenode.net" :port 6697 
+                            :encryption tls 
+                            :channels ("#rcirc" "#emacs" "#emacswiki"))))
+(setq gnus-thread-sort-functions '(gnus-thread-sort-by-number gnus-thread-sort-by-date))
 ;; (yas-global-mode)
 
-(setq ac-sources '(ac-source-semantic ac-source-yasnippet))
 ;; set autosaves to temp dir
-(setq backup-directory-alist
-      `((".*" . ,temporary-file-directory)))
-(setq auto-save-file-name-transforms
-      `((".*" ,temporary-file-directory t)))
+(setq backup-directory-alist `((".*" . ,temporary-file-directory)))
+(setq auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))
 (setq org-agenda-include-diary t)
 (setq diary-file "~/Organiser/Diary")
 (setq org-agenda-files '("~/Organiser/agendas") )
 (setq ruby-insert-encoding-magic-comment nil)
 (setq flyspell-issue-welcome-flag nil)
-(setq inhibit-splash-screen t
-      initial-scratch-message nil
-      initial-major-mode 'org-mode)
-(setq tab-width 8
-      indent-tabs-mode nil)
+(setq inhibit-splash-screen t initial-scratch-message nil initial-major-mode 'org-mode)
+(setq tab-width 8 indent-tabs-mode nil)
 (setq-default indent-tabs-mode nil)
 (setq ring-bell-function 'ignore)
 (setq column-number-mode t)
 (auto-compression-mode 1)
-(setq ac-auto-start 2)
-(setq ac-use-menu-map t)
 (setq-default fill-column 80) ;; 80 character rule
 
 ;; smex setup

(setq helm-mode-fuzzy-match 1)
(setq helm-completion-in-region-fuzzy-match 1)
(setq helm-candidate-number-limit 25)

(require 'helm-fuzzier)

(setq helm-flx-for-helm-find-files t ;; t by default
      helm-flx-for-helm-locate t) ;; nil by default

(helm-flx-mode +1)

(global-set-key (kbd "M-x") #'helm-M-x)
(global-set-key (kbd "C-x r b") #'helm-filtered-bookmarks)
(global-set-key (kbd "C-x C-f") #'helm-find-files)
(global-set-key (kbd "C-x <up>") #'helm-ispell)

(helm-mode 1)
(helm-fuzzier-mode 1)


(require 'helm-grepint)
    (helm-grepint-set-default-config-latest)
    (global-set-key (kbd "C-c g") #'helm-grepint-grep)
(global-set-key (kbd "C-c G") #'helm-grepint-grep-root)

(global-set-key (kbd "C-c G") #'helm-grepint-grep-root)

(package-initialize "no-activate")

;; Additonal repositories
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(add-to-list 'package-archives '("elpa" . "http://tromey.com/elpa/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/"))
;; (add-to-list 'load-path
;;           "~/.emacs.d/src/yasnippet")

(setq package-archive-enable-alist '(("melpa" deft magit)))

;; (let ((default-directory "~/.emacs.d/elpa/"))
;;   (normal-top-level-add-subdirs-to-load-path))

;; (when (not (package-installed-p 'cl-lib))
;;   (package-install 'cl-lib))

;; (add-to-list 'load-path "~/.emacs.d/cl-lib/")
;; (require 'cl-lib)

;; (add-to-list 'load-path "~/.emacs.d/eslint-flycheck/")
;; (require 'eslint-flycheck)

(defvar default-packages 
  '(auctex buttercup coffee-mode column-enforce-mode company dash elisp-format emr
           exec-path-from-shell expand-region fish-mode flycheck go-mode helm helm-company helm-flx helm-flycheck helm-fuzzier
           helm-fuzzy-find helm-gitignore helm-grepint helm-ispell helm-swoop highlight-chars
           inf-ruby intero jade-mode js2-mode key-chord less-css-mode list-utils markdown-mode
           markdown-toc multiple-cursors paredit pkg-info popup projectile racer ruby-block
           ruby-electric rust-mode rw-hunspell s scss-mode slime smartparens sublimity tide company-quickhelp indium
           use-package wakatime-mode web-mode yaml-mode yari yasnippet yasnippet-snippets) 
  "A list of packages to ensure are installed at launch.")

                                        ; activate all the packages (in particular autoloads)
(package-initialize)

                                        ; fetch the list of packages available
(unless package-archive-contents (package-refresh-contents))

                                        ; install the missing packages
(dolist (package default-packages) 
  (unless (package-installed-p package) 
    (package-install package)))

;;;;;;;;;;;;;;;;;;;
;; PACKAGE SETUP ;;
;;;;;;;;;;;;;;;;;;;
(require 'yasnippet)
(require 'smartparens-config)
(require 'multiple-cursors)
(require 'highlight-chars)
(require 'flycheck)
(require 'sublimity)
(require 'sublimity-scroll)
(require 'sublimity-map) ;; experimental
(require 'sublimity-attractive)

(setq sublimity-map-size 20)
(setq sublimity-map-fraction 0.3)
(setq sublimity-map-text-scale -7)
(sublimity-map-set-delay 2)
(add-hook 'sublimity-map-setup-hook (lambda () 
                                      (setq buffer-face-mode-face 
                                            '(:family "Monospace")) 
                                      (buffer-face-mode)))
(sublimity-attractive-hide-bars)

(winner-mode)
(projectile-mode)

(put 'downcase-region 'disabled nil)
(autoload 'inf-ruby-minor-mode "inf-ruby" "Run an inferior Ruby process" t)

