LuaLS / LuaLS/lua-language-server
VM.OnCompileFunctionParam does not work at all
Nessuno ha ancora preso questa issue.
- Lingua principale
- Lua
- Stelle
- 4.4k
- Fork
- 442
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
How are you using the lua-language-server?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Windows
What is the issue affecting?
Plugins
Expected Behaviour
According to https://luals.github.io/wiki/plugins/#vmoncompilefunctionparam, VM.OnCompileFunctionParam() is supposed to work.
Actual Behaviour
It simply does not work, and throws this error instead:
2026-01-28 20:58:08.342 [info] C:\Path\plugin.lua:4: attempt to index a nil value (global 'VM')
stack traceback:
C:\Path\plugin.lua:4: in main chunk
[C]: in global 'xpcall'
script\plugin.lua:157: in function <script\plugin.lua:95>
2026-01-28 20:58:08.348 [info] [Error - 8:58:08 PM] An error occurred in the plugin, please report it to the plugin author.
Please check the details in the output or log.
Plugin path: C:\Path\plugin.lua
Reproduction steps
- Write
function VM.OnCompileFunctionParam(next, func, param) endin plugin.lua - Add
"Lua.runtime.plugin": "C:/Path/plugin.lua"to.vscode/settings.jsonor similar - The error happens
Additional Notes
Please note that OnSetText() works as advertised, so the plugin system works; it is only this specific feature that does not seem to be working correctly.
For context, my library has JS-style event callbacks that work roughly like this:
addHook("PlayerUpdate", function(player)
end)
As you probably guessed already, I was hoping to use VM.OnCompileFunctionParam() to make it detect the parameter's type without requiring explicitly annotations, since generics do not seem to support this pattern at the moment?
I could also use OnSetText() instead, but it sounds like a less reliable method as it depends on the formatting, and it would also cause a warning about duplicate annotations if the user typed the ---@param explicitly.
Log File
No response
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con la riproduzione del plugin in plugin.lua e con il percorso di caricamento referenziato da script\plugin.lua:157, quindi confronta il punto di ingresso documentato VM.OnCompileFunctionParam con l’hook funzionante OnSetText. Riproduci l’errore VM nil usando la configurazione .vscode/settings.json mostrata. Il lavoro è completato quando il callback può essere definito e invocato senza l’errore VM globale.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- lua
- Ambito
- devtools, tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100