LuaLS / LuaLS/lua-language-server

[Feature Request] Add Lua config file support

Đang mở
#3,198 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

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ả

There are some Lua files that are used for configuration, such as `.busted` or `*.rockspec` files. It would be nice if:

- Any globals defined in them are ignored by default
- Global types and return types can be defined for them in a type definition file

This behavior could all be described by creating a type definition file with a special `(config)` option next to `@meta`. The require name is replaced by a Lua pattern that matches the filename or URI. Either that, or it could be specified as a config-specific option using `---@meta (config: PATTERN)`

```lua
-- library/rockspec.d.lua

---@meta (config) "[%w%.%-%_]+%.rockspec$"

---the rockspec format
---@type string
_G.rockspec_format = nil

---the package name
---@type string
_G.package = nil

---the package version
---@type string
_G.version = nil

---a description of the rock
---@class luarocks.rockspec.description
---@field summary string? -- a short sentence that succinctly describes the rock
---@field description string? -- a paragraph-size description that describes the rock
---@field ...
_G.description = {}
```

For configurations that require returning a table, you could define a local variable with the right type and return it.

```lua
-- library/busted.d.lua

---@meta (config) "%.busted$"

---@class .busted.config
---@field coverage boolean? -- use luacov for coverage
---@field verbose boolean? -- print more things
---@field ...

---a dictionary of Busted configurations. You can specify which one using the
---`--run` option. Uses `default` if no configuration is specified
---@class .busted
---@field default .busted.config?
---@field [string] .busted.config?
local busted_config = {}

return busted_config
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng việc xem xét cú pháp `@meta` dành riêng cho cấu hình được đề xuất và các định nghĩa ví dụ trong `library/rockspec.d.lua` và `library/busted.d.lua`. So sánh các phương án khớp tên tệp cấu hình hoặc URI. Hoàn thành khi các tệp cấu hình Lua có thể bỏ qua các biến toàn cục theo mặc định và sử dụng các định nghĩa kiểu và giá trị trả về từ các tệp định nghĩa khớp.

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
devtools
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
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
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.