VSCode plugin has not been updated for quite some time by the maintainer of the plugin, and the recent defold update has caused these issues. The plugin needs to be updated.
This is just a warning and should not stop you from running your game, but if it bothers you then add the following line to the top of your script file
---@diagnostic disable: undefined-global, undefined-field
The warning will go away
Thanks!
Defold updates are not the reason here, as there is no reason to update the plugin for VS Code.
The root of this problem isn’t in any of VS Code plugins but in the fact that the Spine extension lacks Lua annotations that would inform the Lua Language Server about existense of the spine
global namespace and its functions.
I would recommend to avoid disabling diagnostics for undefined global variables and fields, as this is one of the important linter rules. Instead, it’s better to add spine
and other native extensions without Lua annotations to the ignore list in the file .vscode/settings.json
:
"Lua.diagnostics.globals": [
...,
"spine"
],
Is there an example of a repository with annotations for a native extension? And perhaps a script for generating them from .script_api
. I want to update all my assets so that the vscode community can enjoy using them.
Unfortunally, the script I use to generate Defold API annotations parses json
documentation files, not script_api
. It would be smarter to parse the script_api
so that annotations for native extensions can be also generated, but what’s done is done.
I tried to find an example of Lua annotations for native extensions, but nothing came to mind. I remember someone shared the annotations for imgui but can’t find it anymore. So I tried to start with the most common example — Spine: