├── .gitignore ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── .vscodeignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── images └── pico8.png ├── package.json ├── src └── extension.ts ├── syntaxes ├── OSSREADME.json ├── language-configuration.json └── pico8.json └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | node_modules -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | { 3 | "version": "0.1.0", 4 | "configurations": [ 5 | { 6 | "name": "Launch Extension", 7 | "type": "extensionHost", 8 | "request": "launch", 9 | "runtimeExecutable": "${execPath}", 10 | "args": ["--extensionDevelopmentPath=${workspaceRoot}" ], 11 | "stopOnEntry": false, 12 | "sourceMaps": true, 13 | "outFiles": [ "${workspaceRoot}/out/src/**/*.js" ], 14 | "preLaunchTask": "npm" 15 | }, 16 | { 17 | "name": "Launch Tests", 18 | "type": "extensionHost", 19 | "request": "launch", 20 | "runtimeExecutable": "${execPath}", 21 | "args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test" ], 22 | "stopOnEntry": false, 23 | "sourceMaps": true, 24 | "outFiles": [ "${workspaceRoot}/out/test/**/*.js" ], 25 | "preLaunchTask": "npm" 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "files.exclude": { 4 | "out": false // set this to true to hide the "out" folder with the compiled JS files 5 | }, 6 | "search.exclude": { 7 | "out": true // set this to false to include "out" folder in search results 8 | }, 9 | "typescript.tsdk": "./node_modules/typescript/lib", 10 | "eslint.enable": false // we want to use the TS server from our node_modules folder to control its version 11 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // Available variables which can be used inside of strings. 2 | // ${workspaceRoot}: the root folder of the team 3 | // ${file}: the current opened file 4 | // ${fileBasename}: the current opened file's basename 5 | // ${fileDirname}: the current opened file's dirname 6 | // ${fileExtname}: the current opened file's extension 7 | // ${cwd}: the current working directory of the spawned process 8 | 9 | // A task runner that calls a custom npm script that compiles the extension. 10 | { 11 | "version": "0.1.0", 12 | 13 | // we want to run npm 14 | "command": "npm", 15 | 16 | // the command is a shell script 17 | "isShellCommand": true, 18 | 19 | // show the output window only if unrecognized errors occur. 20 | "showOutput": "silent", 21 | 22 | // we run the custom script "compile" as defined in package.json 23 | "args": ["run", "compile", "--loglevel", "silent"], 24 | 25 | // The tsc compiler is started in watching mode 26 | "isWatching": true, 27 | 28 | // use the standard tsc in watch mode problem matcher to find compile problems in the output. 29 | "problemMatcher": "$tsc-watch" 30 | } -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | out/test/** 4 | test/** 5 | src/** 6 | **/*.map 7 | .gitignore 8 | tsconfig.json 9 | vsc-extension-quickstart.md 10 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to the "pico8-vscode" extension will be documented in this file. 3 | 4 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 5 | 6 | ## [Unreleased] 7 | 8 | ## [0.0.1] - 2016-12-30 9 | ### Added 10 | - Initial release 11 | - Syntax highlighting 12 | - Ability to run a p8 file (default keyboard shortcut cmd+r) 13 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2016 John Barton 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pico8-vscode 2 | 3 | A new vscode extension for editing and running pico8 files. 4 | 5 | ![Example of running a pico8 workspace](https://cloud.githubusercontent.com/assets/4092/21540200/d5ac50e8-ce01-11e6-8aad-6c0b78751053.gif) 6 | 7 | I recommend having a separate pico8 workspace for doing dev in. I keep mine at `~/Projects/pico8` and 8 | it looks a bit like this 9 | 10 | ``` 11 | pico8 12 | ├── backup 13 | ├── bbs 14 | ├── carts 15 | │   └── hello.p8 16 | ├── cdata 17 | ├── config.txt 18 | ├── cstore 19 | ├── log.txt 20 | └── sdl_controllers.txt 21 | ``` 22 | 23 | This then allows me to open the workspace from the command line like 24 | 25 | ```sh 26 | joho6[19:22:03]:~/Projects/pico8 27 | 👻 code . 28 | ``` 29 | 30 | The benefit of this is that any edits and saves you make within pico8 (for example doing graphics or sound) 31 | will be written back into the workspace where you would expect it, rather than into the default home 32 | which is likely to be far, far away from the warm embrace of source control 33 | 34 | ## Features 35 | 36 | * Syntax highlighting for *.p8 files 37 | * If used in workspace mode will set the pico8 home to your workspace 38 | * CMD+R to open automatically run the .p8 you're editing in pico8 39 | * A humane licence (no twitter egg anti-sjw MIT variant here) 40 | 41 | ## Requirements 42 | 43 | You need to have pico8. 44 | 45 | ## Extension Settings 46 | 47 | This extension contributes the following settings: 48 | 49 | * `pico8.executablePath`: path to where your pico8 actually is (default is `/Applications/PICO-8.app/Contents/MacOS/pico8`) 50 | 51 | ## Known Issues 52 | 53 | Best I can say is that it "works on my machine" 54 | 55 | ## Release Notes 56 | 57 | ### 0.0.1 58 | 59 | Initial release of pico8-vscode 60 | 61 | ## License 62 | 63 | All code is by John Barton and [MIT licensed](/LICENSE.md) with the exception of the syntaxes folder which is covered by [the original author's license](/syntaxes/OSSREADME.json) 64 | -------------------------------------------------------------------------------- /images/pico8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pico-8/pico8-vscode/d03f2445bbaf74156f9d5bc13108c88a0f74dc15/images/pico8.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pico8-vscode", 3 | "displayName": "pico8-vscode", 4 | "description": "Do all the pico8 things in vscode", 5 | "version": "0.0.1", 6 | "author": { 7 | "name": "John Barton" 8 | }, 9 | "private": true, 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/joho/pico8-vscode.git" 13 | }, 14 | "icon": "images/pico8.png", 15 | "publisher": "johob", 16 | "engines": { 17 | "vscode": "^1.5.0" 18 | }, 19 | "categories": [ 20 | "Other" 21 | ], 22 | "activationEvents": [ 23 | "onLanguage:pico8" 24 | ], 25 | "main": "./out/src/extension", 26 | "contributes": { 27 | "languages": [{ 28 | "id": "pico8", 29 | "extensions": [ 30 | ".p8" 31 | ], 32 | "configuration": "./syntaxes/language-configuration.json" 33 | }], 34 | "grammars": [{ 35 | "language": "pico8", 36 | "scopeName": "source.p8", 37 | "path": "./syntaxes/pico8.json" 38 | }], 39 | "commands": [{ 40 | "command": "pico8.run", 41 | "title": "Run a pico8 file" 42 | }], 43 | "keybindings": [ 44 | { "key": "cmd+r", "command": "pico8.run" } 45 | ], 46 | "configuration": { 47 | "type": "object", 48 | "title": "Pico-8 Configuration", 49 | "properties": { 50 | "pico8.executablePath": { 51 | "type": "string", 52 | "default": "/Applications/PICO-8.app/Contents/MacOS/pico8", 53 | "description": "Path to the pico8 cli (ie /Applications/PICO-8.app/Contents/MacOS/pico8 on MacOS, or C:\\WHO_KNOWS\\PICO8.EXE on windows)" 54 | } 55 | } 56 | } 57 | }, 58 | "scripts": { 59 | "vscode:prepublish": "tsc -p ./", 60 | "compile": "tsc -watch -p ./", 61 | "postinstall": "node ./node_modules/vscode/bin/install", 62 | "test": "node ./node_modules/vscode/bin/test" 63 | }, 64 | "devDependencies": { 65 | "typescript": "^2.0.3", 66 | "vscode": "^1.0.0", 67 | "mocha": "^2.3.3", 68 | "@types/node": "^6.0.40", 69 | "@types/mocha": "^2.2.32" 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/extension.ts: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import * as vscode from 'vscode'; 4 | 5 | import cp = require('child_process'); 6 | import path = require('path'); 7 | 8 | export function activate(context: vscode.ExtensionContext) { 9 | let p8Config = vscode.workspace.getConfiguration('pico8'); 10 | 11 | let disposable = vscode.commands.registerTextEditorCommand('pico8.run', (textEditor: vscode.TextEditor) => { 12 | 13 | let fileName = textEditor.document.fileName; 14 | let args = ["-windowed", "1", "-run", fileName]; 15 | 16 | let workspace = vscode.workspace; 17 | if (workspace) { 18 | args.push("-home", workspace.rootPath); 19 | } 20 | 21 | cp.execFile(p8Config['executablePath'], args, { env: process.env }, (err, stdout, stderr) => { 22 | if (err) { 23 | console.log(err); 24 | } 25 | }) 26 | }); 27 | 28 | context.subscriptions.push(disposable); 29 | } -------------------------------------------------------------------------------- /syntaxes/OSSREADME.json: -------------------------------------------------------------------------------- 1 | // ATTENTION - THIS DIRECTORY CONTAINS THIRD PARTY OPEN SOURCE MATERIALS: 2 | [{ 3 | "name": "textmate/lua.tmbundle", 4 | "version": "0.0.0", 5 | "license": "TextMate Bundle License", 6 | "repositoryURL": "https://github.com/textmate/lua.tmbundle", 7 | "licenseDetail": [ 8 | "Copyright (c) textmate-lua.tmbundle project authors", 9 | "", 10 | "If not otherwise specified (see below), files in this repository fall under the following license:", 11 | "", 12 | "Permission to copy, use, modify, sell and distribute this", 13 | "software is granted. This software is provided \"as is\" without", 14 | "express or implied warranty, and with no claim as to its", 15 | "suitability for any purpose.", 16 | "", 17 | "An exception is made for files in readable text which contain their own license information,", 18 | "or files where an accompanying file exists (in the same directory) with a \"-license\" suffix added", 19 | "to the base-name name of the original file, and an extension of txt, html, or similar. For example", 20 | "\"tidy\" is accompanied by \"tidy-license.txt\"." 21 | ] 22 | }] -------------------------------------------------------------------------------- /syntaxes/language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | "lineComment": "--", 4 | "blockComment": [ "--[[", "]]" ] 5 | }, 6 | "brackets": [ 7 | ["{", "}"], 8 | ["[", "]"], 9 | ["(", ")"] 10 | ], 11 | "autoClosingPairs": [ 12 | ["{", "}"], 13 | ["[", "]"], 14 | ["(", ")"], 15 | ["\"", "\""], 16 | ["'", "'"] 17 | ], 18 | "surroundingPairs": [ 19 | ["{", "}"], 20 | ["[", "]"], 21 | ["(", ")"], 22 | ["\"", "\""], 23 | ["'", "'"] 24 | ] 25 | } -------------------------------------------------------------------------------- /syntaxes/pico8.json: -------------------------------------------------------------------------------- 1 | { 2 | "comment": "Pico8/Lua Syntax: version 0.8 (based on https://github.com/Microsoft/vscode/blob/20b497e68c0a43f0e294a9d1ee82bb5b78f8fadb/extensions/lua/syntaxes/lua.json)", 3 | "fileTypes": [ 4 | "p8" 5 | ], 6 | "firstLineMatch": "^pico-8 cartridge.+", 7 | "name": "Pico8", 8 | "patterns": [ 9 | { 10 | "begin": "^__lua__", 11 | "end": "^__", 12 | "patterns": [ 13 | { 14 | "captures": { 15 | "1": { 16 | "name": "keyword.control.lua" 17 | }, 18 | "2": { 19 | "name": "entity.name.function.scope.lua" 20 | }, 21 | "3": { 22 | "name": "entity.name.function.lua" 23 | }, 24 | "4": { 25 | "name": "punctuation.definition.parameters.begin.lua" 26 | }, 27 | "5": { 28 | "name": "variable.parameter.function.lua" 29 | }, 30 | "6": { 31 | "name": "punctuation.definition.parameters.end.lua" 32 | } 33 | }, 34 | "match": "\\b(function)(?:\\s+([a-zA-Z_.:]+[.:])?([a-zA-Z_]\\w*)\\s*)?(\\()([^)]*)(\\))", 35 | "name": "meta.function.lua" 36 | }, 37 | { 38 | "match": "(?=?|(?