Skip to content

Commit

Permalink
Fixes syl20bnr#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 authored and mmailhot committed Nov 16, 2014
1 parent ac37862 commit 9686e80
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions spacemacs/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,37 @@ determine the state to enable when escaping from the insert state.")

(defun spacemacs/init-projectile ()
(use-package projectile
:commands projectile-global-mode
:init
(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//hide-lighter projectile-mode)))

(defun spacemacs/init-python ()
(use-package python
:defer t
:init
(progn
Expand Down

0 comments on commit 9686e80

Please sign in to comment.