LuaLS / LuaLS/lua-language-server
No autocomplete for the "submodules" of a library when those included from init.lua
還沒有人認領這個 Issue。
- 主要語言
- Lua
- 星號
- 4.4k
- 分支
- 442
- PR 合併指標
- 30 天內沒有已合併 PR
描述
Dear developers, I've read similar existing issues but didn't find the answer.
I have a library (which I am the developer of) which has this structure:
and init.lua is
local UI = (...) .. '.'
return {
Block = require(UI .. 'Block'),
Image = require(UI .. 'Image'),
Label = require(UI .. 'Label'),
Layout = require(UI .. 'Layout'),
Rectangle = require(UI .. 'Rectangle'),
Stack = require(UI .. 'Stack'),
ImageButton = require(UI .. 'ImageButton'),
TextField = require(UI .. 'TextField'),
utils = require(UI .. 'utils')
}
and the rockspec contains this:
build = {
type = 'builtin',
modules = {
['likelihud'] = 'likelihud/init.lua',
['likelihud.Block'] = 'likelihud/Block.lua',
['likelihud.Image'] = 'likelihud/Image.lua',
['likelihud.Label'] = 'likelihud/Label.lua',
['likelihud.Layout'] = 'likelihud/Layout.lua',
['likelihud.Rectangle'] = 'likelihud/Rectangle.lua',
['likelihud.Stack'] = 'likelihud/Stack.lua',
['likelihud.ImageButton'] = 'likelihud/ImageButton.lua',
['likelihud.TextField'] = 'likelihud/TextField.lua',
['likelihud.utils'] = 'likelihud/utils.lua',
},
}
So after install I have
Coc-config:
{
"suggest.noselect": true,
"Lua.workspace.library" : [
"/usr/local/share/lua/5.1"
]
}
The problem
If I write
local Button = require('likelihud.ImageButton')
I get autocomplete for Button.
But if instead I do
local ui = require('likelihud')
I get only those fields when I do ui., but the fields are unknown. :
So the problem LSP doesn't resolve this (...) .. '.' inside init.lua. Should I somehow change how init.lua provides those files or how to fix that ?
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從提供的 init.lua 模組和 rockspec 開始,然後使用所示的 workspace.library 設定在 LuaLS 中重現兩種 require 模式。追蹤動態 require 路徑如何解析,以及回傳的表格欄位如何取得型別;當 ui. 為 init.lua 匯出的模組提供已知且具型別的欄位時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- lua
- 領域
- developer-experience, tooling
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 52/100