Fixes #46 Weird behavior of projectile

Projectile takes time to load (around 0.2 seconds) and it is
lazy loading friendly if we want to enable it globally.

To be able to lazy load it, we encapsulate the binded calls
in spacemacs/xxx functions which take care of firing the
mode globally if required.
This commit is contained in:
syl20bnr 2014-10-29 01:03:01 -04:00
parent 09e058d36f
commit 5ab9d95fca

View file

@ -1560,24 +1560,34 @@ DELETE-FUNC when calling CALLBACK.
(defun spacemacs/init-projectile ()
(use-package projectile
:commands (projectile-switch-to-buffer
projectile-invalidate-cache
projectile-dired
projectile-find-file
projectile-kill-buffers
projectile-grep
projectile-replace)
:commands projectile-global-mode
:init
(evil-leader/set-key
"pC" 'projectile-invalidate-cache
"pd" 'projectile-dired
"pF" 'projectile-find-file
"pg" 'projectile-grep
"pk" 'projectile-kill-buffers
"pr" 'projectile-replace
"ps" 'projectile-switch-to-buffer)
(progn
(defun spacemacs/projectile-lazy-loading (func)
"Wrap FUNC in order to be able to lazy load projectile."
(let ((funcstr (symbol-name func)))
(eval `(defun ,(intern (format "spacemacs/%s" funcstr)) (arg)
,(format "Call %s" funcstr)
(interactive "P")
(projectile-global-mode)
(call-interactively ',func arg)))))
(mapc 'spacemacs/projectile-lazy-loading '(projectile-invalidate-cache
projectile-dired
projectile-find-file
projectile-grep
projectile-kill-buffers
projectile-replace
projectile-switch-to-buffer))
(evil-leader/set-key
"pC" 'spacemacs/projectile-invalidate-cache
"pd" 'spacemacs/projectile-dired
"pF" 'spacemacs/projectile-find-file
"pg" 'spacemacs/projectile-grep
"pk" 'spacemacs/projectile-kill-buffers
"pr" 'spacemacs/projectile-replace
"ps" 'spacemacs/projectile-switch-to-buffer))
:config
(spacemacs//diminish projectile-mode "")))
(spacemacs//hide-lighter projectile-mode)))
(defun spacemacs/init-python ()
(use-package python