DU-LuaC icon indicating copy to clipboard operation
DU-LuaC copied to clipboard

Add support to sumneko's Lua extension

Open matpratta opened this issue 3 years ago • 3 comments

Might require some extra fiddling with the .vscode directory, most specifically to set Lua version, ignore directory, library (for Codex) and max preloads (to support over 500kb of the Codex):

{
    "Lua.runtime.version": "Lua 5.3",
    "Lua.workspace.ignoreDir": [
        ".vscode",
        "out"
    ],
    "Lua.workspace.library": [
        "util/Codex.lua"
    ],
    "Lua.workspace.preloadFileSize": 1000,
    "Lua.workspace.maxPreload": 10000
}

matpratta avatar Oct 12 '22 21:10 matpratta

The lua extension also does not pull type definitions from the new Codex.lua for library, system, unit, etc. The latest version of Codex.lua instantiates the class with "system = System()" . To get type definitions I either had to add the appropriate ---@type... annotations or revert them to references of the class "system = System" .

I'm not sure if this would impact anything using emmylua for annotations or just this extension's implementation.

ghost avatar Oct 13 '22 02:10 ghost

@MatheusMK3 Be a bit careful with this. I've setup my own library paths so if the compiler starts modifying that, it might cause undesired effects.

PerMalmberg avatar Oct 13 '22 07:10 PerMalmberg

@fiddlybits01 I might add the ---@type annotations to handle it, but the correct way of doing it is really system = System() as system is an instance of the System class here. The annotations shouldn't be an issue though.

As for @PerMalmberg's comment, I'm still considering what to do, I was considering detecting pre-existing configs and "extending" them, but I'm not 100% sure yet.

matpratta avatar Oct 15 '22 22:10 matpratta