Skip to content

EmmyLuaLs/emmylua_dap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

25 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ EmmyLua Debug Adapter

A powerful Debug Adapter Protocol (DAP) implementation for Lua debugging

Rust Platform Lua LuaJIT

Built on top of the robust EmmyLuaDebugger foundation


โœจ Features

  • ๐ŸŽฏ 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

๐Ÿš€ Quick Start

๐Ÿ“ฆ Installation

  1. Download the latest release from the releases page
  2. Extract the executable to your desired location
  3. Ensure the emmy_core library is available in your Lua environment

๐Ÿ› ๏ธ Setup Your Lua Application

Add the following debug code to your Lua application:

๐Ÿ–ฅ๏ธ Windows

-- 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()

๐Ÿง Linux

-- 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()

๐ŸŽ macOS

-- 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()

โš™๏ธ DAP Configuration

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
}

๐ŸŽฎ Usage

  1. Add debug code to your Lua application (see setup section above)
  2. Start your Lua program - it will wait for the debugger to connect
  3. Launch the debug session from your editor using the DAP configuration
  4. Set breakpoints and start debugging! ๐ŸŽ‰

๐Ÿ”ง Editor Integration

VS Code

Currently, the EmmyLua extension does not use this project as its DAP implementation.

Neovim
  1. Install the nvim-dap plugin
  2. 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
  }
}
  1. Start debugging with :DapContinue
IntelliJ IDEA
  1. Install the "EmmyLua" or "LSP4IJ" plugin
  2. Go to Run โ†’ Edit Configurations
  3. Add a new Debug Adapter Protocol configuration
  4. set command path to emmylua_dap executable
  5. write working directory
  6. debug mode: launch
  7. 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
  1. Open your project in Zed
  2. 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
  }
]
  1. Start debugging from the Debug panel
Vim (with vim-dap)
  1. Install a DAP plugin like vimspector or vim-dap
  2. 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"]
    }
  }
}
  1. Start debugging with :VimspectorLaunch
Emacs (with dap-mode)
  1. Install dap-mode package
  2. 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))
  1. 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:

  1. Find and install a DAP plugin/extension for your editor
  2. Configure the adapter executable path
  3. Set up the launch configuration with the parameters shown above
  4. Connect to your Lua application on port 9966

๐Ÿ“‹ Configuration Options

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

๐Ÿค Contributing

We welcome contributions! Please feel free to:

  • ๐Ÿ› Report bugs
  • ๐Ÿ’ก Suggest features
  • ๐Ÿ”ง Submit pull requests
  • ๐Ÿ“š Improve documentation

๐Ÿ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages