LuaLS / LuaLS/lua-language-server

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

Aperta
#477 10 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

enhancement feat/LuaCats Annotations priority.normal
Lingua principale
Lua
Stelle
4.4k
Fork
442
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia tracciando come sono rappresentate le EmmyLua annotations e le definizioni delle funzioni, quindi confrontale con i callback di LÖVE citati nell’issue. Decidi la sintassi dei callback e la loro interazione con le implementazioni dell’utente e il completamento dei parametri. Il lavoro è completato quando la notazione distingue i callback dalle funzioni ordinarie e abilita il completamento dei parametri dei callback; non vengono indicati file o test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
lua
Ambito
tooling
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.