LuaLS / LuaLS/lua-language-server

Non-deterministic behavior when there are multiple parent folders with .luarc.json.

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

還沒有人認領這個 Issue。

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

描述

### How are you using the lua-language-server?

NeoVim

### Which OS are you using?

Linux

### What is the issue affecting?

Diagnostics/Syntax Checking

### Expected Behaviour

When the language server processes a Lua file, it should use the .luarc.json file that is closest (in the chain of parent folders) to the file being opened. So in this case:
```
dir1
|- .luarc.json
\_ dir2
|- .luarc.json
\_ code.lua
```
Opening code.lua should use dir2/.luarc.json.

### Actual Behaviour

Non-deterministic behavior: sometimes it uses dir1/.luarc.json and sometimes it uses dir2/.luarc.json. This is a big problem e.g. in cases where those two files specify different versions of Lua.

### Reproduction steps

Create the directory/file structure above, specifying different version of Lua in each one, then put some code in code.lua that is sensitive to the version, then run lua-language-server (I run it through Neovim) on code.lua, and observe sometimes it assumes one version of Lua and other times it uses the other.

Deleting dir1/.luarc.json then eliminates the non-deterministic behavior and it always uses dir2/.luarc.json.

### Additional Notes

_No response_

### Log File

_No response_

貢獻指南

開啟貢獻指南

從這裡開始

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

研究方向

首先,使用兩個 .luarc.json 檔案重現目錄結構,並透過 Neovim 開啟 code.lua。追蹤 lua-language-server 如何發現設定檔,並比較設定不同 Lua 版本時的重複執行結果。當最近的父目錄設定能夠始終一致地被選取,且重現不再顯示非決定性診斷時,即表示完成。

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

評估

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

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

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