LuaLS / LuaLS/lua-language-server

[Feature request] Class-based auto-require

Đang mở
#3,202 0 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ả

My project has some strict styling, and what we have is a system where:

  • MyClass is the sole returned class in myclass.lua, annotated and everything
  • Usage is local MyClass = import("src.myclass")

The language server has a setting for auto-requires. Unfortunately, it hardcodes the require function & is completely filename based.

I've just opened #3201 to add the import thing, but I'd like to request a setting which makes auto-requires work better with the class names, rather than being filename-based.

Ex. MyClass.something() suggests to require the file as local MyClass = import("src.myclass") rather than myclass.

We've considered either not caring (very ugly for code-style), manually fixing it every time (makes auto-requires kind of useless) or changing the filenames to be cased the same as the class (not a proper solution but a workaround -- one that would make the file structure look worse & fear for case sensitive filesystems)

As far as I can tell, this seems like a language server limitation rather than a design limitation. I would try to contribute this option myself, but this codebase seems too complicated for me to understand unfortunately...

(I just realized I opened a similar request a year ago -- I completely forgot and have closed it now.)

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

Trước tiên, hãy xem xét cài đặt auto-require hiện có của language server và yêu cầu liên quan #3201. Công việc hoàn tất khi các gợi ý dựa trên lớp có thể tạo ra câu lệnh theo kiểu import được yêu cầu thay vì chỉ dựa vào tên tệ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
tooling
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
35/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.