Log In  

Howdy folks, this is my first post here!

What is this?

I've written a full set of EmmyLua API definitions for the PICO-8 API, so that you can get full autocomplete/intellisense suggestions and documentation when editing code in an external editor.

Recording showing multiple examples of autocomplete in action

Why?

I've been following pico8 for a few years now but haven't sunk my teeth into really making anything until recently. Something that I've sorely missed all the times I have tinkered about with pico8 is proper code editor awareness of the pico8 API, autocomplete, definitions etc (coming from a C# and JavaScript background).
I thought for sure somebody would have made this but I couldn't even find any real proper editor support for Lua in general ... until now! I've discovered a neat language server utility called EmmyLua. It allows you to decorate code with annotations that provide type information and documentation. If you are familiar with JSDoc, it's very similar to that. EmmyLua has first-class support for 2 of the main code editors out right now: VSCode and IntelliJ.

Where do I get it?

You can find the files you need on the GitHub repository for the project. You just need to include 1 single .lua file somewhere in your project, it can be in a separate folder, and won't interfere with your PICO-8 setup at all.

You missed some stuff! / Something is wrong!

Please let me know! You can raise an issue / pull request on GitHub, or just let me know on here.

Thanks!

Please let me know if you find this useful! I'd love to hear feedback of all kinds. Thanks!

P#89228 2021-03-19 21:24

1

I'm probably just dense, but you wrote

I thought for sure somebody would have made this but I couldn't even find any real proper editor support for Lua in general

However, VSCode has plenty of extensions for Lua support and even Pico8. I'm using Pico-8 VSCode Plugin by Grumpydev, which installs directly through the extensions browser; no files to include. Is yours providing something different? Does the EmmyLua server provide a level of functionality that an extension cannot?

P#89241 2021-03-19 23:44

Yeah, I would love to make it into an extension, but I didn't have the motivation to figure out how to do that. Ideally it would become an extension one day!

The main benefit being added here is awareness of the PICO-8 API in your editor. This is something I haven't seen anywhere else (to my surprise). Grumpydev's extension adds a lot of nice snippets for making it easier to write repetitive bits of code, but it doesn't give you intellisense for the API.

For example, using EmmyLua means vscode knows what functions do or do not exist, what parameters they take, and what types each param is. It also documents what the return type of each function is. This means your editor always knows about the types of the variables you are using. For example, if you assign the result of pget() to a variable, your editor will know that variable is a Color (a number). If you assign a variable of the wrong type to a parameter, you editor might warn you that you are incorrectly mixing types.

This is basically about discoverability and avoiding of mistakes. I am still new to the PICO-8 API so I don't know what functions exist or what they do. Having my editor able to tell me what functions there are and how to use them makes it much easier to write code.

P#89243 2021-03-20 01:13

@peabnuts123 I do get Intellisense though.
(as I look at it more closely, it is a little inconsistent TBH)

P#89253 2021-03-20 06:26 ( Edited 2021-03-20 06:28)

The little square indicates a snippet 🙂 you’ll see it has no place for type information or documentation. It’s simply a shortcut (“line”) that expands to a longer sequence (“line(x0,y0,x1,y1,black)”) and tabs through each value for you to fill out

P#89255 2021-03-20 06:48

This is amazing, thank you so much <3

P#93061 2021-06-05 16:59

[Please log in to post a comment]