Note: Croissant is in active development.
Croissant is based on sirocco.
C-h
or M-h
on an identifier)Requirements:
hererocks -rlatest
will install 2.4, you need to specify it with -r3.0
)luarocks install croissant
# Make sure lua/luarocks binaries are in your $PATH (~/.luarocks/bin)
croissant [-h] [<input>] [<arguments>] [-d [<debugger>] ...]
<input>
: a lua file to run or debug. If not provided, croissant will run the REPL.<arguments>
: arguments to pass to the <input>
script--debugger -d --break -b [file.lua:line] ...
: runs croissant in debugger mode and optionally sets breakpoints--help -h
: shows help messagecroissant filetodebug.lua -d
This will start croissant in debugger mode. You can then add some breakpoints with the breakpoint
command and start your script with the run
command.
Alternatively, you can require the debugger in your script where you want to break:
require "croissant.debugger"()
Croissant looks at the first word of your entry and runs any command it matches. It'll otherwise runs the entry as Lua code in the current frame context. If empty, croissant executes the previous repeatable command.
help [<command>]
: prints general help or help about specified commandrun
: starts your scriptargs <argument> ...
: set arguments to pass to your scriptwatch <expression>
: breaks when evaluated Lua expression
changes valuebreakpoint <where> [<when>]
: add a new breakpoint at <where>
(can be line number in current file, file.lua:line
or a function name) if <when>
(lua code evaluated in the breakpoint context) is true or absentcondition <#id> <when>
: change breaking condition of breakpoint #id
delete <#id>
: delete breakpoint or watchpoint #id
enable <#id>
: enable breakpoint or watchpoint #id
disable <#id>
: disable breakpoint or watchpoint #id
display <expression>
: display evalued Lua expression
each time the program stopsundisplay <#id>
: dlete display #id
clear
: deletes all breakpoints, watchpoints and displaysinfo <what>
:
breakpoints
: list breakpoints and watchpointslocals
: list locals of the current framedisplays
: list displaysstep
(repeatable): step in the codenext
(repeatable): step in the code going over any function callfinish
(repeatable): will break after leaving the current functionup
(repeatable): go up one framedown
(repeatable): go down one framecontinue
(repeatable): continue until hitting a breakpoint. If no breakpoint are specified, clears debug hookseval <code>
: runs code
(useful to disambiguate from debugger commands)depth <depthLimit> <itemsLimit>
: set depth limit and number of items when pretty printing valuesexit
: quitwhere [<rows>]
: prints <rows>
or conf.whereRows
rows around the current line. Is ran for you each time you step in the code or change frame contexttrace
: prints current stack trace and highlights current frame.dump.depthLimit
and dump.itemsLimit
value in your ~/.croissantrc
or the depth
command to avoid exploring to far down in complex tables.clear
before doing continue
.local function stopMe()
-- ...
end
local function call(fn)
fn()
end
call(stopMe)
You can customize some aspect of croissant by writing a ~/.croissantrc
lua file. Here are the default values than you can overwrite:
return {
-- Default prompt
prompt = "→ ",
-- Prompt used when editing multiple lines of code
continuationPrompt = ".... ",
-- Maximum amount of remembered lines
-- Croissant manages two history file: one for the repl (~/.croissant_history),
-- one for the debugger (~/.croissant_debugger_history)
historyLimit = 1000,
-- How many rows `where` should print around the current line
whereRows = 4,
-- Syntax highlighting colors
-- Available colors are: black, red, green, yellow, blue, magenta, cyan, white.
-- They can also be combined with modifiers: bright, dim, underscore, blink, reverse, hidden
syntaxColors = {
constant = { "bright", "yellow" },
string = { "green" },
comment = { "dim", "cyan" },
number = { "yellow" },
operator = { "yellow" },
keywords = { "bright", "magenta" },
identifier = { "blue" },
},
dump = {
-- Nesting limit at which croissant will stop when pretty printing a table
depthLimit = 5,
-- If a table has more items than itemsLimit, will stop there and print ellipsis
itemsLimit = 30
}
}
Read and understand the Caveats section.
luarocks install croissant --tree mygame/lua_modules
Tell Löve to search in lua_modules
:
love.filesystem.setRequirePath(
love.filesystem.getRequirePath()
.. ";lua_modules/share/lua/5.1/?/init.lua"
.. ";lua_modules/share/lua/5.1/?.lua"
)
love.filesystem.setCRequirePath(
love.filesystem.getCRequirePath()
.. ";lua_modules/lib/lua/5.1/?.so"
)
Require croissant.debugger
where you want to break:
require "croissant.debugger"()