LuaLS / LuaLS/lua-language-server

feature suggestion: add a notation for callbacks that expects the user to implement

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

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

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

説明

There exist some callbacks in the LÖVE framework, like love.conf, love.draw and some others, and there is currently no way in EmmyLua to note that they are callbacks rather than normal functions, and that a new definition of the same function is an implementation rather than a new overload.

Current Behavior

No way to indicate that this is a callback instead of a normal function definition.

-- In the API definition.
---xxx
---@param t string
function callback(t) end


-- In user code
function callback(t)
    t:$
end

There is no completion based on the type of the parameter or ...

Suggested Behavior

Add a new notation for callbacks so when user is defining a new implementation, they can get completion on the parameters. This is especially useful when the parameter is extremely complex (for an example, see love.conf)

-- In the API definition.
---@callback
---xxx
---@param t string
callback = nil

-- In the user code
function callback(t)
    t:$
end

I am totally open to the specific syntax, and I think what is really important is to have a syntax for them.

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

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

はじめの一歩

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

調査の方向性

まず、EmmyLua annotations と関数定義がどのように表現されているかを追跡し、それを issue で名前が挙げられている LÖVE コールバックと比較します。コールバック構文と、それがユーザー実装およびパラメーター補完とどのように相互作用するかを決定します。記法によってコールバックと通常の関数が区別され、コールバックパラメーターの補完が可能になれば完了です。ファイルやテストの名前は挙げません。

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

評価

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

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

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