Skip to content

Commit

Permalink
Fixes #46 Weird behavior of projectile
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
syl20bnr committed Oct 29, 2014
1 parent 53a44d2 commit 57c71e0
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions spacemacs/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
(interactive "P")
(format "Call %s" funcstr)
(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
Expand Down

0 comments on commit 57c71e0

Please sign in to comment.