Skip to content

Commit 76204f8

Browse files
committed
update
1 parent 8db2a51 commit 76204f8

File tree

7 files changed

+338
-95
lines changed

7 files changed

+338
-95
lines changed

CHANGELOG.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,84 @@
22

33
[中文Log](CHANGELOG_CN.md)
44

5+
# 0.9.22
6+
7+
`CHG` Generic constraint (StrTplRef) removes the protection for string:
8+
```lua
9+
---@generic T: string -- need to remove `: string`
10+
---@param a `T`
11+
---@return T
12+
local function class(a)
13+
end
14+
15+
---@class A
16+
17+
local A = class("A") -- error
18+
```
19+
20+
`NEW` Explicitly declared `Tuple` are immutable.
21+
```lua
22+
---@type [1, 2]
23+
local a = {1, 2}
24+
25+
a[1] = 3 -- error
26+
```
27+
28+
`FIX` Hover `function` now can show the corresponding doc comment.
29+
30+
`FIX` Fix a crash when `go to definition` of member
31+
32+
`NEW` Added the configuration item `classDefaultCall`, which is used to declare a method with the specified name as the default `__call` for a class. The effect is equivalent to `---@overload fun()`, but with a lower priority. If an explicitly declared `---@overload fun()` exists, `classDefaultCall` will have no effect on the class.
33+
34+
```json
35+
{
36+
"runtime": {
37+
"classDefaultCall": {
38+
"functionName": "__init",
39+
"forceNonColon": true,
40+
"forceReturnSelf": true
41+
}
42+
},
43+
}
44+
```
45+
46+
```lua
47+
---@class MyClass
48+
local M = {}
49+
50+
-- `functionName` is `__init`, so the call will be treated as `__init`
51+
function M:__init(a)
52+
-- `forceReturnSelf` is `true`, so the call will return `self`. even if the method does not return `self` or returns some other value.
53+
end
54+
55+
56+
-- `forceNonColon` is `true`, so the call can be called without `:` and without passing `self`
57+
-- `forceReturnSelf` is `true`, so the call will return `self`
58+
A = M() -- `A` is `MyClass`
59+
```
60+
61+
62+
`NEW` Added `docBaseConstMatchBaseType` configuration item, default is `false`. Base constant types defined in doc can match base types, allowing int to match `---@alias id 1|2|3`, same for string.
63+
64+
```json
65+
{
66+
"strict": {
67+
"docBaseConstMatchBaseType": true
68+
},
69+
}
70+
```
71+
72+
`FIX` When `enum` is used as a function parameter, it is treated as a value rather than the `enum` itself.
73+
74+
`FIX` When the expected type of a table field is a function, function completion is available.
75+
76+
`NEW` `inlay_hint` params hint can now jump to the actual type definition.
77+
78+
`NEW` When closing files in the editor that are not in the workspace or library, their impact will be removed
79+
80+
`NEW` Enhanced Ignore-related functionality. Files configured to be ignored will not be parsed even when opened, but due to technical constraints, files already open when starting the editor will still be parsed (to be fixed in a future update)
81+
82+
583
# 0.9.21
684

785
`NEW` Implement `std.Unpack` type for better type inference of the `unpack` function, and `std.Rawget` type for better type inference of the `rawget` function

CHANGELOG_CN.md

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,81 @@
11
# Change Log
22

