nesbox / TIC-80

TIC-80 is a fantasy computer for making, playing and sharing tiny games.
https://tic80.com
MIT License
5k stars 483 forks source link

Type annotations file for Lua #2250

Open Anrock opened 1 year ago

Anrock commented 1 year ago

Lua language server supports type annotations for better diagnostics and QoL like autocompletion. See https://luals.github.io/wiki/annotations

I think TIC-80 should provide these especially since some of the API calls are pretty crazy (like map).

I can (slowly, in free time) make a file with annotations (have some already, actually) but I'm not sure how it should be distributed and made available to users since external file support is available only in PRO version.

Should TIC-80 just ship the file somewhere with binaries? Should it be created with a command from TIC console (like export)? Should it just be put with other type annotation files in LuaLS repo and link given in TIC wiki?

I guess we can at least convert wiki type annotations to more-or-less standardized ones from LuaLS.

nesbox commented 1 year ago

Looks interesting, I just can't figure out how it works. I see there should be a language server, where should it be hosted, locally or remotely on tic80.com?

Anrock commented 1 year ago

@nesbox usually (99.9% of cases) the language server process is launched by code editor and running on user machine. Some language servers can work over sockets but such setups aren't common

Roughly, the process is like this

  1. User opens a file in his editor
  2. Editor determines type of the file and launches corresponding language server as a child process
  3. Editor then communicates with language server over stdio, sending file contents and commands and receiving back autocompletions, diagnostics and other useful stuff which is then presented to user by the editor.