lang/lua: improve moonscript & love2D support
- Fix moonscript-mode not highlighting/treating single-quoted strings as strings - Fontify interpolated expressions in moonscript-mode strings (PR upstream?) - Fix +lua-love-mode project detection - Fix +lua/run-love-game love project root resolution
This commit is contained in:
parent
74877edd5d
commit
1f0a5f04f2
4 changed files with 66 additions and 32 deletions
38
modules/lang/lua/autoload/lua.el
Normal file
38
modules/lang/lua/autoload/lua.el
Normal file
|
@ -0,0 +1,38 @@
|
|||
;;; lang/lua/autoload/lua.el -*- lexical-binding: t; -*-
|
||||
|
||||
(defun +lua-love-build-command ()
|
||||
(when-let (root (+lua-love-project-root))
|
||||
(format "%s %s"
|
||||
(if (executable-find "love")
|
||||
"love"
|
||||
(if IS-MAC "open -a love.app"))
|
||||
(shell-quote-argument root))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +lua/open-repl ()
|
||||
"Open Lua REPL."
|
||||
(interactive)
|
||||
(lua-start-process "lua" "lua")
|
||||
(pop-to-buffer lua-process-buffer))
|
||||
|
||||
;;;###autoload
|
||||
(defun +lua/run-love-game ()
|
||||
"Run the current project with Love2D."
|
||||
(interactive)
|
||||
(if-let (cmd (+lua-love-build-command))
|
||||
(async-shell-command cmd)
|
||||
(user-error "Couldn't find love project")))
|
||||
|
||||
;;;###autoload
|
||||
(defun +lua-love-project-root ()
|
||||
"Returns the directory where a main.lua exists.
|
||||
|
||||
Returns nil if 'love' executable can't be found."
|
||||
(when (executable-find "love")
|
||||
(or (and (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)
|
||||
(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