justarandomgeek / vscode-factoriomod-debug

Factorio Mod Tool Kit
Other
97 stars 21 forks source link

Sumneko don't do Lua diagnostics correctly. #102

Open YPetremann opened 8 months ago

YPetremann commented 8 months ago

I use my ~/.factorio/mods as workspace

here the workspace config:

{
  "factorio.versions": [
    {
      "name": "Home",
      "factorioPath": "~/.factorio/bin/x64/factorio",
      "active": true
    }
  ],
  "Lua.workspace.library": [
    "/home/ypetremann/.factorio/data"
  ],
  "Lua.workspace.userThirdParty": [
    "/home/ypetremann/.config/Code/User/workspaceStorage/41d17afb68f79f41547c41aa0b00bf09/justarandomgeek.factoriomod-debug/sumneko-3rd"
  ],
  "factorio.docs.docLinksVersion": "current",
  "factorio.package.zipLocation": "outside"
}

Sumneke throw me errors like :

Undefined global `game`.
Undefined global `serpent`.
Undefined global `rendering`.
Undefined global `script`.
Undefined type or alias `EventData.on_gui_checked_state_changed`.
...

This indicatre that sumneko don't work correctly with the factorio modding toolkit

K1ngLui commented 7 months ago

If you are using sumeko Lua V3.7.3 on Linux there are popups missing. I've had the same problem. Those missing popups result in not having the correct path in "Lua.workspace.library"

You could change the Version to V3.7.0 then the popups should show up, or you can add this path to your libraries.

"/home/your_name/.config/Code/User/workspaceStorage/{hex-num}/justarandomgeek.factoriomod-debug/sumneko-3rd/factorio/library"
justarandomgeek commented 7 months ago

This seems to be related to the recent changes in LuaLS checking for libraries: https://github.com/LuaLS/lua-language-server/issues/2419 https://github.com/LuaLS/lua-language-server/pull/2354

I've found setting "Lua.workspace.checkThirdParty": "ApplyInMemory" seems to work well, but i'm not sure i want to set that automatically yet (i expect it will change again in LuaLS, since it's not just us affected)