pico-api is a project consisting of definition files for the sumneko/lua extension for VSCode, allowing you to write PICO-8 or Picotron programs with the support of modern editor features.
Setup
- Install and enable sumneko/Lua extensions in VSCode Marketplace

-
Download pico-api
- New a folder .vscode in your workspace, and put the file setting.json into it
.png)
- Change the field Lua.workspace.library in .vscode/settings.json to the path to the folder picotron(or folder pico8, depending on the type of your project)
.png)
- New a cartridge and use this snippet at the top of its code:
-- picotron cd("/myproj") include("main.lua") |
-- pico8 #include main.lua |
Then you can write code in the workspace of VSCode and enjoy code prompts, formatting, AI copilot, etc.
.png)
Issues
Picotron Shorthand is not completely supported.
> !=
operator and shorthand assignment operators (like +=
, -=
, etc) can be used now. Thanks to @arnaught.
This is a very rough version. Welcome to submit issues and PRs.
Reference
https://marketplace.visualstudio.com/items?itemName=sumneko.lua



This is cool! I've been working on basically the same thing: https://github.com/Rayquaza01/picotron-definitions
Worth noting this doesn't just work with VSCode, but any editor that can use Lua Language Server.
Shorthand can be partially supported with changes to the .luarc.json / settings.json file. I believe Lua LS supports all of the shorthand assignment operators Picotron uses except ..=
. You can also disable some of the builtin modules that aren't available in Picotron. See this as an example: https://github.com/Rayquaza01/fuzzy-finder-picotron/blob/main/.luarc.json



I am not understanding the snippet I use to actually get functionality in vscode. I tried copy pasting your snippets and i get stack overflows in picotron. Can you assist me? I am sure it is user error lol



@arrangedgodly the file is run in VSCode rather than in Picotron. So you should follow the steps to setup your workspace. Copy and pasting the snippets directly is not the correct way.



I am trying to follow setting up the workspace but step 5 isn't making sense to me, can you clarify what I do?



@arrangedgodly you can read this chapter in the manual:
https://www.lexaloffle.com/dl/docs/picotron_manual.html#Using_External_Editors



Thank you! I noticed that flip_x and flip_y for spr() are number? rather than boolean? in picotron/graphics.lua, and did I pull request, is that OK?



Hello! I didn't find your project until now, and had started working on my own: https://github.com/Teajey/luacats-pico8
I came up with a way to generate the types from pico_manual.txt, and to use overloads to show in detail how each function can be called.
But I like your project structure better than mine 😅
I wonder if you'd want to merge our projects? I could add the features of mine to yours



@teajey
It is a very clever approach to use the Python script to generate files directly from the manual.
However, I noticed that the parameter types are not specified in the manual.
This needs to be checked manually and supplemented by experience and experimentation.
So at the moment I am only considering the PR of adding and revising content.



Right, my approach would be to manage parameter types manually. It means I will have to pay attention to what changes I stage for Git commits after running the generator.
No worries. I'll continue with mine and see how it goes.


.png)
Thanks, I will try to use it for my Picotron project! 💛
I will post my finding on GitHub 👍
[Please log in to post a comment]