japhib / pico8-ls

PICO-8 Language Server
MIT License
64 stars 8 forks source link

Support #include files #3

Closed japhib closed 2 years ago

japhib commented 2 years ago

Support go-to-definition and all the other features for files that are #include'ed into a cartridge.

thomasdziedzic commented 2 years ago

When using this plugin and having a single include in my .p8 file:

#include main.lua

I get an error from the extension:

unexpected symbol '#' near 'include'

Is this expected until this feature is implemented?

japhib commented 2 years ago

Yeah, although it’d be a pretty quick change to at least not have it emit an error for the #include statement itself

japhib commented 2 years ago

Fixed with 0.4.0 (#include files are now fully supported)

scambier commented 2 years ago

Hello :)

The syntax itself works, but variables and functions declared in another file are not recognized

Here, I have board.lua and main.lua included in game.p8. When I reference Board in main.lua, this warning is displayed: image

japhib commented 2 years ago

That makes sense, since the symbols from board.lua and main.lua would be imported into game.p8 but e.g. board.lua would not be imported into main.lua.

I think it'd be doable to track the #includes to see which files are included by which other files and solve this use case. I'll re-open this issue until I make that change.

japhib commented 2 years ago

Fixed with 0.4.1