LuaLS / LuaLS/lua-language-server
Support for module-style includes?
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Lua
- Star
- 4.4k
- Fork
- 442
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
### 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.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách so sánh các thiết lập Lua.runtime.path, Lua.workspace.library và Lua.runtime.special được mô tả trong issue, đặc biệt khi import được ánh xạ tới require. Tái hiện các import tương đối với dự án bên dưới src/script-game và xác minh rằng chẩn đoán, đi tới định nghĩa và tính năng hoàn thành hoạt động mà không cần đường dẫn thư viện tuyệt đối.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- lua
- Lĩnh vực
- tooling
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100