Skip to content

EmmyLua/VSCode-EmmyLua

Repository files navigation

EmmyLua for VSCode

logo

EmmyLua is a powerful Lua language support extension for Visual Studio Code, providing intelligent code completion, debugging, and analysis capabilities.

📋 Quick Links

Online EmmyLua Doc donate 加入QQ群

🚀 Features

  • Smart Code Completion: Intelligent auto-completion with type inference
  • Real-time Diagnostics: Error detection and warnings as you type
  • Advanced Debugging: Support for attach, launch, and remote debugging
  • Cross-platform: Works on Windows, macOS, and Linux
  • LSP-based: Built on Language Server Protocol for reliability

📦 Related Extensions

Enhance your Lua development experience with these complementary extensions:

🔧 Configuration

Project Configuration

Create a .emmyrc.json file in your project root to customize behavior:

{
  "diagnostics": {
    "undefined-global": false
  }
}

For detailed configuration options, see:

🐛 Debugging

Remote Debug Setup

  1. Insert Debugger Code

    • Use command: EmmyLua: Insert Emmy Debugger Code
    • Or manually add:
    package.cpath = package.cpath .. ";path/to/emmy/debugger/?.dll"
    local dbg = require('emmy_core')
    dbg.tcpListen('localhost', 9966)
    dbg.waitIDE()
  2. Set Breakpoints

    • Add dbg.breakHere() where you want to pause execution
    • Or use VSCode's built-in breakpoint system
  3. Start Debugging

    • Run your Lua application
    • Launch "EmmyLua New Debug" configuration in VSCode
    • The debugger will connect automatically

Debug Types

  • EmmyLua New Debug: Modern debugging with better performance
  • EmmyLua Attach: Attach to running processes (requires exported Lua symbols)
  • EmmyLua Launch: Direct launch debugging

❓ Frequently Asked Questions

Why doesn't attach debugging work?

English: The debugger needs access to Lua symbols from the target process. Ensure your executable exports Lua symbols.

中文: 调试器需要获取进程中的 Lua 符号,因此需要进程导出 Lua 符号。

Why do I see many "undefined variable" warnings?

English: Create .emmyrc.json in your project root and disable the undefined-global diagnostic:

{
  "diagnostics": {
    "undefined-global": false
  }
}

中文: 在项目根目录创建 .emmyrc.json 文件并禁用 undefined-global 诊断。

Can I use EmmyLua analysis in other editors?

English: Yes! EmmyLua uses a standard Language Server Protocol implementation. Any LSP-compatible editor can use it.

中文: 可以!EmmyLua 基于标准的语言服务器协议,任何支持 LSP 的编辑器都可以使用。

Why use .emmyrc.json instead of VSCode settings?

English: Project-specific configuration files work across different editors and platforms without requiring IDE-specific setup.

中文: 项目配置文件可以跨平台和编辑器使用,无需在每个 IDE 中重复配置。

Why was the language server rewritten in Rust?

English: The Rust implementation provides better performance, memory safety, and cross-platform compatibility compared to the previous .NET and Java versions.

中文: Rust 实现提供了更好的性能、内存安全性和跨平台兼容性。(作者说:因为我想试试 rust 😄)

🤝 Contributing

We welcome contributions! Please feel free to:

  • Report bugs and issues
  • Suggest new features
  • Submit pull requests
  • Join our QQ group for discussions

📄 License

This project is licensed under the MIT License.