VSCode autocomplete for Lua

I'm banging my head against a wall trying to get autocomplete working in Visual Studio Code. I've got a project setup which is mostly identical to the template posted elsewhere on the forum, but autocomplete/intellisense doesn't work. Anyone got any idea where I'm going wrong?

settings.json

{
    "Lua.runtime.version": "Lua 5.4",
    "Lua.diagnostics.disable": ["undefined-global", "lowercase-global"],
    "Lua.diagnostics.globals": ["playdate", "import"],
    "Lua.runtime.nonstandardSymbol": ["+=", "-=", "*=", "/="],
    "Lua.workspace.library": ["${PLAYDATE_SDK_PATH}/CoreLibs"],
    "Lua.workspace.preloadFileSize": 1000
}

I have the Lua and Lua plus extensions installed.

I also downloaded lua, because I figured those extensions might require it, and added it to the path (file is named lua.exe).

You might get a faster answer using VScode support channels?

Sorry I can't help.

Yes, you could be right. I'll try the discord also :slight_smile:

For anyone else who ends up in the same predicament:

This turned out to be an issue with Visual Studio Code being several versions behind (1.47.x).

A restart caused VSCode to prompt to do the update (now 1.64.2) and now everything seems to be working as expected.

(Also ${PLAYDATE_SDK_PATH}/CoreLibs should be $PLAYDATE_SDK_PATH/CoreLibs in the example settings I posted

4 Likes

Hi, discovered a curious autocompletion behaviour that kind of confused me for a while... (I'm using the setup pretty much identical to the one mentioned here albeit on mac os)

If I declare:

local pd = playdate
local gfx = playdate.graphics

then I'm having proper autocompletion when typing gfx elsewhere in the code
but if I do something like this (which kind of makes more sense to me - just referring to previously declared variable already pointing to playdate global):

local pd = playdate
local gfx = pd.graphics

then the autocompletion for gfx is not working anymore...
I mean I can live with that and happy that the autocompletion works in general, but curious what's going on and also posting so some other people don't get confused thinking the autocompletion is broken in general especially since using local variables as shorthand to complex and nested globals is recommended in documentation for performance reasons.