  ;; If there is more than one, they won't work right.
  '(package-selected-packages
    (quote
-    (spacemacs-theme rainbow-delimiters ledger-mode restclient markdown-mode ivy general which-key evil-lion evil-collection evil diminish use-package))))
+    (projectile company magit spacemacs-theme rainbow-delimiters ledger-mode restclient markdown-mode ivy general which-key evil-lion evil-collection evil diminish use-package))))
 (custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.


  (evil-ex-define-cmd "ret[ab]"    'av/evil-retab)
  (evil-ex-define-cmd "ter[minal]" 'ansi-term)

  (use-package evil-collection
    :ensure t

  (general-define-key
    :prefix "SPC SPC"
    :states '(normal visual)
    "" 'execute-extended-command)

  ;; File
  (leader
    "f" '(:ignore t :which-key "file")
    "ff" 'find-file
    "ft" 'dired
    "fc" '((lambda () (interactive) (find-file (concat user-emacs-directory "init.el"))) :which-key "edit-config"))

  ;; Emacs Lisp
  (local-leader
    :keymaps '(emacs-lisp-mode-map lisp-interaction-mode-map)
    "e" '(:ignore t :which-key "eval")
    "eb" 'eval-buffer
    "ed" 'eval-defun
    "ee" 'eval-expression
    "es" 'eval-last-sexp
    "ep" 'eval-print-last-sexp
    "er" 'eval-region))

(use-package ivy
  :ensure t
  :diminish ivy-mode
  :config (ivy-mode 1))

(use-package company
  :ensure t
  :diminish company-mode
  :hook (after-init . global-company-mode))

(use-package magit
  :ensure t
  :defer 1
  :config

  (leader
    "g"  '(:ignore t :which-key "git/vcs")
    "gs" 'magit-status
    "gd" 'magit-diff
    "gb" 'magit-blame))

;; TODO finish configuring this (set up mappings)
(use-package projectile
  :ensure t
  :defer t
  :config (projectile-mode 1))

;;; TODO proof general

(use-package rainbow-delimiters
  :ensure t
  :hook (prog-mode . rainbow-delimiters-mode))

(use-package spacemacs-theme
  :ensure t
  :defer t
  :init (load-theme 'spacemacs-dark t))



;;; File types

(use-package markdown-mode :ensure t :defer t)

(use-package org
  :ensure t
  :defer t
  :hook (org-mode . org-indent-mode)
  :config
  ;; TODO set org directory for org-agenda

  (local-leader
    :keymaps 'org-mode-map
    "i" '(:ignore t :which-key "insert")
    "il" 'org-insert-link
    "o" 'org-open-at-point
    "a" 'org-agenda
    "c" 'org-capture
    "g" 'org-store-link
    "e" 'org-export-dispatch
    "v" 'org-eval
    "s" 'org-edit-src-code
    "t" 'org-todo))

;; TODO write function to open this?
(use-package restclient
  :ensure t
  :mode ("\\.restclient\\'" . restclient-mode)
  :config

  (local-leader
    :keymaps 'restclient-mode-map
    "s" '(:ignore t :which-key "send")
    "sc" 'restclient-http-send-current
    "sr" 'restclient-http-send-current-raw
    "ss" 'restclient-http-send-current-stay-in-window
    "j" 'restclient-jump-prev
    "k" 'restclient-jump-next))

(use-package ledger-mode
  :ensure t
  :defer t
  :config

  ;; FIXME `ledger-mode-clean-buffer' should sort in reverse order
  (local-leader
    :keymaps 'ledger-mode-map
    "c" 'ledger-mode-clean-buffer
    "k" 'ledger-check-buffer
    "b" '(:ignore t :which-key "balance")
    "bb" 'ledger-display-balance
    "bp" 'ledger-display-balance-at-point
    "r" '(:ignore t :which-key "register")))

;; (use-package js2-mode
;;   :ensure t
;;   :defer t
;;   :config (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode)))

;; (use-package csharp-mode
;;   :ensure t
;;   :defer t
;;   :config

;;   (add-to-list 'auto-mode-alist '("\\.cs$" . csharp-mode))

;;   (use-package omnisharp
;;     :ensure t
;;     :hook (csharp-mode . omnisharp-mode)))

(custom-set-variables
 ;; custom-set-variables was added by Custom.
