2017-01-31 19:50:11 -05:00
|
|
|
;;; core-projects.el --- tools for getting around your project
|
|
|
|
|
2017-02-19 18:11:28 -05:00
|
|
|
;; I want Emacs to be aware of the projects. `projectile' provides tools for
|
|
|
|
;; digging through project files and exposing an API I can use to make other
|
|
|
|
;; plugins/features project-aware.
|
2017-02-08 02:02:51 -05:00
|
|
|
|
2017-02-23 00:06:12 -05:00
|
|
|
(def-package! projectile :demand t
|
2017-01-31 19:50:11 -05:00
|
|
|
:init
|
2017-02-19 18:09:26 -05:00
|
|
|
(setq projectile-cache-file (concat doom-cache-dir "projectile.cache")
|
2017-01-31 19:50:11 -05:00
|
|
|
projectile-enable-caching (not noninteractive)
|
|
|
|
projectile-file-exists-remote-cache-expire nil
|
2017-02-19 18:09:26 -05:00
|
|
|
projectile-globally-ignored-directories `(,doom-local-dir ".sync")
|
2017-01-31 19:50:11 -05:00
|
|
|
projectile-globally-ignored-file-suffixes '(".elc" ".pyc" ".o")
|
|
|
|
projectile-globally-ignored-files '(".DS_Store" "Icon
")
|
|
|
|
projectile-indexing-method 'alien
|
2017-02-19 18:09:26 -05:00
|
|
|
projectile-known-projects-file (concat doom-cache-dir "projectile.projects")
|
2017-01-31 19:50:11 -05:00
|
|
|
projectile-project-root-files '(".git" ".hg" ".svn" ".project")
|
|
|
|
projectile-require-project-root nil)
|
|
|
|
|
|
|
|
:config
|
|
|
|
(projectile-mode +1)
|
|
|
|
|
2017-02-13 04:45:57 -05:00
|
|
|
(setq projectile-other-file-alist
|
|
|
|
(append '(("less" "css")
|
|
|
|
("styl" "css")
|
|
|
|
("sass" "css")
|
|
|
|
("scss" "css")
|
|
|
|
("css" "scss" "sass" "less" "styl")
|
|
|
|
("jade" "html")
|
|
|
|
("pug" "html")
|
|
|
|
("html" "jade" "pug" "jsx" "tsx"))
|
|
|
|
projectile-other-file-alist))
|
2017-01-31 19:50:11 -05:00
|
|
|
|
|
|
|
(defun doom*projectile-cache-current-file (orig-fun &rest args)
|
|
|
|
"Don't cache ignored files."
|
2017-02-19 18:02:40 -05:00
|
|
|
(unless (cl-some (lambda (path)
|
|
|
|
(string-prefix-p buffer-file-name
|
|
|
|
(expand-file-name path)))
|
|
|
|
(projectile-ignored-directories))
|
2017-01-31 19:50:11 -05:00
|
|
|
(apply orig-fun args)))
|
|
|
|
(advice-add 'projectile-cache-current-file :around 'doom*projectile-cache-current-file))
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
;; Library
|
|
|
|
;;
|
|
|
|
|
|
|
|
(defun doom-project-p (&optional strict-p)
|
|
|
|
"Whether or not this buffer is currently in a project or not."
|
|
|
|
(let ((projectile-require-project-root strict-p))
|
|
|
|
(projectile-project-p)))
|
|
|
|
|
|
|
|
(defun doom-project-root (&optional strict-p)
|
|
|
|
"Get the path to the root of your project."
|
|
|
|
(let ((projectile-require-project-root strict-p))
|
|
|
|
(ignore-errors (projectile-project-root))))
|
|
|
|
|
|
|
|
(defun doom-project-has-files (files &optional root)
|
|
|
|
"Return non-nil if FILES exist in the project root."
|
|
|
|
(let ((root (or root (doom-project-root)))
|
|
|
|
(files (if (listp files) files (list files)))
|
|
|
|
(found-p (if files t)))
|
|
|
|
(while (and found-p files)
|
|
|
|
(let ((file (expand-file-name (pop files) root)))
|
|
|
|
(setq found-p (if (string-suffix-p "/" file)
|
|
|
|
(file-directory-p file)
|
|
|
|
(file-exists-p file)))))
|
|
|
|
found-p))
|
|
|
|
|
|
|
|
(provide 'core-projects)
|
|
|
|
;;; core-projects.el ends here
|