|
1 | | - |
2 | 1 | # EmmyLua for VSCode |
3 | 2 |
|
4 | | -QQ交流群:`29850775` (最新版本以及部分视频演示在群文件中下载) |
| 3 | + |
| 4 | + |
| 5 | +EmmyLua is a powerful Lua language support extension for Visual Studio Code, providing intelligent code completion, debugging, and analysis capabilities. |
| 6 | + |
| 7 | +## 📋 Quick Links |
| 8 | + |
| 9 | +- 📖 [Documentation](https://github.com/EmmyLuaLs/emmylua-analyzer-rust/blob/main/docs/config/emmyrc_json_EN.md) |
| 10 | +- 📝 [Changelog (English)](CHANGELOG.md) |
| 11 | +- 📝 [更新日志 (中文)](CHANGELOG_CN.md) |
| 12 | +- 🔧 [Language Server (Rust)](https://github.com/CppCXY/emmylua-analyzer-rust) |
| 13 | +- 💬 QQ Group: `29850775` |
5 | 14 |
|
6 | 15 | [](https://emmylua.github.io) |
7 | 16 | [](https://emmylua.github.io/donate.html) |
8 | 17 | [](//shang.qq.com/wpa/qunwpa?idkey=f1acce081c45fbb5670ed5f880f7578df7a8b84caa5d2acec230ac957f0c1716) |
9 | 18 |
|
10 | | -[更新日志](CHANGELOG_CN.md) |
11 | | - |
12 | | -[CHANGELOG](CHANGELOG.md) |
13 | | - |
14 | | -[EmmyLua Langauge Server](https://github.com/CppCXY/emmylua-analyzer-rust) |
15 | | - |
16 | | -## FAQ (中文 & English) |
17 | | - |
18 | | -**Q (中文)**: vscode-emmylua 全家桶还有哪些? |
19 | | -**Q (English)**: Which other extensions are included in the vscode-emmylua suite? |
20 | | -**A (中文)**: [EmmyLuaCodeStyle](https://marketplace.visualstudio.com/items?itemName=CppCXY.emmylua-codestyle), [EmmyLuaUnity](https://marketplace.visualstudio.com/items?itemName=CppCXY.emmylua-unity) |
21 | | -**A (English)**: Install [EmmyLuaCodeStyle](https://marketplace.visualstudio.com/items?itemName=CppCXY.emmylua-codestyle) and [EmmyLuaUnity](https://marketplace.visualstudio.com/items?itemName=CppCXY.emmylua-unity) |
22 | | - |
23 | | -**Q (中文)**: 为什么附加调试没有作用? |
24 | | -**Q (English)**: Why doesn't attach debugging work? |
25 | | -**A (中文)**: 调试会尝试获取进程中的 Lua 符号,因此需要进程导出 Lua 符号 |
26 | | -**A (English)**: The debugger needs Lua symbols from the process, so the process must export them |
27 | | - |
28 | | -**Q (中文)**: Emmy New Debug 为什么连不上目标? |
29 | | -**Q (English)**: Why does Emmy New Debug fail to connect? |
30 | | -**A (中文)**: 可能是插入代码 require 失败或返回 true,表明可执行文件未导出 Lua 符号 |
31 | | -**A (English)**: Usually the injected require code fails or returns true, indicating missing Lua symbols |
32 | | - |
33 | | -**Q (中文)**: 为什么打开项目后会有大量未定义变量警告? |
34 | | -**Q (English)**: Why do many undefined variable warnings appear after opening the project? |
35 | | -**A (中文)**: 未定义的全局变量会触发提示,可在项目根目录创建 .emmyrc.json 并禁用 undefined-global |
36 | | -**A (English)**: Undefined globals trigger warnings; create .emmyrc.json in your project root and disable undefined-global |
37 | | - |
38 | | -**Q (中文)**: 我能否在其他平台使用 vscode-emmylua 的代码分析? |
39 | | -**Q (English)**: Can I use vscode-emmylua’s code analysis on other platforms? |
40 | | -**A (中文)**: 可以,它基于 [emmylua-analyzer-rust](https://github.com/CppCXY/emmylua-analyzer-rust),兼容支持 LSP 的客户端 |
41 | | -**A (English)**: Yes, it uses [emmylua-analyzer-rust](https://github.com/CppCXY/emmylua-analyzer-rust), which is a standard LSP |
42 | | - |
43 | | -**Q (中文)**: 为什么不用 VSCode 配置,而是用 .emmyrc.json? |
44 | | -**Q (English)**: Why use .emmyrc.json instead of VSCode settings? |
45 | | -**A (中文)**: 方便在其他平台上使用,无需在每个 IDE 中重复配置 |
46 | | -**A (English)**: It works across platforms without extra IDE configuration |
47 | | - |
48 | | -**Q (中文)**: 为什么用 Rust 重写语言服务器?放弃.net和java语言服务器 |
49 | | -**Q (English)**: Why rewrite the language server in Rust? and abandon the .NET and Java servers? |
50 | | -**A (中文)**: 因为我想试试 rust |
51 | | -**A (English)**: I want to try rust |
52 | | - |
53 | | -**Q (中文)**: 为什么没有文档? |
54 | | -**Q (English)**: Why is there no documentation? |
55 | | -**A (中文)**: 配置文件文档见 https://github.com/CppCXY/emmylua-analyzer-rust/blob/main/docs/config/emmyrc_json_CN.md |
56 | | -**A (English)**: See configuration docs at https://github.com/CppCXY/emmylua-analyzer-rust/blob/main/docs/config/emmyrc_json_EN.md |
57 | | - |
58 | | -## FAQ – Debugging (中文 & English) |
59 | | - |
60 | | -**Remote Debug Setup (中文)** |
61 | | -1) 在 VSCode 中打开 Lua 文件 |
62 | | -2) 插入调试库路径并 require |
63 | | -3) 在需要断点处添加 dbg.waitIDE(); dbg.breakHere() |
64 | | -4) 运行外部程序等待连接 |
65 | | -5) 启动 “EmmyLua New Debug” 与目标调试 |
66 | | - |
67 | | -**Remote Debug Setup (English)** |
68 | | -1) Load your Lua file in VSCode |
69 | | -2) Inject the debugger path and require it |
70 | | -3) Add dbg.waitIDE(); dbg.breakHere() where you want to break |
71 | | -4) Run your external program, which waits for a debugger |
72 | | -5) Launch “EmmyLua New Debug” to connect and debug |
| 19 | +## 🚀 Features |
| 20 | + |
| 21 | +- **Smart Code Completion**: Intelligent auto-completion with type inference |
| 22 | +- **Real-time Diagnostics**: Error detection and warnings as you type |
| 23 | +- **Advanced Debugging**: Support for attach, launch, and remote debugging |
| 24 | +- **Cross-platform**: Works on Windows, macOS, and Linux |
| 25 | +- **LSP-based**: Built on Language Server Protocol for reliability |
| 26 | + |
| 27 | +## 📦 Related Extensions |
| 28 | + |
| 29 | +Enhance your Lua development experience with these complementary extensions: |
| 30 | + |
| 31 | +- [EmmyLuaCodeStyle](https://marketplace.visualstudio.com/items?itemName=CppCXY.emmylua-codestyle) - Code formatting and style enforcement |
| 32 | +- [EmmyLuaUnity](https://marketplace.visualstudio.com/items?itemName=CppCXY.emmylua-unity) - Unity3D integration |
| 33 | + |
| 34 | +## 🔧 Configuration |
| 35 | + |
| 36 | +### Project Configuration |
| 37 | + |
| 38 | +Create a `.emmyrc.json` file in your project root to customize behavior: |
| 39 | + |
| 40 | +```json |
| 41 | +{ |
| 42 | + "diagnostics": { |
| 43 | + "undefined-global": false |
| 44 | + } |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +For detailed configuration options, see: |
| 49 | +- [English Documentation](https://github.com/CppCXY/emmylua-analyzer-rust/blob/main/docs/config/emmyrc_json_EN.md) |
| 50 | +- [中文文档](https://github.com/CppCXY/emmylua-analyzer-rust/blob/main/docs/config/emmyrc_json_CN.md) |
| 51 | + |
| 52 | +## 🐛 Debugging |
| 53 | + |
| 54 | +### Remote Debug Setup |
| 55 | + |
| 56 | +1. **Insert Debugger Code** |
| 57 | + - Use command: `EmmyLua: Insert Emmy Debugger Code` |
| 58 | + - Or manually add: |
| 59 | + ```lua |
| 60 | + package.cpath = package.cpath .. ";path/to/emmy/debugger/?.dll" |
| 61 | + local dbg = require('emmy_core') |
| 62 | + dbg.tcpListen('localhost', 9966) |
| 63 | + dbg.waitIDE() |
| 64 | + ``` |
| 65 | + |
| 66 | +2. **Set Breakpoints** |
| 67 | + - Add `dbg.breakHere()` where you want to pause execution |
| 68 | + - Or use VSCode's built-in breakpoint system |
| 69 | + |
| 70 | +3. **Start Debugging** |
| 71 | + - Run your Lua application |
| 72 | + - Launch "EmmyLua New Debug" configuration in VSCode |
| 73 | + - The debugger will connect automatically |
| 74 | + |
| 75 | +### Debug Types |
| 76 | + |
| 77 | +- **EmmyLua New Debug**: Modern debugging with better performance |
| 78 | +- **EmmyLua Attach**: Attach to running processes (requires exported Lua symbols) |
| 79 | +- **EmmyLua Launch**: Direct launch debugging |
| 80 | + |
| 81 | +## ❓ Frequently Asked Questions |
| 82 | + |
| 83 | +<details> |
| 84 | +<summary><strong>Why doesn't attach debugging work?</strong></summary> |
| 85 | + |
| 86 | +**English**: The debugger needs access to Lua symbols from the target process. Ensure your executable exports Lua symbols. |
| 87 | + |
| 88 | +**中文**: 调试器需要获取进程中的 Lua 符号,因此需要进程导出 Lua 符号。 |
| 89 | +</details> |
| 90 | + |
| 91 | +<details> |
| 92 | +<summary><strong>Why do I see many "undefined variable" warnings?</strong></summary> |
| 93 | + |
| 94 | +**English**: Create `.emmyrc.json` in your project root and disable the `undefined-global` diagnostic: |
| 95 | +```json |
| 96 | +{ |
| 97 | + "diagnostics": { |
| 98 | + "undefined-global": false |
| 99 | + } |
| 100 | +} |
| 101 | +``` |
| 102 | + |
| 103 | +**中文**: 在项目根目录创建 `.emmyrc.json` 文件并禁用 `undefined-global` 诊断。 |
| 104 | +</details> |
| 105 | + |
| 106 | +<details> |
| 107 | +<summary><strong>Can I use EmmyLua analysis in other editors?</strong></summary> |
| 108 | + |
| 109 | +**English**: Yes! EmmyLua uses a standard Language Server Protocol implementation. Any LSP-compatible editor can use it. |
| 110 | + |
| 111 | +**中文**: 可以!EmmyLua 基于标准的语言服务器协议,任何支持 LSP 的编辑器都可以使用。 |
| 112 | +</details> |
| 113 | + |
| 114 | +<details> |
| 115 | +<summary><strong>Why use .emmyrc.json instead of VSCode settings?</strong></summary> |
| 116 | + |
| 117 | +**English**: Project-specific configuration files work across different editors and platforms without requiring IDE-specific setup. |
| 118 | + |
| 119 | +**中文**: 项目配置文件可以跨平台和编辑器使用,无需在每个 IDE 中重复配置。 |
| 120 | +</details> |
| 121 | + |
| 122 | +<details> |
| 123 | +<summary><strong>Why was the language server rewritten in Rust?</strong></summary> |
| 124 | + |
| 125 | +**English**: The Rust implementation provides better performance, memory safety, and cross-platform compatibility compared to the previous .NET and Java versions. |
| 126 | + |
| 127 | +**中文**: Rust 实现提供了更好的性能、内存安全性和跨平台兼容性。(作者说:因为我想试试 rust 😄) |
| 128 | +</details> |
| 129 | + |
| 130 | +## 🤝 Contributing |
| 131 | + |
| 132 | +We welcome contributions! Please feel free to: |
| 133 | +- Report bugs and issues |
| 134 | +- Suggest new features |
| 135 | +- Submit pull requests |
| 136 | +- Join our QQ group for discussions |
| 137 | + |
| 138 | +## 📄 License |
| 139 | + |
| 140 | +This project is licensed under the MIT License. |
0 commit comments