LuaLS / LuaLS/lua-language-server
feature suggestion: add a notation for callbacks that expects the user to implement
还没有人认领这个 Issue。
- 主要语言
- Lua
- 星标
- 4.4k
- 派生
- 442
- PR 合并指标
- 30 天内没有已合并 PR
描述
There exist some callbacks in the LÖVE framework, like love.conf, love.draw and some others, and there is currently no way in EmmyLua to note that they are callbacks rather than normal functions, and that a new definition of the same function is an implementation rather than a new overload.
Current Behavior
No way to indicate that this is a callback instead of a normal function definition.
-- In the API definition.
---xxx
---@param t string
function callback(t) end
-- In user code
function callback(t)
t:$
end
There is no completion based on the type of the parameter or ...
Suggested Behavior
Add a new notation for callbacks so when user is defining a new implementation, they can get completion on the parameters. This is especially useful when the parameter is extremely complex (for an example, see love.conf)
-- In the API definition.
---@callback
---xxx
---@param t string
callback = nil
-- In the user code
function callback(t)
t:$
end
I am totally open to the specific syntax, and I think what is really important is to have a syntax for them.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先追踪 EmmyLua annotations 和函数定义的表示方式,然后将其与 issue 中提到的 LÖVE 回调进行比较。确定回调语法,以及它与用户实现和参数补全之间的交互方式。当该记法能够区分回调和普通函数,并支持回调参数补全时,即视为完成;不指定任何文件或测试。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua
- 领域
- tooling
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 30/100