Skip to content

Commit

Permalink
Add initial support for Löve and Lövr
Browse files Browse the repository at this point in the history
  • Loading branch information
xyproto committed Jan 13, 2025
1 parent 4f3fbcb commit aa205dd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
4 changes: 4 additions & 0 deletions v2/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,10 @@ func (e *Editor) BuildOrExport(tty *vt100.TTY, c *vt100.Canvas, status *StatusBa
}
// the exportPandoc function handles it's own status output
return htmlFilename, nil
case mode.Lua:
if e.IsLuaLove() || e.IsLuaLovr() {
return "", nil
}
}

// The immediate builds are done, time to build a exec.Cmd, run it and analyze the output
Expand Down
26 changes: 25 additions & 1 deletion v2/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,23 @@ func (e *Editor) Run() (string, bool, error) {
cmd = exec.Command("xdg-open", pdfFilename)
}
case mode.Lua:
cmd = exec.Command("lua", sourceFilename)
if e.IsLuaLove() {
const macLovePath = "/Applications/love.app/Contents/MacOS/love"
if isDarwin && files.Exists(macLovePath) {
cmd = exec.Command(macLovePath, sourceFilename)
} else {
cmd = exec.Command("love", sourceFilename)
}
} else if e.IsLuaLovr() {
const macLovrPath = "/Applications/lovr.app/Contents/MacOS/lovr"
if isDarwin && files.Exists(macLovrPath) {
cmd = exec.Command(macLovrPath, sourceFilename)
} else {
cmd = exec.Command("lovr", sourceFilename)
}
} else {
cmd = exec.Command("lua", sourceFilename)
}
case mode.Make:
cmd = exec.Command("make")
case mode.Java:
Expand Down Expand Up @@ -216,3 +232,11 @@ func CombinedOutputSetPID(c *exec.Cmd) ([]byte, error) {
// Return the output bytes and the error, if any
return b.Bytes(), err
}

func (e *Editor) IsLuaLove() bool {
return e.mode == mode.Lua && strings.Contains(e.String(), "function love.draw(")
}

func (e *Editor) IsLuaLovr() bool {
return e.mode == mode.Lua && strings.Contains(e.String(), "function lovr.draw(")
}

0 comments on commit aa205dd

Please sign in to comment.