Make doom-project-{p,root} functions simpler
+ doom-project-root and doom-project-p no longer takes arguments + Remove doom*project-root advice
This commit is contained in:
parent
77836e08b1
commit
3fcbdae441
4 changed files with 10 additions and 16 deletions
|
@ -53,7 +53,7 @@ Inspired from http://demonastery.org/2013/04/emacs-evil-narrow-region/"
|
||||||
|
|
||||||
If no project is active, return all buffers."
|
If no project is active, return all buffers."
|
||||||
(let ((buffers (doom-buffer-list)))
|
(let ((buffers (doom-buffer-list)))
|
||||||
(if-let (project-root (doom-project-root t))
|
(if-let (project-root (if (doom-project-p) (doom-project-root)))
|
||||||
(cl-loop for buf in buffers
|
(cl-loop for buf in buffers
|
||||||
if (projectile-project-buffer-p buf project-root)
|
if (projectile-project-buffer-p buf project-root)
|
||||||
collect buf)
|
collect buf)
|
||||||
|
|
|
@ -63,22 +63,17 @@ state are passed in.")
|
||||||
(dolist (fn projectile-project-root-files-functions)
|
(dolist (fn projectile-project-root-files-functions)
|
||||||
(remhash (format "%s-%s" fn default-directory) projectile-project-root-cache)))
|
(remhash (format "%s-%s" fn default-directory) projectile-project-root-cache)))
|
||||||
|
|
||||||
(defun doom-project-p (&optional strict-p)
|
(defun doom-project-p ()
|
||||||
"Whether or not this buffer is currently in a project or not."
|
"Whether or not this buffer is currently in a project or not."
|
||||||
(let ((projectile-require-project-root strict-p))
|
(let ((projectile-require-project-root t))
|
||||||
(projectile-project-p)))
|
(projectile-project-p)))
|
||||||
|
|
||||||
(defun doom-project-root (&optional strict-p)
|
(defun doom-project-root ()
|
||||||
"Get the path to the root of your project.
|
"Get the path to the root of your project.
|
||||||
If STRICT-P, return nil if no project was found, otherwise return
|
If STRICT-P, return nil if no project was found, otherwise return
|
||||||
`default-directory'."
|
`default-directory'."
|
||||||
(let ((projectile-require-project-root strict-p))
|
(let (projectile-require-project-root)
|
||||||
(ignore-errors (projectile-project-root))))
|
(projectile-project-root)))
|
||||||
|
|
||||||
(defun doom*project-root (&rest _)
|
|
||||||
"An advice function used to replace project-root-detection functions in other
|
|
||||||
libraries."
|
|
||||||
(doom-project-root))
|
|
||||||
|
|
||||||
(defmacro doom-project-has! (files)
|
(defmacro doom-project-has! (files)
|
||||||
"Checks if the project has the specified FILES, relative to the project root,
|
"Checks if the project has the specified FILES, relative to the project root,
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
:commands tern-mode
|
:commands tern-mode
|
||||||
:init (add-hook 'js2-mode-hook #'tern-mode)
|
:init (add-hook 'js2-mode-hook #'tern-mode)
|
||||||
:config
|
:config
|
||||||
(advice-add #'tern-project-dir :override #'doom*project-root))
|
(advice-add #'tern-project-dir :override #'doom-project-root))
|
||||||
|
|
||||||
|
|
||||||
(def-package! company-tern
|
(def-package! company-tern
|
||||||
|
|
|
@ -41,8 +41,7 @@
|
||||||
(equal (file-name-extension buffer-file-name) "tsx")))
|
(equal (file-name-extension buffer-file-name) "tsx")))
|
||||||
(tide-setup)
|
(tide-setup)
|
||||||
(flycheck-mode +1)
|
(flycheck-mode +1)
|
||||||
(eldoc-mode +1)))
|
(eldoc-mode +1)
|
||||||
(add-hook! (typescript-mode web-mode) #'+typescript|init-tide)
|
(setq tide-project-root (doom-project-root))))
|
||||||
|
(add-hook! (typescript-mode web-mode) #'+typescript|init-tide))
|
||||||
(advice-add #'tide-project-root :override #'doom*project-root))
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue