EmmyLua / IntelliJ-EmmyLua

Lua IDE/Debugger Plugin for IntelliJ IDEA
https://emmylua.github.io
Apache License 2.0
1.76k stars 295 forks source link

Love2d Debugging #170

Open turbo opened 6 years ago

turbo commented 6 years ago

Hi,

There are a few differences with using Love2d instead of LUA. Both use mobdebug to debug. But Love2d doesn't have "entry point files", it only takes one argument, the project directory. Here's some sample code:

function love.load()
    if arg[#arg] == "-debug" then
        require("mobdebug").start()
    end

    local a = foobar(21)
end

function love.update(dt)
end

function love.draw()
end

function foobar(val)
    return val * 2
end

-debug is the canonical way to make love2d start a mobdebug server (like ZeroBrane does it). This is my config:

lua

This works fine for Run, it just calls /usr/bin/love /home/turbo/Projects/luajtest. However, debugging doesn't work:

Error
boot.lua:481: Cannot load game at path '/home/turbo/Projects/luajtest/-e'.
Make sure a folder exists at the specified path.

Traceback

[C]: in function 'error'
[C]: in function 'xpcall'
[C]: in function 'xpcall'

Seems like emmy is appending -e to the first argument without a space, which of course causes love to crash. How do I get a space in there so that I can do

if arg[#arg] == "-e" then require("mobdebug").start() end

or am I doing this completely wrong?

DoctorGester commented 6 years ago

I was able to get the remote debugger working using the Remote configuration (not local with remote profile selected) but breakpoints are all wrong :(

DoctorGester commented 6 years ago

Nervermind, if you create a proper module with src directory set the breakpoints work. However it will break in a current location when first enabling a breakpoint, works properly when you press continue

D0NM commented 4 years ago

Here is my configuration for Love2D + Attach Debugger ( IntelliJ IDEA 2019.3 Community Edition / Windows 10 ) 2019-12-11_16-07-44 and 2019-12-11_16-07-30