Add set-project-type! autodef
And use it for love2d projects in lang/lua module.
This commit is contained in:
parent
ba7c713bf6
commit
22cc519ac1
3 changed files with 28 additions and 4 deletions
|
@ -5,9 +5,23 @@
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(autoload 'projectile-relevant-known-projects "projectile")
|
(autoload 'projectile-relevant-known-projects "projectile")
|
||||||
|
|
||||||
|
;;;###autodef
|
||||||
|
(cl-defun set-project-type! (name &key predicate compile run test configure dir)
|
||||||
|
"Add a project type to `projectile-project-type'."
|
||||||
|
(declare (indent 1))
|
||||||
|
(after! projectile
|
||||||
|
(add-to-list 'projectile-project-types
|
||||||
|
(list name
|
||||||
|
'marker-files when
|
||||||
|
'compilation-dir dir
|
||||||
|
'configure-command configure
|
||||||
|
'compile-command compile
|
||||||
|
'test-command test
|
||||||
|
'run-command run))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Macros
|
;;; Macros
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defmacro without-project-cache! (&rest body)
|
(defmacro without-project-cache! (&rest body)
|
||||||
|
@ -29,7 +43,7 @@ they are absolute."
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Commands
|
;;; Commands
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/find-file-in-other-project (project-root)
|
(defun doom/find-file-in-other-project (project-root)
|
||||||
|
@ -55,7 +69,7 @@ they are absolute."
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Library
|
;;; Library
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom-project-p (&optional dir)
|
(defun doom-project-p (&optional dir)
|
||||||
|
|
|
@ -11,10 +11,17 @@
|
||||||
(defun +lua/run-love-game ()
|
(defun +lua/run-love-game ()
|
||||||
"Run the current project with Love2D."
|
"Run the current project with Love2D."
|
||||||
(interactive)
|
(interactive)
|
||||||
(when-let (root (locate-dominating-file buffer-file-name "main.lua"))
|
(when-let (root (+lua-love-project-root))
|
||||||
(async-shell-command
|
(async-shell-command
|
||||||
(format "%s %s"
|
(format "%s %s"
|
||||||
(or (executable-find "love")
|
(or (executable-find "love")
|
||||||
(if IS-MAC "open -a love.app"))
|
(if IS-MAC "open -a love.app"))
|
||||||
(shell-quote-argument (file-name-directory root))))))
|
(shell-quote-argument (file-name-directory root))))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun +lua-love-project-root ()
|
||||||
|
"Returns the directory where a main.lua exists.
|
||||||
|
|
||||||
|
Returns nil if 'love' executable can't be found."
|
||||||
|
(and (executable-find "love")
|
||||||
|
(locate-dominating-file buffer-file-name "main.lua")))
|
||||||
|
|
|
@ -30,6 +30,9 @@
|
||||||
:modes (lua-mode markdown-mode json-mode)
|
:modes (lua-mode markdown-mode json-mode)
|
||||||
:files (and "main.lua" "conf.lua")
|
:files (and "main.lua" "conf.lua")
|
||||||
:on-load
|
:on-load
|
||||||
|
(set-project-type! 'love2d
|
||||||
|
:predicate #'+lua-love-project-root
|
||||||
|
:run #'+lua/run-love-game)
|
||||||
(map! :localleader
|
(map! :localleader
|
||||||
:map +lua-love-mode-map
|
:map +lua-love-mode-map
|
||||||
"b" #'+lua/run-love-game))
|
"b" #'+lua/run-love-game))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue