Refactor core-projects

Relevant to #161
This commit is contained in:
Henrik Lissner 2017-07-26 18:42:33 +02:00
parent aa255d9cb6
commit 4c1f42de81
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -6,27 +6,18 @@ state are passed in.")
(def-package! projectile (def-package! projectile
:demand t :demand t
:init :init (add-hook 'doom-init-hook #'projectile-mode)
:config
(setq projectile-cache-file (concat doom-cache-dir "projectile.cache") (setq projectile-cache-file (concat doom-cache-dir "projectile.cache")
projectile-enable-caching (not noninteractive) projectile-enable-caching (not noninteractive)
projectile-file-exists-remote-cache-expire nil projectile-file-exists-remote-cache-expire nil
projectile-globally-ignored-file-suffixes '(".elc" ".pyc" ".o")
projectile-globally-ignored-files '(".DS_Store" "Icon ")
projectile-indexing-method 'alien projectile-indexing-method 'alien
projectile-known-projects-file (concat doom-cache-dir "projectile.projects") projectile-known-projects-file (concat doom-cache-dir "projectile.projects")
projectile-require-project-root nil projectile-require-project-root nil
projectile-project-root-files projectile-project-root-files
'(".git" ".hg" ".svn" ".project" "package.json" "setup.py" "Gemfile" '(".git" ".hg" ".svn" ".project" "package.json" "setup.py" "Gemfile"
"build.gradle")) "build.gradle")
projectile-other-file-alist
(after! projectile
(mapc (lambda (dir) (cl-pushnew dir projectile-globally-ignored-directories))
`(,doom-local-dir ".sync")))
:config
(add-hook 'doom-init-hook #'projectile-mode)
(setq projectile-other-file-alist
(append '(("less" "css") (append '(("less" "css")
("styl" "css") ("styl" "css")
("sass" "css") ("sass" "css")
@ -35,21 +26,27 @@ state are passed in.")
("jade" "html") ("jade" "html")
("pug" "html") ("pug" "html")
("html" "jade" "pug" "jsx" "tsx")) ("html" "jade" "pug" "jsx" "tsx"))
projectile-other-file-alist)) projectile-other-file-alist)
projectile-globally-ignored-file-suffixes '(".elc" ".pyc" ".o")
projectile-globally-ignored-files '(".DS_Store" "Icon ")
projectile-globally-ignored-directories
(append (list doom-local-dir ".sync")
projectile-globally-ignored-directories))
;; In core-editor.el I've forced `recentf' to use `abbreviate-file-name', but ;; Add `recentf-filename-handlers' support to `projectile-recentf-files'.
;; this messes up projectile-recentf, so let's fix that:
(defun doom*projectile-abbreviate-project-root (orig-fn &rest args) (defun doom*projectile-abbreviate-project-root (orig-fn &rest args)
"Abbreviate `projectile-project-root'." "Abbreviate `projectile-project-root'."
(cl-letf (((symbol-function 'projectile-project-root) (cl-letf (((symbol-function 'projectile-project-root)
`(lambda () `(lambda ()
(abbreviate-file-name (cl-loop with dir = (,(symbol-function 'projectile-project-root))
(,(symbol-function 'projectile-project-root)))))) for fn in recentf-filename-handlers
do (setq dir (funcall fn dir))
finally return dir))))
(apply orig-fn args))) (apply orig-fn args)))
(advice-add #'projectile-recentf-files :around #'doom*projectile-abbreviate-project-root) (advice-add #'projectile-recentf-files :around #'doom*projectile-abbreviate-project-root)
;; Projectile root-searching functions cause an endless loop on TRAMP ;; Projectile root-searching functions can cause an infinite loop on TRAMP
;; connections, so we disable them. ;; connections, so disable them.
(defun doom*projectile-locate-dominating-file (orig-fn &rest args) (defun doom*projectile-locate-dominating-file (orig-fn &rest args)
"Don't traverse the file system if a remote connection." "Don't traverse the file system if a remote connection."
(unless (file-remote-p default-directory) (unless (file-remote-p default-directory)