LuaLS / LuaLS/lua-language-server
Support for module-style includes?
還沒有人認領這個 Issue。
- 主要語言
- Lua
- 星號
- 4.4k
- 分支
- 442
- PR 合併指標
- 30 天內沒有已合併 PR
描述
### How are you using the lua-language-server?
Other
### Which OS are you using?
Windows
### What is the issue affecting?
Diagnostics/Syntax Checking
### Expected Behaviour
Lua files from my project are found automatically without adding a workspace library path.
### Actual Behaviour
Incorrect diagnostics due to LSP seemingly being unable to find the lua files in the path. Also go to definition and such don't work.
### Reproduction steps
.
### Additional Notes
I have a lot of files in my project which I import like so:
```lua
import 'game.physics'
import 'game.ball.request'
import 'game.world'
```
Note that we use `import` instead of `require`. It doesn't do anything special regarding the paths, and I have the following setting:
```json
"Lua.runtime.special": {
"import" : "require"
}
```
These paths are relative to the workspace, plus some folders. The actual paths are like so:
```
/src/script-game/game/physics.lua
/src/script-game/game/ball/request.lua
/src/script-game/game/world.lua
```
From reading the documentation, it seems like the default `Lua.runtime.path` should pick these files up no problem, but I get diagnostics like "Undefined global "physics"", and I can't go to definition or get completions for those files (details omitted, sorry):

---
If I then add a config for `Lua.workspace.library`, I can make it work:
```
"Lua.workspace.library": [
"\\src\\script-game"
],
```
But this feels wrong. These are my files and they're part of my project. I shouldn't need to add them as a library path, should I? Additionally, I could only get it to work as an absolute path, so I need to update this whenever I switch projects. I tried "src/script-game" and "src\\script-game" and both reverted back to the broken behaviour.
Am I missing something? Do I need to set something custom in `Lua.runtime.path`?
### Log File
Unfortunately I can't provide this as most of it is under NDA.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先比較 issue 中描述的 Lua.runtime.path、Lua.workspace.library 和 Lua.runtime.special 設定,尤其是在將 import 對應到 require 的情況下。在 src/script-game 下重現專案相對匯入,並確認不使用絕對函式庫路徑時,診斷、前往定義和補全都能正常運作。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- lua
- 領域
- tooling
- Issue 類型
- 功能
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100