japhib / pico8-ls

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

How to make pico8-ls aware of globals? #28

Closed beetrootpaul closed 1 year ago

beetrootpaul commented 1 year ago

How can I make pico8-ls aware of globals I have defined in another file and use across my codebase?

Here you can see on the screenshot how files within my src are marked orange due to warnings. When I look into some file, it seems like for example new_static_sprite and _color_15_peach are marked as "undefined variable".

Those variables come from other files. All files of my game are included in the .p8 file (and order of includes doesn't matter for most of files, since those usages are within functions… or at least I haven't stumble on any error in PICO-8 so far)

screenshot 2022-10-18 at 10 06 03
beetrootpaul commented 1 year ago

just in case:

japhib commented 1 year ago

It should be aware of globals as long as they're all #include'ed into the same .p8 file. I'll mark this as a bug.

beetrootpaul commented 1 year ago

just a random thought: what if having 4 different p8 files (with different sets of includes) messes things up?

beetrootpaul commented 1 year ago

ah, I think I have a lead! See, my p8 files do NOT include from src/ (where my code lives) but from build/ (where minified code ends in result of a npm start script).

If this is the culprit, then probably this is not a bug, just might be good to have a way to disable those warnings in plugin settings? 🤔 (OFC I would love for pico8-ls to take care of my globals, but if this cannot be easily done in my setup, then I prefer to turn off those particular warnings)

japhib commented 1 year ago

That would do it!