LuaLS / LuaLS/lua-language-server

[Feature request] Class-based auto-require

オープン
#3,202 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Lua
スター
4.4k
フォーク
442
PR マージ指標
30日以内にマージされた PR はありません

説明

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.)

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、language server に既存の auto-require 設定と、関連する #3201 のリクエストを確認してください。クラスベースの候補が、ファイル名だけに依存せず、要求された import スタイルの文を生成できるようになれば、作業は完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
lua
領域
tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。