LuaLS / LuaLS/lua-language-server

Priority for function definitions in external files over local script

未关闭
#3,106 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Lua
星标
4.4k
派生
442
PR 合并指标
30 天内没有已合并 PR

描述

Description:
When a function is defined both in an external file (e.g., qlua.d.lua) and in the local script, Lua Language Server prioritizes the local definition. This behavior makes it difficult to use external annotations and documentation for functions that are implemented locally.

Steps to reproduce:
Define a function in qlua.d.lua with annotations:
lua
Copy
---@param index number
---@return number|nil
function OnCalculate(index) end
Define the same function in the local script without annotations:

lua
Copy
function OnCalculate(index)
-- Implementation
end
Hover over the function in the local script.

Expected behavior:
Lua Language Server should prioritize the definition from qlua.d.lua for tooltips and documentation.
Actual behavior:
Lua Language Server uses the local definition, ignoring the one from qlua.d.lua.
Proposed solution:
Add an option to prioritize definitions from external files over local ones. For example, a setting like:

json
Copy
{
"Lua.workspace.prioritizeExternalDefinitions": true
}
VS Code
Ver: 1.98.0 (user setup)
Фиксация: 6609ac3d66f4eade5cf376d1cb76f13985724bcb
Data: 2025-03-04T21:06:18.612Z
Electron: 34.2.0
ElectronBuildId: 11044223
Chromium: 132.0.6834.196
Node.js: 20.18.2
V8: 13.2.152.36-electron.0
OS: Windows_NT x64 10.0.19045
LUA:
ID- sumneko.lua
Ver- 3.13.6

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先追踪语言服务器如何解析重复的函数定义,以及工作区设置如何声明和读取。复现 qlua.d.lua 和 local-script 示例,然后验证新设置会使悬停文档使用外部定义,同时默认保留当前行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
lua
领域
devtools
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
活跃
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。