LuaLS / LuaLS/lua-language-server

Require paths not resolved when external library is loaded and using custom require path

未關閉
#2,992 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Lua
星號
4.4k
分支
442
PR 合併指標
30 天內沒有已合併 PR

描述

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Windows

What is the issue affecting?

Completion, Hover, Libraries

Expected Behaviour

Hovering above lib should find lua/lib.lua.

Actual Behaviour

Hovering above lib yields 3 bytes, and only finds the path if either the file has not been loaded or no extra workspace library directory has been found.

Reproduction steps
  1. Setup the files:
-- lua/lib.lua
return {
	test = "hello"
}
-- cmd/test.lua
local lib = require 'lib'

assert(lib.test == "hello")
-- .luarc.json
{
	"runtime.path": [
		"lua/?.lua",
		"lua/?/init.lua"
	],
	"workspace.library": [
		"${3rd}/love2d/library"
	]
}
  1. Close NeoVim.
  2. Reopen NeoVim and open only the file cmd/test.lua
  3. Hover above lib and see bug.
  4. Open lua/lib.lua
  5. Go back to cmd/test.lua
  6. Completion is now available again.
Additional Notes

I could not reproduce this behaviour in VSCode.

Log File

Log file generated using the reproduction steps: https://pastebin.com/4VXMJjjB

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

使用 .luarc.json 搭配 lua/lib.lua 和 cmd/test.lua 重現此問題,依照列出的 NeoVim 步驟操作並檢查連結的日誌。追蹤外部程式庫載入後 custom runtime.path 和 workspace.library 的處理方式;完成的標準是在不先開啟 lua/lib.lua 的情況下,懸停和補全都能一致地解析 lib。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
lua
領域
tooling
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。