 (defun spacemacs/init-helm-ag ()
   (use-package helm-ag
     :defer t
-    :config
+    :init
     (defun spacemacs/helm-do-ag-region-or-symbol (&optional basedir)
       "Calls `helm-do-ag' with a default string of the escaped
 active region or the symbol at the point if there is no active
 region. Requires \"ag\" search tool."
       (interactive)
-      (require 'helm-mode)
-      (require 'helm-grep)
-      (require 'helm-ag)
-      (require 'pcre2el)
       (unless (executable-find "ag")
         (error "ag not available"))
       (setq helm-ag--original-window (selected-window))

            (helm :sources '(helm-source-do-ag) :buffer "*helm-ag*"
                  :input search-string
                  :keymap helm-do-ag-map)))))

    (defun spacemacs/helm-projectile-ag-region-or-symbol (&optional options)
      "Version of `spacemacs/helm-do-ag-region-or-symbol' that
defaults to searching the current project. Requires \"ag\" search tool."
      (interactive)
      (unless (executable-find "ag")
        (error "ag not available"))
      (if (require 'helm-ag nil  'noerror)
          (if (projectile-project-p)
              (let* ((grep-find-ignored-files
                      (-union (projectile-ignored-files-rel)  grep-find-ignored-files))
                     (grep-find-ignored-directories
                      (-union (projectile-ignored-directories-rel) grep-find-ignored-directories))
                     (ignored
                      (mapconcat (lambda (i)
                                   (concat "--ignore " i))
                                 (append grep-find-ignored-files grep-find-ignored-directories)
                                 " "))
                     (helm-ag-command-option options)
                     (helm-ag-base-command (concat helm-ag-base-command " " ignored)))
                (spacemacs/helm-do-ag-region-or-symbol (projectile-project-root)))
            (error "You're not in a project"))
        (error "helm-ag not available")))
    (evil-define-key 'normal helm-ag-map "SPC" evil-leader--default-map)
    (evilify helm-ag-mode helm-ag-mode-map
             (kbd "RET") 'helm-ag-mode-jump-other-window
             (kbd "q") 'quit-window)))

(defun spacemacs/init-helm-descbinds ()
  (use-package helm-descbinds

            (let ((helm-ag-base-command "pt -e --nocolor --nogroup"))
              (call-interactively 'helm-projectile-ag))
          (message "error: helm-ag not found.")))

      (when (configuration-layer/package-usedp 'helm-ag)
        (defun spacemacs/helm-projectile-ag-region-or-symbol (&optional options)
          "Version of `spacemacs/helm-do-ag-region-or-symbol' that
defaults to searching the current project. Requires \"ag\" search tool."
          (interactive)
          (unless (executable-find "ag")
            (error "ag not available"))
          (if (require 'helm-ag nil  'noerror)
              (if (projectile-project-p)
                  (let* ((grep-find-ignored-files
                          (-union (projectile-ignored-files-rel)
                                  grep-find-ignored-files))
                         (grep-find-ignored-directories
                          (-union (projectile-ignored-directories-rel)
                                  grep-find-ignored-directories))
                         (ignored
                          (mapconcat (lambda (i)
                                       (concat "--ignore " i))
                                     (append grep-find-ignored-files
                                             grep-find-ignored-directories)
                                     " "))
                         (helm-ag-command-option options)
                         (helm-ag-base-command (concat helm-ag-base-command
                                                       " " ignored)))
                    (spacemacs/helm-do-ag-region-or-symbol
                     (projectile-project-root)))
                (error "You're not in a project"))
            (error "helm-ag not available"))))

      (defun spacemacs//helm-projectile-do-search-find-tool (tools)
        "Create a cond form given a TOOLS string list and evaluate it."
