I made definition files so that LSP can support pico8/picotron's library functions and special syntax, so that pico8/picotron programs can be written in external editors such as VSCode while getting the help of various modern features.
How to
- 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
- 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)
- 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.
Issues
Picotron Shorthand is not supported.
> UPDATE: Thanks to @arnaught. !=
operator and shorthand assignment operators like +=
can be used now.
This is a very rough version. If you have any questions, please raise them in the repo issue or comment directly here. You can also add and modify definitions in the file yourself.
link
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?
[Please log in to post a comment]