lang/lua: fix +lua-love-project-root
Its former logic would only return a correct path if both main.{lua,moon} and src/main.{lua,moon} exist within the same project, which is very unlikely.
This commit is contained in:
parent
ee81d0533a
commit
e38dad13c6
1 changed files with 17 additions and 8 deletions
|
@ -25,14 +25,23 @@
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +lua-love-project-root ()
|
(defun +lua-love-project-root ()
|
||||||
"Returns the directory where a main.lua exists.
|
"Returns the directory 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")
|
||||||
(or (and (projectile-locate-dominating-file default-directory "main.lua")
|
(if (doom-project-p)
|
||||||
(when-let (root (projectile-locate-dominating-file default-directory "src/main.lua"))
|
(file-name-directory
|
||||||
(expand-file-name "src" root)))
|
(or (project-file-exists-p! (or "main.lua" "src/main.lua"))
|
||||||
(and (featurep! +moonscript)
|
(and (featurep! +moonscript)
|
||||||
(projectile-locate-dominating-file default-directory "main.moon")
|
(project-file-exists-p! (or "main.moon" "src/main.moon")))
|
||||||
(when-let (root (projectile-locate-dominating-file default-directory "src/main.moon"))
|
""))
|
||||||
(expand-file-name "src" root))))))
|
;; 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
|
||||||
|
;; main.lua/main.moon up the file tree as a backup.
|
||||||
|
(or (projectile-locate-dominating-file default-directory "main.lua")
|
||||||
|
(when-let (root (projectile-locate-dominating-file default-directory "src/main.lua"))
|
||||||
|
(expand-file-name "src" root))
|
||||||
|
(and (featurep! +moonscript)
|
||||||
|
(or (projectile-locate-dominating-file default-directory "main.moon")
|
||||||
|
(when-let (root (projectile-locate-dominating-file default-directory "src/main.moon"))
|
||||||
|
(expand-file-name "src" root))))))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue