LuaLS / LuaLS/lua-language-server
VM.OnCompileFunctionParam does not work at all
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the plugin reproduction in plugin.lua and the loading path referenced by script\plugin.lua:157, then compare the documented VM.OnCompileFunctionParam entry point with the working OnSetText hook. Reproduce the nil VM error using the shown .vscode/settings.json configuration. Done means the callback can be defined and invoked without the global VM error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- devtools, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100