插件新增特性
Lua 5.1 module(...) 模块声明支持
- 背景:本插件基于 LuaHelper 二次开发,补充了 Lua 5.1 中
module(...) 的模块声明支持,方便兼容现有项目。
- 作用:为使用
module('modname', package.seeall) 的代码提供模块内符号解析、跳转、补全、引用与诊断。
- 识别规则:
- 识别
module("xxx", package.seeall),将当前文件声明的符号归入全局模块 xxx 的命名空间;
示例:
-- a.lua
module("A", package.seeall)
function foo(x)
return x + 1
end
BAR = 42
-- b.lua
A.foo(1)
print(A.BAR)
注意:
- 新项目建议使用“返回表”模块风格(return table),
module(...) 支持主要用于兼容旧项目;
忽略不存在的全局变量(支持正则)
- 配置项:luahelper.base.ignoreUndefinedGlobals(字符串数组)
- 规则:同一数组中可混合“精确名”和“正则”
- 精确名:直接写变量名,如 "GlobalConfig"、"DEV"
- 正则:两种写法任选其一
示例 settings.json 片段:
{
"luahelper.base.ignoreUndefinedGlobals": [
"GlobalConfig",
"__DEV__",
"regex:^cc\\.",
"/^GAME_/"
]
}
说明:精确项性能更好(哈希匹配);正则仅对显式声明的项编译与匹配。上述配置会忽略如 cc.Sprite、GAME_VERSION 等前缀匹配的未定义全局告警。
class(...) 的 super 继承与隐式声明支持
- 继承:当使用 class 函数配合父类时,支持从父类(super)继承字段与方法信息,悬停/补全/跳转均可透传展示。
- 隐式声明:未显式
---@class 时,可基于 class('Name') 与后续成员赋值推断类型,提供基本的类型感知与诊断。
示例:
Animal = class("Animal")
function Animal:say() end
Dog = class("Dog", Animal) -- 此处不需要显式添加注解
function Dog:init()
self:say(); -- 从 super 继承的方法,可补全/跳转
end
LuaHelper Guide
LuaHelper is a High-performance lua plugin, Language Server Protocol for lua.

Introduction
Lua is very popular in game development because of its simple syntax and flexible use. However, its ecology is not perfect, and IDE tools and support are few, which affects Lua's development efficiency and quality. LuaHelper complies with Microsoft Language Server Protocol and is a cross-platform Lua code editing and testing tool developed in go language.
Compared with other Lua plugins currently on the market, it has the following improvements:
- [X] 1.Coroutine development, real-time detection, millisecond output detection results
- [X] 2.Support large-scale Lua projects, perfectly support editing and testing of 1000+ file project
- [X] 3.Comprehensive error type detection, including: grammar detection, semantic detection
- [X] 4.Various types of reference search, including: multi-file reference search, multi-layer reference search
- [X] 5.Rich configurable items, including: multiple alarm information configurations, ignorable file settings
- [X] 6.Low memory consumption, low-performance machines can still run smoothly
Lua因其语法简单、使用灵活,在游戏开发中十分流行。但其生态并不完善,IDE开发工具及配套支持较少,一定程度上影响了Lua的开发效率及质量。LuaHelper遵从微软Language Server Protocol协议,是采用go语言开发的一种跨平台Lua代码编辑及检测工具。
相较目前市面其他Lua插件,具有以下改进:
- [X] 1.协程开发,实时检测,毫秒级输出检测结果
- [X] 2.支持大型Lua项目,完美支持1000+文件项目工程的编辑与检测
- [X] 3.全面的错误类型检测,包括:语法检测、语义检测
- [X] 4.多种类引用查找,包括:多文件引用查找、多层引用查找
- [X] 5.丰富的可配置项,包括:多种告警信息配置、可忽略文件设定
- [X] 6.内存消耗低,低性能机器仍可流畅运行
Documentation
Feature Summary
Code Editing
Code Detection
Debugger
Feature Detail
Defintion Find/定义跳转
支持局部、全局文件定义查询跳转

Find All References/引用查找
支持基于作用域的各类型引用查找

Document Symbols/文件符号表查询
支持文件域符号表查询,在搜索栏输入@

Workspace Symbols/工程符号表查询
支持工程域符号表查询,在搜索栏输入#

Auto Code Completion/自动代码补全
支持变量、函数的自动输入提示

支持代码格式化

Hover/代码悬停
支持代码悬停提示

Hightlight Global Var/全局变量着色
支持全局变量高亮着色

Syntax Check/语法检测
提供丰富的语法错误检测类型

Semantic Check/语义检测
支持多种类型的语义检测

Quick Analysis/快速增量分析
支持增量变化分析,分析结果诊断输出

Debug Attach/调试连接其他进程
Debug Detail Use/调试详细使用

Debug Single Lua File/调试单lua文件
Debug Single Lua File [调试单文件]

Run Single Lua File/运行单lua文件
Run Single Lua File [运行单文件]

Installation
App Market Installation
- Click the Vs Code application market icon
- Search luahelper in the input box
- Click to install Lua Helper
应用市场安装
- 点击Vs Code应用市场图标
- 在输入框中搜索 luahelper
- 点击安装Lua Helper

Acknowledgements
- luago-books, go语言生成lua的AST,修改了源码(对AST的每个节点增加了列的属性,同时也优化了性能)。
- LuaFormatter, c++写的Lua代码格式化库,性能较高。
- LuaPanda, 集成了LuaPanda的调试组件,LuaPanda的作者stuartwang也给我们提供了很多帮助。
- EmmyLua, 作者阿唐对我们整个插件的实现提供很多帮助和建议。
Developer
yinfei, handsomeli, richardzha
Contribution
nattygui
Support
If you have any questions, please refer to FAQ. If you have any questions, please use issues. We will follow and reply.
如有问题先参阅 FAQ ,如有问题建议使用 issues ,我们会关注和回复。
Email:yvanfyin@tencent.com; handsomeli@tencent.com; richardzha@tencent.com
QQ群:747590892