LuaLS / LuaLS/lua-language-server
VM.OnCompileFunctionParam does not work at all
まだ誰も着手していません。
- 主要言語
- Lua
- スター
- 4.4k
- フォーク
- 442
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
plugin.lua でのプラグインの再現と、script\plugin.lua:157 で参照されている読み込みパスの確認から始め、その後、文書化されているエントリーポイント VM.OnCompileFunctionParam と動作する OnSetText フックを比較します。示されている .vscode/settings.json の設定を使って nil VM エラーを再現します。コールバックを定義して呼び出せ、グローバル VM エラーが発生しなければ完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua
- 領域
- devtools, tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100