A powerful Debug Adapter Protocol (DAP) implementation for Lua debugging
Built on top of the robust EmmyLuaDebugger foundation
- ๐ฏ Debug Adapter Protocol (DAP) compatible
- ๐ง Cross-platform support (Windows, Linux, macOS)
- ๐ Easy integration with any DAP-compatible editor
- ๐ Advanced debugging capabilities for Lua applications
- ๐ LuaJIT support for high-performance Lua applications
- ๐ Multiple file extensions support (.lua, .lua.txt, .lua.bytes)
- ๐ TCP connection for remote debugging
- Download the latest release from the releases page
- Extract the executable to your desired location
- Ensure the emmy_core library is available in your Lua environment
Add the following debug code to your Lua application:
-- Add the emmy_core library to your package path
package.cpath = package.cpath .. ";<path_to_emmy_core>/?.dll"
-- Initialize the debugger
local dbg = require("emmy_core")
dbg.tcpListen("localhost", 9966)
-- Optional: Wait for IDE connection
-- dbg.waitIDE()
-- Optional: Set a breakpoint
-- dbg.breakHere()-- Add the emmy_core library to your package path
package.cpath = package.cpath .. ";<path_to_emmy_core>/?.so"
-- Initialize the debugger
local dbg = require("emmy_core")
dbg.tcpListen("localhost", 9966)
-- Optional: Wait for IDE connection
-- dbg.waitIDE()
-- Optional: Set a breakpoint
-- dbg.breakHere()-- Add the emmy_core library to your package path
package.cpath = package.cpath .. ";<path_to_emmy_core>/?.dylib"
-- Initialize the debugger
local dbg = require("emmy_core")
dbg.tcpListen("localhost", 9966)
-- Optional: Wait for IDE connection
-- dbg.waitIDE()
-- Optional: Set a breakpoint
-- dbg.breakHere()Create a launch configuration in your editor:
{
"type": "emmylua_new",
"request": "launch",
"name": "๐ EmmyLua Debug Session",
"host": "localhost",
"port": 9966,
"sourcePaths": [
"path/to/your/workspace"
],
"ext": [
".lua",
".lua.txt",
".lua.bytes"
],
"ideConnectDebugger": true
}- Add debug code to your Lua application (see setup section above)
- Start your Lua program - it will wait for the debugger to connect
- Launch the debug session from your editor using the DAP configuration
- Set breakpoints and start debugging! ๐
VS Code
Currently, the EmmyLua extension does not use this project as its DAP implementation.
Neovim
- Install the
nvim-dapplugin - Configure the DAP adapter in your Neovim config:
local dap = require('dap')
dap.adapters.emmylua = {
type = 'executable',
command = '/path/to/emmylua_dap',
args = {}
}
dap.configurations.lua = {
{
type = 'emmylua',
request = 'launch',
name = 'EmmyLua Debug',
host = 'localhost',
port = 9966,
sourcePaths = { 'path/to/your/workspace' }, -- maybe exist some env variable
ext = { '.lua' },
ideConnectDebugger = true
}
}- Start debugging with
:DapContinue
IntelliJ IDEA
- Install the "EmmyLua" or "LSP4IJ" plugin
- Go to Run โ Edit Configurations
- Add a new
Debug Adapter Protocolconfiguration - set command path to
emmylua_dapexecutable - write working directory
- debug mode: launch
- debug parameters:
{
"type": "emmylua_new",
"request": "launch",
"name": " EmmyLua Debug Session",
"host": "localhost",
"port": 9966,
"sourcePaths": [
"${workspaceFolder}"
],
"ext": [
".lua",
".lua.txt",
".lua.bytes"
],
"ideConnectDebugger": true
}
Zed Editor
- Open your project in Zed
- Create or edit
.zed/debug.json:
[
{
"label": "EmmyLua Debug",
"adapter": "emmylua_new",
"type": "emmylua_new",
"request": "launch",
"host": "localhost",
"port": 9966,
"sourcePaths": ["$ZED_WORKTREE_ROOT"],
"ext": [".lua", ".lua.txt", ".lua.bytes"],
"ideConnectDebugger": true
}
]
- Start debugging from the Debug panel
Vim (with vim-dap)
- Install a DAP plugin like
vimspectororvim-dap - Configure
.vimspector.json:
{
"configurations": {
"EmmyLua Debug": {
"adapter": "emmylua",
"configuration": {
"request": "launch",
"host": "localhost",
"port": 9966,
"sourcePaths": ["${workspaceFolder}"],
"ext": [".lua", ".lua.txt", ".lua.bytes"],
"ideConnectDebugger": true
}
}
},
"adapters": {
"emmylua": {
"command": ["/path/to/emmylua_dap"]
}
}
}- Start debugging with
:VimspectorLaunch
Emacs (with dap-mode)
- Install
dap-modepackage - Add to your Emacs config:
(require 'dap-mode)
(dap-register-debug-template
"EmmyLua Debug"
(list :type "emmylua"
:request "launch"
:name "EmmyLua Debug Session"
:host "localhost"
:port 9966
:sourcePaths (list (lsp-workspace-root))
:ext (list ".lua" ".lua.txt" ".lua.bytes")
:ideConnectDebugger t))- Start debugging with
M-x dap-debug
Other Editors
Any editor that supports the Debug Adapter Protocol can be used with EmmyLua DAP:
- Eclipse (with DAP extensions)
- Sublime Text (with DAP plugins)
- Atom (with DAP packages)
- Kate (KDE Advanced Text Editor with DAP support)
General steps:
- Find and install a DAP plugin/extension for your editor
- Configure the adapter executable path
- Set up the launch configuration with the parameters shown above
- Connect to your Lua application on port 9966
| Option | Type | Description | Default |
|---|---|---|---|
host |
string | Debug server host | "localhost" |
port |
number | Debug server port | 9966 |
sourcePaths |
array | Source code directories | ["${workspaceFolder}"] |
ext |
array | Supported file extensions | [".lua", ".lua.txt", ".lua.bytes"] |
ideConnectDebugger |
boolean | IDE initiates connection | true |
We welcome contributions! Please feel free to:
- ๐ Report bugs
- ๐ก Suggest features
- ๐ง Submit pull requests
- ๐ Improve documentation
This project is licensed under the MIT License - see the LICENSE file for details.
- EmmyLuaDebugger - The core debugging engine
- emmy_dap_types
- Contributors who help improve this project