core-project: refactor; add functions; add comments
This commit is contained in:
parent
c1418ad76b
commit
e328577eac
1 changed files with 29 additions and 10 deletions
|
@ -1,12 +1,8 @@
|
||||||
;;; core-project.el --- tools for getting around your project
|
;;; core-project.el --- tools for getting around your project
|
||||||
|
|
||||||
;; I want Emacs project-aware. i.e. To know what project I'm in, and to be able
|
;; I want Emacs to be nominally aware of the projects. `projectile' provides
|
||||||
;; to tell me about it. `projectile' helps me with this. It also provides nifty
|
;; tools for digging through project files and exposing an API I can use to make
|
||||||
;; tools for digging out files I want from a project of any size.
|
;; other plugins/features project-aware.
|
||||||
;;
|
|
||||||
;; `neotree', on the other hand, allows me to browse my project files. I
|
|
||||||
;; occasionally like having a birds-eye view of my files.
|
|
||||||
|
|
||||||
(package! projectile :demand t
|
(package! projectile :demand t
|
||||||
:init
|
:init
|
||||||
(setq projectile-cache-file (concat doom-temp-dir "/projectile.cache")
|
(setq projectile-cache-file (concat doom-temp-dir "/projectile.cache")
|
||||||
|
@ -22,6 +18,8 @@
|
||||||
projectile-require-project-root nil)
|
projectile-require-project-root nil)
|
||||||
|
|
||||||
:config
|
:config
|
||||||
|
(projectile-global-mode +1)
|
||||||
|
|
||||||
(mapc (lambda (r) (push r projectile-other-file-alist))
|
(mapc (lambda (r) (push r projectile-other-file-alist))
|
||||||
'(("less" "css")
|
'(("less" "css")
|
||||||
("styl" "css")
|
("styl" "css")
|
||||||
|
@ -32,20 +30,41 @@
|
||||||
("pug" "html")
|
("pug" "html")
|
||||||
("html" "jade" "pug" "jsx" "tsx")))
|
("html" "jade" "pug" "jsx" "tsx")))
|
||||||
|
|
||||||
|
(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))
|
||||||
|
(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))
|
||||||
|
|
||||||
(defun doom*projectile-cache-current-file (orig-fun &rest args)
|
(defun doom*projectile-cache-current-file (orig-fun &rest args)
|
||||||
"Don't cache ignored files."
|
"Don't cache ignored files."
|
||||||
(unless (--any (f-descendant-of? buffer-file-name it)
|
(unless (--any (f-descendant-of? buffer-file-name it)
|
||||||
(projectile-ignored-directories))
|
(projectile-ignored-directories))
|
||||||
(apply orig-fun args)))
|
(apply orig-fun args)))
|
||||||
(advice-add 'projectile-cache-current-file :around 'doom*projectile-cache-current-file)
|
(advice-add 'projectile-cache-current-file :around 'doom*projectile-cache-current-file))
|
||||||
|
|
||||||
(projectile-global-mode +1))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Autoloaded Packages
|
;; Autoloaded Packages
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
;; A side-panel for browsing my project files. Inspired by vim's NERDTree.
|
||||||
(package! neotree
|
(package! neotree
|
||||||
:commands (neotree-show
|
:commands (neotree-show
|
||||||
neotree-hide
|
neotree-hide
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue