   :bind (("C-c <up>" . git-gutter:previous-hunk)
          ("C-c <down>" . git-gutter:next-hunk)))
 
-;; In addition to highlighting, we get navigation between
-(use-package highlight-symbol
-  :hook ((prog-mode . highlight-symbol-mode)
-         (prog-mode . highlight-symbol-nav-mode))
-  :ensure t
-  :bind (:map highlight-symbol-nav-mode-map
-              (("M-n" . highlight-symbol-next)
-               ("M-p" . highlight-symbol-prev)))
-  :config
-  (set-face-attribute 'highlight-symbol-face nil
-                      :background "default"
-                      :foreground "yellow")
-  (vsetq highlight-symbol-idle-delay 0.2)
-  (vsetq highlight-symbol-on-navigation-p t))
+(add-hook 'emacs-startup-hook
+          (lambda ()
+            ;; In addition to highlighting, we get navigation between
+            (use-package highlight-symbol
+              :hook ((prog-mode . highlight-symbol-mode)
+                     (prog-mode . highlight-symbol-nav-mode))
+              :ensure t
+              :bind (:map highlight-symbol-nav-mode-map
+                          (("M-n" . highlight-symbol-next)
+                           ("M-p" . highlight-symbol-prev)))
+              :config
+              (set-face-attribute 'highlight-symbol-face nil
+                                  :background "default"
+                                  :foreground "yellow")
+              (vsetq highlight-symbol-idle-delay 0.2)
+              (vsetq highlight-symbol-on-navigation-p t))))
 
 ;;;; Navigation END
 

  :bind (("M-<up>" . drag-stuff-up)
         ("M-<down>" . drag-stuff-down)))

(use-package whitespace
  :defer 5
  ;; Automatically remove whitespace on saving.
  :hook ((before-save . whitespace-cleanup)
         (prog-mode . whitespace-mode))
  :config
  ;; When nil, fill-column is used instead.
  (vsetq whitespace-line-column nil)
  ;; Highlight empty lines, TABs, blanks at beginning/end, lines
  ;; longer than fill-column, and trailing blanks.
  (vsetq whitespace-style '(face empty tabs lines-tail trailing))
  (vsetq show-trailing-whitespace t)
  (set-face-attribute 'whitespace-line nil
                      :foreground "DarkOrange1"
                      :background "default"))

(use-package smartparens
  :ensure t
  :defer 0.01
  ;; Add to minibuffer also.
  :hook ((minibuffer-setup . smartparens-mode)
         (prog-mode . smartparens-strict-mode)
         (eshell-mode . smartparens-strict-mode))
  :config
  (require 'smartparens-config)
  (require 'smartparens-html)
  (require 'smartparens-python)

  (defun ar/kill-region-advice-fun (orig-fun &rest r)
    "Advice function around `kill-region' (ORIG-FUN and R)."
    (if (or (null (nth 2 r)) ;; Consider kill-line (C-k).
            mark-active)
        (apply orig-fun r)
      ;; Kill entire line.
      (let ((last-command (lambda ())) ;; Override last command to avoid appending to kill ring.
            (offset (- (point)
                       (line-beginning-position))))
        (apply orig-fun (list (line-beginning-position)
                              (line-end-position)
                              nil))
        (delete-char 1)
        (forward-char (min offset
                           (- (line-end-position)
                              (line-beginning-position)))))))

  (advice-add 'kill-region
              :around
              'ar/kill-region-advice-fun)

  ;; I prefer keeping C-w to DWIM kill, provided by
  ;; `ar/kill-region-advice-fun'. Removing remap.
  ;;   (define-key smartparens-strict-mode-map [remap kill-region] nil)

  (defun ar/smartparens-wrap-square-bracket (arg)
    "[] equivalent of `paredit-wrap-round'."
    (interactive "P")
    (save-excursion
      (unless (sp-point-in-symbol)
        (backward-char))
      (sp-wrap-with-pair "["))
    (insert " "))

  :bind (:map smartparens-strict-mode-map
              ([remap kill-region] . kill-region)
              ("C-c <right>" . sp-forward-slurp-sexp)
              ("C-c <left>" . sp-forward-barf-sexp)
              ("M-[" . sp-rewrap-sexp)
              :map smartparens-mode-map
              ("M-]" . ar/smartparens-wrap-square-bracket)))


(use-package region-bindings-mode


      ;; comint-magic-space needs to be whitelisted to ensure we receive company-begin events in eshell.
      (when (boundp 'company-begin-commands)
        (setq-local company-begin-commands
                    (append company-begin-commands (list 'comint-magic-space))))

      (bind-key "C-l" #'ar/eshell-cd-to-parent eshell-mode-map))
    :config
