   :ensure t
   :init
   (projectile-mode)
-  (setq projectile-completion-system 'ivy))
+  (setq projectile-completion-system 'ivy)
+  :bind 
+  (:map
+   projectile-mode-map 
+   ("s-b" . projectile-switch-to-buffer)
+   ("s-p" . projectile-command-map)))
+
+
 
 (use-package counsel-projectile
   :ensure t
   :config
-  (counsel-projectile-on))
+  (counsel-projectile-mode))
 
 ;; Org
 (use-package org
-  :ensure t)
+  :ensure t
+
+  :bind
+  (("C-c c" . org-capture)
+   :map
+   org-mode-map
+   ("C-c a" . org-agenda))
+
+  
+
+  :config
+  ;; Setup
+  (csetq org-agenda-files '("~/code/journal"
+                            "~/code/journal/spikeup"))
+
+  (csetq org-default-notes-file "~/code/journal/refile.org")
+
+  ;; Refile
+  (csetq org-refile-targets (quote ((nil :maxlevel . 9)
+                                    (org-agenda-files :maxlevel . 9))))
+
+  (csetq org-refile-allow-creating-parent-nodes (quote confirm))
+
+  (csetq org-refile-use-outline-path 'file)
+  (csetq org-outline-path-complete-in-steps nil)
+
+
+  (defun udots/verify-refile-target ()
+    "Exclude todo keywords with a done state from refile targets"
+    (not (member (nth 2 (org-heading-components)) org-done-keywords)))
+  
+  (csetq org-refile-target-verify-function 'udots/verify-refile-target)
+  
+  ;; Clocking
+  (defun udots/get-clock-for-menubar ()
+    (if (org-clock-is-active)
+        (substring-no-properties (org-clock-get-clock-string))
+      "[Clock not running]"))
+
+  (defun udots/update-bitbar-org-clock ()
+    (udots/update-bitbar-plugin "org-clock.*?.sh"))
+  
+  (when (udots/mac-p)
+    (add-hook 'org-clock-in-hook 'udots/update-bitbar-org-clock)
+    (add-hook 'org-clock-out-hook 'udots/update-bitbar-org-clock)
+    (add-hook 'org-clock-cancel-hook 'udots/update-bitbar-org-clock))
+  
+  (csetq org-clock-into-drawer t)
+  (csetq org-clock-out-when-done t)
+  (csetq org-clock-out-remove-zero-time-clocks t)
+  (csetq org-clock-report-include-clocking-task t)
+
+  ;; Properties
+  (setq org-global-properties (quote (("Effort_ALL" . "0:15 0:30 0:45 1:00 2:00 3:00 4:00 5:00 6:00 0:00"))))
+
+  ;; Column
+  (setq org-columns-default-format "%80ITEM(Task) %10Effort(Effort){:} %10CLOCKSUM")
+
+  ;; Appearence
+  (setq org-startup-indented t)
+
+  ;; Logging
+  (csetq org-log-done (quote time))
+  (csetq org-log-into-drawer nil)
+  (csetq org-log-state-notes-insert-after-drawers t)
+  (csetq org-reverse-note-order nil)
+
+  ;; Todo Configuration
+  (csetq org-todo-keywords
+         (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d)")
+                 (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)" "CALL"))))
+
+  (setq org-todo-keyword-faces
+        (quote (("TODO" :foreground "red" :weight bold)
+                ("NEXT" :foreground "blue" :weight bold)
+                ("DONE" :foreground "forest green" :weight bold)
+                ("WAITING" :foreground "orange" :weight bold)
+                ("HOLD" :foreground "magenta" :weight bold)
+                ("CANCELLED" :foreground "forest green" :weight bold)
+                ("CALL" :foreground "forest green" :weight bold))))
+
+  (csetq org-use-fast-todo-selection t)
+  (csetq org-enforce-todo-dependencies t)
+
+  ;; Tags
+  ;; (csetq org-fast-tag-selection-single-key (quote expert))
+  (csetq org-use-fast-tag-selection t)
+  (csetq org-todo-state-tags-triggers
+         (quote (("CANCELLED" ("CANCELLED" . t))
+                 ("WAITING" ("WAITING" . t))
+                 ("HOLD" ("WAITING") ("HOLD" . t))
+                 (done ("WAITING") ("HOLD"))
+                 ("TODO" ("WAITING") ("CANCELLED") ("HOLD"))
+                 ("NEXT" ("WAITING") ("CANCELLED") ("HOLD"))
+                 ("DONE" ("WAITING") ("CANCELLED") ("HOLD")))))
+
+  ;; Capture Templates
+  (csetq org-capture-templates
+         (quote (("t" "todo" entry (file "~/code/journal/refile.org")
+                  "* TODO %?\n%U\n" :clock-in t :clock-resume t)
+                 ("n" "note" entry (file "~/code/journal/refile.org")
+                  "* %? :NOTE:\n%U\n" :clock-in t :clock-resume t)
+                 ("j" "Journal" entry (file+datetree "~/code/journal/journal.org")
+                  "* %?\n%U\n" :clock-in t :clock-resume t)
+                 )))
+
+  ;; Agenda Helpers
+  (defvar udots/hide-scheduled-and-waiting-next-tasks t)
+
+  (defun udots/find-project-task ()
+    "Move point to the parent (project) task if any"
+    (save-restriction
+      (widen)
+      (let ((parent-task (save-excursion (org-back-to-heading 'invisible-ok) (point))))
+        (while (org-up-heading-safe)
+          (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
+            (setq parent-task (point))))
+        (goto-char parent-task)
+        parent-task)))
+
+  (defun udots/is-project-p ()
+    "Any task with a todo keyword subtask"
+    (save-restriction
+      (widen)
+      (let ((has-subtask)
+            (subtree-end (save-excursion (org-end-of-subtree t)))
+            (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
+        (save-excursion
+          (forward-line 1)
+          (while (and (not has-subtask)
+                      (< (point) subtree-end)
+                      (re-search-forward "^\*+ " subtree-end t))
+            (when (member (org-get-todo-state) org-todo-keywords-1)
+              (setq has-subtask t))))
+        (and is-a-task has-subtask))))
+
+  (defun udots/is-project-subtree-p ()
+    "Any task with a todo keyword that is in a project subtree.
+Callers of this function already widen the buffer view."
+    (let ((task (save-excursion (org-back-to-heading 'invisible-ok)
+                                (point))))
+      (save-excursion
+        (udots/find-project-task)
+        (if (equal (point) task)
+            nil
+          t))))
+
+  (defun udots/is-task-p ()
+    "Any task with a todo keyword and no subtask"
+    (save-restriction
+      (widen)
+      (let ((has-subtask)
+            (subtree-end (save-excursion (org-end-of-subtree t)))
+            (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
+        (save-excursion
+          (forward-line 1)
+          (while (and (not has-subtask)
+                      (< (point) subtree-end)
+                      (re-search-forward "^\*+ " subtree-end t))
+            (when (member (org-get-todo-state) org-todo-keywords-1)
+              (setq has-subtask t))))
+        (and is-a-task (not has-subtask)))))
+
+  (defun udots/is-subproject-p ()
+    "Any task which is a subtask of another project"
+    (let ((is-subproject)
+          (is-a-task (member (nth 2 (org-heading-components)) org-todo-keywords-1)))
+      (save-excursion
+        (while (and (not is-subproject) (org-up-heading-safe))
+          (when (member (nth 2 (org-heading-components)) org-todo-keywords-1)
+            (setq is-subproject t))))
+      (and is-a-task is-subproject)))
+
+  (defun udots/skip-non-projects ()
+    "Skip trees that are not projects"
+    (if (save-excursion (udots/skip-non-stuck-projects))
+        (save-restriction
+          (widen)
+          (let ((subtree-end (save-excursion (org-end-of-subtree t))))
+            (cond
+             ((udots/is-project-p)
+              nil)
+             ((and (udots/is-project-subtree-p) (not (udots/is-task-p)))
+              nil)
+             (t
+              subtree-end))))
+      (save-excursion (org-end-of-subtree t))))
+
+  (defun udots/skip-non-stuck-projects ()
+    "Skip trees that are not stuck projects" 
+    (save-restriction
+      (widen)
+      (let ((next-headline (save-excursion (or (outline-next-heading) (point-max)))))
+        (if (udots/is-project-p)
+            (let* ((subtree-end (save-excursion (org-end-of-subtree t)))
+                   (has-next ))
+              (save-excursion
+                (forward-line 1)
+                (while (and (not has-next) (< (point) subtree-end) (re-search-forward "^\\*+ NEXT " subtree-end t))
+                  (unless (member "WAITING" (org-get-tags-at))
+                    (setq has-next t))))
+              (if has-next
+                  next-headline
+                nil)) ; a stuck project, has subtasks but no next task
+          next-headline))))
+
+  (defun udots/skip-non-project-tasks ()
+    "Show project tasks.
+Skip project and sub-project tasks, habits, and loose non-project tasks."
+    (save-restriction
+      (widen)
+      (let* ((subtree-end (save-excursion (org-end-of-subtree t)))
+             (next-headline (save-excursion (or (outline-next-heading) (point-max)))))
+        (cond
+         ((udots/is-project-p)
+          next-headline) 
+         ((and (udots/is-project-subtree-p)
+               (member (org-get-todo-state) (list "NEXT")))
+          subtree-end)
+         ((not (udots/is-project-subtree-p))
+          subtree-end)
+         (t
+          nil)))))
+
+  (defun udots/skip-projects-and-habits-and-single-tasks ()
+    "Skip trees that are projects, tasks that are habits, single non-project tasks"
+    (save-restriction
+      (widen)
+      (let ((next-headline (save-excursion (or (outline-next-heading) (point-max)))))
+        (cond 
+         ((member "WAITING" (org-get-tags-at))
+          next-headline)
+         ((udots/is-project-p)
+          next-headline)
+         ((and (udots/is-task-p) (not (udots/is-project-subtree-p)))
+          next-headline)
+         (t
+          nil)))))
+
+  (defun udots/skip-project-tasks ()
+    "Show non-project tasks.
+Skip project and sub-project tasks, habits, and project related tasks."
+    (save-restriction
+      (widen)
+      (let* ((subtree-end (save-excursion (org-end-of-subtree t))))
+        (cond
+         ((udots/is-project-p)
+          subtree-end) 
+         ((udots/is-project-subtree-p)
+          subtree-end)
+         (t
+          nil)))))
+
+  (defun udots/skip-non-tasks ()
+    "Show non-project tasks.
+Skip project and sub-project tasks, habits, and project related tasks."
+    (save-restriction
+      (widen)
+      (let ((next-headline (save-excursion (or (outline-next-heading) (point-max)))))
+        (cond
+         ((udots/is-task-p)
+          nil)
+         (t
+          next-headline)))))
+
+  (defun udots/show-scheduled ()
+    "Show the deadline"
+    (or
+     (org-entry-get (point) "SCHEDULED" nil)
+     ""))
+
+  (defun udots/org-agenda-prefix-string ()
+    "Format"
+    (let ((path (org-format-outline-path (org-get-outline-path))))
+      (if (> (length path) 0)
+          (concat " [" path "]"))))
+  
+  ;; Agenda
+  (csetq org-agenda-tags-todo-honor-ignore-options t)
+  (csetq org-agenda-dim-blocked-tasks nil)
+  (csetq org-agenda-span 'day)
+  (csetq org-agenda-custom-commands
+         '((" " "Main Agenda" 
+            ((agenda nil)
+             (tags "REFILE"
+                   ((org-agenda-overriding-header "Tasks to Refile")
+                    (org-tags-match-list-sublevels nil)))
+             
+             (tags-todo "-HOLD-CANCELLED/!"
+                        ((org-agenda-overriding-header "Projects")
+                         (org-agenda-skip-function 'udots/skip-non-projects)
+                         (org-tags-match-list-sublevels 'indented)
+                         (org-agenda-sorting-strategy
+                          '(category-keep))))
+
+             (tags-todo "-CANCELLED/!"
+                        ((org-agenda-overriding-header "Stuck Projects")
+                         (org-agenda-skip-function 'udots/skip-non-stuck-projects)
+                         (org-agenda-sorting-strategy
+                          '(category-keep))))
+             
+             (tags-todo "-CANCELLED/!NEXT"
+                        ((org-agenda-overriding-header "Project Next Tasks")
+                         (org-agenda-skip-function 'udots/skip-projects-and-habits-and-single-tasks)
+                         (org-tags-match-list-sublevels t)
+                         (org-agenda-todo-ignore-scheduled 'future)
+                         (org-agenda-todo-ignore-deadlines 'future) 
+                         (org-agenda-sorting-strategy
+                          '(todo-state-down effort-up category-keep))))
+
+             (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
+                        ((org-agenda-overriding-header "Standalone Tasks")
+                         (org-agenda-skip-function 'udots/skip-project-tasks)
+                         (org-agenda-todo-ignore-scheduled 'future)
+                         (org-agenda-todo-ignore-deadlines 'future) 
+                         (org-agenda-sorting-strategy
+                          '(category-keep))))
+
+             (todo nil
+                   ((org-agenda-overriding-header "Upcoming Tasks")
+                    (org-agenda-prefix-format '((todo .  " %i %-11:c [%(udots/show-scheduled)] ")))
+                    (org-agenda-skip-function '(org-agenda-skip-entry-if 'notscheduled))
+                    (org-agenda-sorting-strategy
+                     '(category-keep))
+                    ))
+
+             (tags-todo "-CANCELLED+WAITING|HOLD/!"
+                        ((org-agenda-overriding-header "Waiting and Postponed Tasks")
+                         (org-agenda-skip-function 'udots/skip-non-tasks)
+                         (org-tags-match-list-sublevels nil)
+                         (org-agenda-todo-ignore-scheduled 'future)
+                         (org-agenda-todo-ignore-deadlines 'future))))))))
+
+
+
 
 ;; Markdown
 (use-package markdown-mode

  :config
  (add-hook 'prog-mode-hook 'rainbow-delimiters-mode))

;; Clojure
(use-package clojure-mode
  :ensure t)

(use-package cider
  :ensure t)

;; Elixir
(use-package elixir-mode
  :ensure t)

(use-package alchemist
  :ensure t)

;; Go
(use-package go-mode
  :ensure t)

(use-package company-go
  :ensure t
  :config
  (add-to-list 'company-backends 'company-go))

(use-package go-eldoc
  :ensure t
  :config
  (add-hook 'go-mode-hook 'go-eldoc-setup))

;; Clojure
(use-package clojure-mode
  :ensure t)

(use-package cider
  :ensure t)

(use-package clj-refactor
  :ensure t)

;; Haskell

        (funcall function))
    (switch-to-buffer-other-window buffer-name)))


(defun udots/update-bitbar-plugin (plugin)
  (if (udots/mac-p)
      (start-process "open-bitbar" nil "open" "-g" (format "bitbar://refreshPlugin?name=%s" plugin))
    (message "This is only available on macOS")))

;;(load-theme 'solarized-dark t)

;; PATH Mangling
(use-package exec-path-from-shell
  :ensure t
  :config
  (when (udots/mac-p)
    (csetq exec-path-from-shell-arguments nil)
    (exec-path-from-shell-initialize)
    (exec-path-from-shell-copy-env "GOPATH")))
