fix(lua): love2d project check
Close: #7333 Co-authored-by: LemonBreezes <LemonBreezes@users.noreply.github.com>
This commit is contained in:
parent
b1cc719063
commit
b17257cf98
1 changed files with 19 additions and 18 deletions
|
@ -9,27 +9,28 @@
|
||||||
(shell-quote-argument root))))
|
(shell-quote-argument root))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +lua-love-project-root ()
|
(defun +lua-love-project-root (&optional dir)
|
||||||
"Returns the directory where a main.lua or main.moon exists.
|
"Return directory (up from DIR) where a main.lua or main.moon exists.
|
||||||
|
|
||||||
Returns nil if 'love' executable can't be found."
|
Returns nil if 'love' executable can't be found."
|
||||||
(when (executable-find "love")
|
(when (executable-find "love")
|
||||||
(if (doom-project-p)
|
(when-let ((dir (or dir (doom-project-root))))
|
||||||
|
(if (doom-project-p dir)
|
||||||
(file-name-directory
|
(file-name-directory
|
||||||
(or (project-file-exists-p! (or "main.lua" "src/main.lua"))
|
(or (file-exists-p! (or "main.lua" "src/main.lua") dir)
|
||||||
(and (modulep! +moonscript)
|
(and (modulep! +moonscript)
|
||||||
(project-file-exists-p! (or "main.moon" "src/main.moon")))
|
(file-exists-p! (or "main.moon" "src/main.moon") dir))
|
||||||
""))
|
""))
|
||||||
;; Since Love2D games are likely to be prototypes, they may not be in a
|
;; Since Love2D games are likely to be prototypes, they may not be in a
|
||||||
;; well-formed project as far as projecitle is concerned, so we search for
|
;; well-formed project as far as projecitle is concerned, so we search for
|
||||||
;; main.lua/main.moon up the file tree as a backup.
|
;; main.lua/main.moon up the file tree as a backup.
|
||||||
(or (projectile-locate-dominating-file default-directory "main.lua")
|
(or (projectile-locate-dominating-file dir "main.lua")
|
||||||
(when-let (root (projectile-locate-dominating-file default-directory "src/main.lua"))
|
(when-let (root (projectile-locate-dominating-file dir "src/main.lua"))
|
||||||
(expand-file-name "src" root))
|
(expand-file-name "src" root))
|
||||||
(and (modulep! +moonscript)
|
(and (modulep! +moonscript)
|
||||||
(or (projectile-locate-dominating-file default-directory "main.moon")
|
(or (projectile-locate-dominating-file dir "main.moon")
|
||||||
(when-let (root (projectile-locate-dominating-file default-directory "src/main.moon"))
|
(when-let (root (projectile-locate-dominating-file dir "src/main.moon"))
|
||||||
(expand-file-name "src" root))))))))
|
(expand-file-name "src" root)))))))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue