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) end in plugin.lua
- Add
"Lua.runtime.plugin": "C:/Path/plugin.lua" to .vscode/settings.json or 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
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:
Reproduction steps
function VM.OnCompileFunctionParam(next, func, param) endin plugin.lua"Lua.runtime.plugin": "C:/Path/plugin.lua"to.vscode/settings.jsonor similarAdditional 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:
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---@paramexplicitly.Log File
No response