3-
# 0.9.21
3+
# 0.9.22
4+
5+
`CHG` 泛型约束(StrTplRef)移除了对字符串的保护:
6+
```lua
7+
---@generic T: string -- 需要移除 `: string`
8+
---@param a `T`
9+
---@return T
10+
local function class(a)
11+
end
12+
13+
---@class A
14+
15+
local A = class("A") -- 错误
16+
```
17+
18+
`NEW` 显式声明的 `Tuple` 是不可变的。
19+
```lua
20+
---@type [1, 2]
21+
local a = {1, 2}
22+
23+
a[1] = 3 -- 错误
24+
```
25+
26+
`FIX` 悬停在 `function` 上现在可以显示相应的文档注释。
27+
28+
`FIX` 修复在成员的 `转到定义` 时可能出现的崩溃问题
29+
30+
`NEW` 添加了配置项 `classDefaultCall`,用于声明指定名称的方法作为类的默认 `__call`。效果等同于 `---@overload fun()`,但优先级较低。如果存在显式声明的 `---@overload fun()`,则 `classDefaultCall` 对该类不生效。
31+
32+
```json
33+
{
34+
"runtime": {
35+
"classDefaultCall": {
36+
"functionName": "__init",
37+
"forceNonColon": true,
38+
"forceReturnSelf": true
39+
}
40+
},
41+
}
42+
```
43+
44+
```lua
45+
---@class MyClass
46+
local M = {}
47+
48+
-- `functionName` 是 `__init`,所以调用将被视为 `__init`
49+
function M:__init(a)
50+
-- `forceReturnSelf` 为 `true`,所以调用将返回 `self`。即使该方法没有返回 `self` 或返回了其它值。
51+
end
52+
53+
54+
-- `forceNonColon` 为 `true`,所以调用可以不使用 `:` 且不传递 `self`
55+
-- `forceReturnSelf` 为 `true`,所以调用将返回 `self`
56+
A = M() -- `A` 是 `MyClass`
57+
```
58+
59+
`NEW` 添加了 `docBaseConstMatchBaseType` 配置项,默认为 `false`。doc 中定义的基础常量类型可以匹配基础类型,允许 int 匹配 `---@alias id 1|2|3`,字符串同理。
60+
61+
```json
62+
{
63+
"strict": {
64+
"docBaseConstMatchBaseType": true
65+
},
66+
}
67+
```
68+
69+
`FIX``enum` 被用作函数参数时,它被视为值而不是 `enum` 本身。
70+
71+
`FIX` 当表字段的预期类型是函数时,可以使用函数补全。
72+
73+
`NEW` `inlay_hint` 参数提示现在可以跳转到实际类型定义。
74+
75+
`NEW` 关闭不在工作区或库中的文件时,将移除它们的影响
76+
77+
`NEW` 增强了忽略相关功能。配置为忽略的文件即使被打开也不会被解析,但由于技术限制,启动编辑器时已经打开的文件仍会被解析(将在未来更新中修复)
78+
479
# 0.9.21
580

681
`NEW` 实现 `std.Unpack` 类型以提升 `unpack` 函数的类型推断,以及 `std.Rawget` 类型以提升 `rawget` 函数的类型推断

README.md

Lines changed: 133 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,140 @@
1-
![logo](/res/logo.png)
21
# EmmyLua for VSCode
32

4-
QQ交流群:`29850775` (最新版本以及部分视频演示在群文件中下载)
3+
![logo](/res/logo.png)
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`
514

615
[![Online EmmyLua Doc](https://img.shields.io/badge/emmy-doc-46BC99.svg?style=flat-square)](https://emmylua.github.io)
716
[![donate](https://img.shields.io/badge/donate-emmy-FF69B4.svg?style=flat-square)](https://emmylua.github.io/donate.html)
817
[![加入QQ群](https://img.shields.io/badge/chat-QQ群-46BC99.svg?style=flat-square)](//shang.qq.com/wpa/qunwpa?idkey=f1acce081c45fbb5670ed5f880f7578df7a8b84caa5d2acec230ac957f0c1716)
918

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.

build/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
exports.default = {
22
emmyDebuggerVersion: '1.8.5',
33
emmyDebuggerUrl: 'https://github.com/EmmyLua/EmmyLuaDebugger/releases/download',
4-
newLanguageServerVersion: "0.8.0",
4+
newLanguageServerVersion: "0.8.1",
55
newLanguageServerUrl: "https://github.com/CppCXY/emmylua-analyzer-rust/releases/download"
66
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "emmylua",
33
"displayName": "EmmyLua",
44
"description": "EmmyLua for vscode",
5-
"version": "0.9.21",
5+
"version": "0.9.22",
66
"icon": "res/icon.png",
77
"publisher": "tangzx",
88
"engines": {

0 commit comments

Comments
 (0)