├── .eslintrc.js ├── .gitignore ├── .vscode ├── launch.json └── tasks.json ├── LICENSE ├── README.md ├── images └── icon.png ├── janet.configuration.json ├── out ├── extension.js └── extension.js.map ├── package.json ├── src └── extension.ts ├── syntaxes └── janet.tmLanguage └── tsconfig.json /.eslintrc.js: -------------------------------------------------------------------------------- 1 | /**@type {import('eslint').Linter.Config} */ 2 | // eslint-disable-next-line no-undef 3 | module.exports = { 4 | root: true, 5 | parser: '@typescript-eslint/parser', 6 | plugins: [ 7 | '@typescript-eslint', 8 | ], 9 | extends: [ 10 | 'eslint:recommended', 11 | 'plugin:@typescript-eslint/recommended', 12 | ], 13 | rules: { 14 | 'semi': [2, "always"], 15 | '@typescript-eslint/no-unused-vars': 0, 16 | '@typescript-eslint/no-explicit-any': 0, 17 | '@typescript-eslint/explicit-module-boundary-types': 0, 18 | '@typescript-eslint/no-non-null-assertion': 0, 19 | } 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Index ./out for easy local install 2 | node_modules 3 | .vscode-test/ 4 | *.vsix 5 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [{ 8 | "name": "Run Extension", 9 | "type": "extensionHost", 10 | "request": "launch", 11 | "runtimeExecutable": "${execPath}", 12 | "args": [ 13 | "--extensionDevelopmentPath=${workspaceFolder}" 14 | ], 15 | "outFiles": [ 16 | "${workspaceFolder}/out/**/*.js" 17 | ], 18 | "preLaunchTask": "npm: watch" 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // See https://go.microsoft.com/fwlink/?LinkId=733558 2 | // for the documentation about the tasks.json format 3 | { 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "watch", 9 | "problemMatcher": "$tsc-watch", 10 | "isBackground": true, 11 | "presentation": { 12 | "reveal": "never" 13 | }, 14 | "group": { 15 | "kind": "build", 16 | "isDefault": true 17 | } 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 Calvin Rose and contributors 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Janet language support for Visual Studio Code 2 | 3 | ## Features 4 | 5 | - Syntax highlighting 6 | - Eval expression ```alt+e``` 7 | - Eval file ```alt+l``` 8 | 9 | ## Notes 10 | 11 | This extension is not published yet. To install proceed to local install section. 12 | 13 | ## Local install 14 | ``` 15 | # First, make sure you have Node.js version 14 or greater installed. 16 | 17 | # Clone the extension. 18 | git clone https://github.com/janet-lang/vscode-janet.git 19 | cd vscode-janet 20 | 21 | # Install vscode-janet dependencies. 22 | npm install 23 | 24 | # Generate the vscode extension (VSIX) file using vsce. 25 | npx vsce package 26 | 27 | # Install the extension. 28 | code --install-extension vscode-janet-0.0.2.vsix 29 | 30 | # Finally reload the vscode window (cmd + shift + P > Developer: Reload Window). 31 | ``` 32 | 33 | Alternatively you can clone the extension right into vscode's extention directory. This is easier, but can be unreliable as vscode will sometimes clean up the extension directory and remove vscode-janet. 34 | ``` 35 | # Clone the extension. 36 | cd ~/.vscode/extensions 37 | git clone https://github.com/janet-lang/vscode-janet.git 38 | 39 | # Force vscode to regenerate the extensions.json file. 40 | mv extensions.json /tmp/ 41 | 42 | # Finally reload the vscode window (cmd + shift + P > Developer: Reload Window). 43 | 44 | # If you're finding that vscode isn't loading the extension, you can force it to 45 | # regenerate the extensions.json file by removing ~/.vscode/extensions/extensions.json. 46 | ``` 47 | 48 | 49 | ## Debug this extension 50 | 51 | - Run `npm install` in terminal to install dependencies 52 | - Run the `Run Extension` target in the Debug View in VS Code. This will: 53 | - Start a task `npm: watch` to compile the code 54 | - Run the extension in a new VS Code window 55 | -------------------------------------------------------------------------------- /images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/janet-lang/vscode-janet/0225a87fb8c75d9dec024d592f2bdcf74f366e5e/images/icon.png -------------------------------------------------------------------------------- /janet.configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | "lineComment": "#" 4 | }, 5 | "brackets": [ 6 | ["[", "]"], 7 | ["(", ")"], 8 | ["{", "}"] 9 | ], 10 | "autoClosingPairs": [ 11 | ["[", "]"], 12 | ["(", ")"], 13 | ["{", "}"], 14 | { "open": "\"", "close": "\"", "notIn": ["string"] }, 15 | { "open": "`", "close": "`", "notIn": ["string", "comment"] } 16 | ], 17 | "surroundingPairs": [ 18 | ["[", "]"], 19 | ["(", ")"], 20 | ["{", "}"] 21 | ], 22 | "wordPattern": "[A-Za-z0-9\\!\\$\\%\\&\\*\\+\\-\\.\\/\\:\\<\\?\\=\\>\\@\\^\\_\\|\\x80-\\xFF]+", 23 | "onEnterRules": [ 24 | { 25 | "beforeText": "^[^#]*(\\{[^}]*|\\([^)]*|\\[[^\\]]*)$", 26 | "action": { "indent": "indent" } 27 | }, 28 | { 29 | "beforeText": "(^[^\\[#]*\\]\\s*(#.*)?\\s*$)|(^[^\\(#]*\\)\\s*(#.*)?\\s*$)|(^[^\\{#]*\\}\\s*(#.*)?\\s*$)", 30 | "action": { "indent": "outdent" } 31 | } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /out/extension.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.activate = void 0; 4 | const fs = require("fs"); 5 | const os = require("os"); 6 | const path = require("path"); 7 | const vscode = require("vscode"); 8 | const windows = os.platform() == 'win32'; 9 | const janetBinary = windows ? 'janet.exe' : 'janet'; 10 | const terminalName = 'Janet REPL'; 11 | function janetExists() { 12 | return process.env['PATH'].split(path.delimiter) 13 | .some((x) => fs.existsSync(path.resolve(x, janetBinary))); 14 | } 15 | function newREPL() { 16 | const terminal = vscode.window.createTerminal(terminalName); 17 | terminal.sendText(janetBinary + ' -s', true); 18 | return vscode.window.withProgress({ 19 | location: vscode.ProgressLocation.Notification, 20 | title: "Running Janet REPL...", 21 | cancellable: false 22 | }, (progress, token) => { 23 | return new Promise(resolve => { 24 | setTimeout(() => { 25 | terminal.show(); 26 | thenFocusTextEditor(); 27 | resolve(terminal); 28 | }, 2000); 29 | }); 30 | }); 31 | } 32 | function getREPL(show) { 33 | const terminal = vscode.window.terminals.find(x => x.name === terminalName); 34 | const terminalP = (terminal) ? Promise.resolve(terminal) : newREPL(); 35 | return terminalP.then(t => { 36 | if (show) { 37 | t.show(); 38 | } 39 | return t; 40 | }); 41 | } 42 | function sendSource(terminal, text) { 43 | terminal.sendText(text, true); 44 | } 45 | function thenFocusTextEditor() { 46 | setTimeout(() => vscode.commands.executeCommand('workbench.action.focusActiveEditorGroup'), 250); 47 | } 48 | function activate(context) { 49 | console.log('Extension "vscode-janet" is now active!'); 50 | if (!janetExists()) { 51 | vscode.window.showErrorMessage('Can\'t find Janet language on your computer! Check your PATH variable.'); 52 | return; 53 | } 54 | context.subscriptions.push(vscode.commands.registerCommand('janet.startREPL', () => { 55 | getREPL(true); 56 | })); 57 | context.subscriptions.push(vscode.commands.registerCommand('janet.eval', () => { 58 | const editor = vscode.window.activeTextEditor; 59 | if (editor == null) 60 | return; 61 | getREPL(true).then(terminal => { 62 | function send(terminal) { 63 | sendSource(terminal, editor.document.getText(editor.selection)); 64 | thenFocusTextEditor(); 65 | } 66 | if (editor.selection.isEmpty) 67 | vscode.commands.executeCommand('editor.action.selectToBracket').then(() => send(terminal)); 68 | else 69 | send(terminal); 70 | }); 71 | })); 72 | context.subscriptions.push(vscode.commands.registerCommand('janet.evalFile', () => { 73 | const editor = vscode.window.activeTextEditor; 74 | if (editor == null) 75 | return; 76 | getREPL(true).then(terminal => { 77 | sendSource(terminal, editor.document.getText()); 78 | thenFocusTextEditor(); 79 | }); 80 | })); 81 | context.subscriptions.push(vscode.commands.registerCommand('janet.formatFile', () => { 82 | getREPL(true).then(terminal => { 83 | sendSource(terminal, "(import spork/fmt) (fmt/format-file \"" + 84 | vscode.window.activeTextEditor.document.uri.fsPath.replace(/\\/g, "/") 85 | + "\")"); 86 | thenFocusTextEditor(); 87 | }); 88 | })); 89 | } 90 | exports.activate = activate; 91 | //# sourceMappingURL=extension.js.map -------------------------------------------------------------------------------- /out/extension.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,yBAAyB;AACzB,6BAA6B;AAC7B,iCAAiC;AAEjC,MAAM,OAAO,GAAY,EAAE,CAAC,QAAQ,EAAE,IAAI,OAAO,CAAC;AAElD,MAAM,WAAW,GAAW,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CA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AAC;AA1DD,4BA0DC"} -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vscode-janet", 3 | "displayName": "Janet", 4 | "description": "Janet language support for Visual Studio Code", 5 | "icon": "images/icon.png", 6 | "version": "0.0.2", 7 | "publisher": "janet-lang", 8 | "repository": "https://github.com/janet-lang/vscode-janet", 9 | "engines": { 10 | "vscode": "^1.34.0" 11 | }, 12 | "categories": [ 13 | "Programming Languages" 14 | ], 15 | "activationEvents": [ 16 | "onCommand:janet.startREPL", 17 | "onCommand:janet.eval", 18 | "onCommand:janet.evalFile", 19 | "onCommand:janet.formatFile" 20 | ], 21 | "main": "./out/extension.js", 22 | "contributes": { 23 | "languages": [ 24 | { 25 | "id": "janet", 26 | "aliases": [ 27 | "Janet", 28 | "janet" 29 | ], 30 | "extensions": [ 31 | ".janet" 32 | ], 33 | "configuration": "./janet.configuration.json" 34 | } 35 | ], 36 | "grammars": [ 37 | { 38 | "language": "janet", 39 | "scopeName": "source.janet", 40 | "path": "./syntaxes/janet.tmLanguage" 41 | } 42 | ], 43 | "commands": [ 44 | { 45 | "command": "janet.startREPL", 46 | "title": "Janet: Start REPL" 47 | }, 48 | { 49 | "command": "janet.eval", 50 | "title": "Janet: Evaluate expression" 51 | }, 52 | { 53 | "command": "janet.evalFile", 54 | "title": "Janet: Evaluate file" 55 | }, 56 | { 57 | "command": "janet.formatFile", 58 | "title": "Janet: Format file" 59 | } 60 | ], 61 | "keybindings": [ 62 | { 63 | "command": "janet.eval", 64 | "key": "alt+e" 65 | }, 66 | { 67 | "command": "janet.evalFile", 68 | "key": "alt+l" 69 | } 70 | ] 71 | }, 72 | "scripts": { 73 | "vscode:prepublish": "npm run compile", 74 | "compile": "tsc -p ./", 75 | "lint": "eslint . --ext .ts,.tsx", 76 | "watch": "tsc -watch -p ./" 77 | }, 78 | "devDependencies": { 79 | "@types/node": "^12.12.0", 80 | "@types/vscode": "^1.34.0", 81 | "@typescript-eslint/eslint-plugin": "^4.16.0", 82 | "@typescript-eslint/parser": "^4.16.0", 83 | "eslint": "^7.21.0", 84 | "typescript": "^4.2.2" 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/extension.ts: -------------------------------------------------------------------------------- 1 | import * as fs from 'fs'; 2 | import * as os from 'os'; 3 | import * as path from 'path'; 4 | import * as vscode from 'vscode'; 5 | 6 | const windows: boolean = os.platform() == 'win32'; 7 | 8 | const janetBinary: string = windows ? 'janet.exe' : 'janet'; 9 | const terminalName = 'Janet REPL'; 10 | 11 | function janetExists(): boolean { 12 | return process.env['PATH'].split(path.delimiter) 13 | .some((x) => fs.existsSync(path.resolve(x, janetBinary))); 14 | } 15 | 16 | function newREPL(): Thenable { 17 | const terminal = vscode.window.createTerminal(terminalName); 18 | terminal.sendText(janetBinary + ' -s', true); 19 | return vscode.window.withProgress({ 20 | location: vscode.ProgressLocation.Notification, 21 | title: "Running Janet REPL...", 22 | cancellable: false 23 | }, (progress, token) => { 24 | return new Promise(resolve => { 25 | setTimeout(() => { 26 | terminal.show(); 27 | thenFocusTextEditor(); 28 | resolve(terminal); 29 | }, 2000); 30 | }); 31 | }); 32 | } 33 | 34 | function getREPL(show: boolean): Thenable { 35 | const terminal: vscode.Terminal = vscode.window.terminals.find(x => x.name === terminalName); 36 | const terminalP = (terminal) ? Promise.resolve(terminal) : newREPL(); 37 | return terminalP.then(t => { 38 | if (show) { 39 | t.show(); 40 | } 41 | return t; 42 | }); 43 | } 44 | 45 | function sendSource(terminal: vscode.Terminal, text: string) { 46 | terminal.sendText(text, true); 47 | } 48 | 49 | function thenFocusTextEditor() { 50 | setTimeout(() => vscode.commands.executeCommand('workbench.action.focusActiveEditorGroup'), 250); 51 | } 52 | 53 | export function activate(context: vscode.ExtensionContext) { 54 | 55 | console.log('Extension "vscode-janet" is now active!'); 56 | 57 | if (!janetExists()) { 58 | vscode.window.showErrorMessage('Can\'t find Janet language on your computer! Check your PATH variable.'); 59 | return; 60 | } 61 | 62 | context.subscriptions.push(vscode.commands.registerCommand( 63 | 'janet.startREPL', 64 | () => { 65 | getREPL(true); 66 | } 67 | )); 68 | 69 | context.subscriptions.push(vscode.commands.registerCommand( 70 | 'janet.eval', 71 | () => { 72 | const editor = vscode.window.activeTextEditor; 73 | if (editor == null) return; 74 | getREPL(true).then(terminal => { 75 | function send(terminal: vscode.Terminal) { 76 | sendSource(terminal, editor.document.getText(editor.selection)); 77 | thenFocusTextEditor(); 78 | } 79 | if (editor.selection.isEmpty) 80 | vscode.commands.executeCommand('editor.action.selectToBracket').then(() => send(terminal)); 81 | else 82 | send(terminal); 83 | }); 84 | } 85 | )); 86 | 87 | context.subscriptions.push(vscode.commands.registerCommand( 88 | 'janet.evalFile', 89 | () => { 90 | const editor = vscode.window.activeTextEditor; 91 | if (editor == null) return; 92 | getREPL(true).then(terminal => { 93 | sendSource(terminal, editor.document.getText()); 94 | thenFocusTextEditor(); 95 | }); 96 | } 97 | )); 98 | 99 | context.subscriptions.push(vscode.commands.registerCommand( 100 | 'janet.formatFile', 101 | () => { 102 | 103 | getREPL(true).then(terminal => { 104 | sendSource(terminal, "(import spork/fmt) (fmt/format-file \""+ 105 | vscode.window.activeTextEditor.document.uri.fsPath.replace(/\\/g, "/") 106 | +"\")"); 107 | thenFocusTextEditor(); 108 | }); 109 | } 110 | )); 111 | } 112 | -------------------------------------------------------------------------------- /syntaxes/janet.tmLanguage: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | fileTypes 6 | 7 | janet 8 | 9 | foldingStartMarker 10 | \{ 11 | foldingStopMarker 12 | \} 13 | foldingStartMarker 14 | \[ 15 | foldingStopMarker 16 | \] 17 | foldingStartMarker 18 | \( 19 | foldingStopMarker 20 | \) 21 | keyEquivalent 22 | ^~L 23 | name 24 | Janet 25 | patterns 26 | 27 | 28 | include 29 | #all 30 | 31 | 32 | repository 33 | 34 | all 35 | 36 | patterns 37 | 38 | 39 | include 40 | #comment 41 | 42 | 43 | include 44 | #parens 45 | 46 | 47 | include 48 | #brackets 49 | 50 | 51 | include 52 | #braces 53 | 54 | 55 | include 56 | #readermac 57 | 58 | 59 | include 60 | #string 61 | 62 | 63 | include 64 | #longstring 65 | 66 | 67 | include 68 | #literal 69 | 70 | 71 | include 72 | #corelib 73 | 74 | 75 | include 76 | #r-number 77 | 78 | 79 | include 80 | #dec-number 81 | 82 | 83 | include 84 | #hex-number 85 | 86 | 87 | include 88 | #keysym 89 | 90 | 91 | include 92 | #symbol 93 | 94 | 95 | 96 | comment 97 | 98 | captures 99 | 100 | 1 101 | 102 | name 103 | punctuation.definition.comment.janet 104 | 105 | 106 | match 107 | (#).*$ 108 | name 109 | comment.line.janet 110 | 111 | braces 112 | 113 | begin 114 | (@?{) 115 | captures 116 | 117 | 1 118 | 119 | name 120 | punctuation.definition.braces.begin.janet 121 | 122 | 123 | end 124 | (}) 125 | captures 126 | 127 | 1 128 | 129 | name 130 | punctuation.definition.braces.end.janet 131 | 132 | 133 | patterns 134 | 135 | 136 | include 137 | #all 138 | 139 | 140 | 141 | brackets 142 | 143 | begin 144 | (@?\[) 145 | captures 146 | 147 | 1 148 | 149 | name 150 | punctuation.definition.brackets.begin.janet 151 | 152 | 153 | end 154 | (\]) 155 | captures 156 | 157 | 1 158 | 159 | name 160 | punctuation.definition.brackets.end.janet 161 | 162 | 163 | patterns 164 | 165 | 166 | include 167 | #all 168 | 169 | 170 | 171 | parens 172 | 173 | begin 174 | (@?\() 175 | captures 176 | 177 | 1 178 | 179 | name 180 | punctuation.definition.parens.begin.janet 181 | 182 | 183 | end 184 | (\)) 185 | captures 186 | 187 | 1 188 | 189 | name 190 | punctuation.definition.parens.end.janet 191 | 192 | 193 | patterns 194 | 195 | 196 | include 197 | #all 198 | 199 | 200 | 201 | readermac 202 | 203 | match 204 | [\'\~\;\,] 205 | name 206 | punctuation.other.janet 207 | 208 | 209 | literal 210 | 211 | match 212 | (?<![\.:\w_\-=!@\$%^&?/<>*])(true|false|nil)(?![\.:\w_\-=!@\$%^&?/<>*]) 213 | name 214 | constant.language.janet 215 | 216 | corelib 217 | 218 | match 219 | (?<![\.:\w_\-=!@\$%^&?/<>*])(break|def|do|var|set|fn|while|if|quote|quasiquote|unquote|splice|%|%=|\*|\*=|\+|\+\+|\+=|\-|\-\-|\-=|\->|\->>|\-\?>|\-\?>>|/|/=|<|<=|=|>|>=|abstract\?|accumulate|accumulate2|all|all\-bindings|all\-dynamics|and|any\?|apply|array|array/concat|array/ensure|array/fill|array/insert|array/new|array/new\-filled|array/peek|array/pop|array/push|array/remove|array/slice|array/trim|array\?|as\->|as\?\->|asm|assert|bad\-compile|bad\-parse|band|blshift|bnot|boolean\?|bor|brshift|brushift|buffer|buffer/bit|buffer/bit\-clear|buffer/bit\-set|buffer/bit\-toggle|buffer/blit|buffer/clear|buffer/fill|buffer/format|buffer/new|buffer/new\-filled|buffer/popn|buffer/push|buffer/push\-byte|buffer/push\-string|buffer/push\-word|buffer/slice|buffer/trim|buffer\?|bxor|bytes\?|cancel|case|cfunction\?|chr|cli\-main|cmp|comment|comp|compare|compare<|compare<=|compare=|compare>|compare>=|compif|compile|complement|comptime|compwhen|cond|coro|count|curenv|debug|debug/arg\-stack|debug/break|debug/fbreak|debug/lineage|debug/stack|debug/stacktrace|debug/step|debug/unbreak|debug/unfbreak|debugger\-env|dec|deep\-not=|deep=|def\-|default|default\-peg\-grammar|defer|defglobal|defmacro|defmacro\-|defn|defn\-|describe|dictionary\?|disasm|distinct|doc|doc\*|doc\-format|dofile|drop|drop\-until|drop\-while|dyn|each|eachk|eachp|eachy|edefer|eflush|empty\?|env\-lookup|eprin|eprinf|eprint|eprintf|error|errorf|ev/call|ev/cancel|ev/capacity|ev/chan|ev/chunk|ev/close|ev/count|ev/deadline|ev/full|ev/give|ev/go|ev/read|ev/rselect|ev/select|ev/sleep|ev/spawn|ev/take|ev/with\-deadline|ev/write|eval|eval\-string|even\?|every\?|extreme|false\?|fiber/can\-resume\?|fiber/current|fiber/getenv|fiber/maxstack|fiber/new|fiber/root|fiber/setenv|fiber/setmaxstack|fiber/status|fiber\?|file/close|file/flush|file/open|file/popen|file/read|file/seek|file/temp|file/write|filter|find|find\-index|first|flatten|flatten\-into|flush|for|forever|forv|freeze|frequencies|function\?|gccollect|gcinterval|gcsetinterval|generate|gensym|get|get\-in|getline|hash|idempotent\?|identity|if\-let|if\-not|if\-with|import|import\*|in|inc|index\-of|indexed\?|int/s64|int/u64|int\?|interleave|interpose|invert|janet/build|janet/config\-bits|janet/version|juxt|juxt\*|keep|keys|keyword|keyword/slice|keyword\?|kvs|label|last|length|let|load\-image|load\-image\-dict|loop|macex|macex1|make\-env|make\-image|make\-image\-dict|map|mapcat|marshal|match|math/\-inf|math/abs|math/acos|math/acosh|math/asin|math/asinh|math/atan|math/atan2|math/atanh|math/cbrt|math/ceil|math/cos|math/cosh|math/e|math/erf|math/erfc|math/exp|math/exp2|math/expm1|math/floor|math/gamma|math/hypot|math/inf|math/int\-max|math/int\-min|math/int32\-max|math/int32\-min|math/log|math/log10|math/log1p|math/log2|math/nan|math/next|math/pi|math/pow|math/random|math/rng|math/rng\-buffer|math/rng\-int|math/rng\-uniform|math/round|math/seedrandom|math/sin|math/sinh|math/sqrt|math/tan|math/tanh|math/trunc|max|mean|merge|merge\-into|merge\-module|min|mod|module/add\-paths|module/cache|module/expand\-path|module/find|module/loaders|module/loading|module/paths|nan\?|nat\?|native|neg\?|net/accept|net/accept\-loop|net/address|net/chunk|net/close|net/connect|net/flush|net/listen|net/read|net/recv\-from|net/send\-to|net/server|net/write|next|nil\?|not|not=|number\?|odd\?|one\?|or|os/arch|os/cd|os/chmod|os/clock|os/cryptorand|os/cwd|os/date|os/dir|os/environ|os/execute|os/exit|os/getenv|os/link|os/lstat|os/mkdir|os/mktime|os/open|os/perm\-int|os/perm\-string|os/pipe|os/proc\-kill|os/proc\-wait|os/readlink|os/realpath|os/rename|os/rm|os/rmdir|os/setenv|os/shell|os/sleep|os/spawn|os/stat|os/symlink|os/time|os/touch|os/umask|os/which|pairs|parse|parser/byte|parser/clone|parser/consume|parser/eof|parser/error|parser/flush|parser/has\-more|parser/insert|parser/new|parser/produce|parser/state|parser/status|parser/where|partial|partition|peg/compile|peg/find|peg/find\-all|peg/match|peg/replace|peg/replace\-all|pos\?|postwalk|pp|prewalk|prin|prinf|print|printf|product|prompt|propagate|protect|put|put\-in|quit|range|reduce|reduce2|repeat|repl|require|resume|return|reverse|reverse!|root\-env|run\-context|scan\-number|seq|setdyn|short\-fn|signal|slice|slurp|some|sort|sort\-by|sorted|sorted\-by|spit|stderr|stdin|stdout|string|string/ascii\-lower|string/ascii\-upper|string/bytes|string/check\-set|string/find|string/find\-all|string/format|string/from\-bytes|string/has\-prefix\?|string/has\-suffix\?|string/join|string/repeat|string/replace|string/replace\-all|string/reverse|string/slice|string/split|string/trim|string/triml|string/trimr|string\?|struct|struct\?|sum|symbol|symbol/slice|symbol\?|table|table/clone|table/getproto|table/new|table/rawget|table/setproto|table/to\-struct|table\?|take|take\-until|take\-while|tarray/buffer|tarray/copy\-bytes|tarray/length|tarray/new|tarray/properties|tarray/slice|tarray/swap\-bytes|thread/close|thread/current|thread/exit|thread/new|thread/receive|thread/send|trace|tracev|true\?|truthy\?|try|tuple|tuple/brackets|tuple/setmap|tuple/slice|tuple/sourcemap|tuple/type|tuple\?|type|unless|unmarshal|untrace|update|update\-in|use|values|var\-|varfn|varglobal|walk|when|when\-let|when\-with|with|with\-dyns|with\-syms|with\-vars|xprin|xprinf|xprint|xprintf|yield|zero\?|zipcoll)(?![\.:\w_\-=!@\$%^&?/<>*]) 220 | name 221 | keyword.control.janet 222 | 223 | keysym 224 | 225 | match 226 | (?<![\.:\w_\-=!@\$%^&?/<>*]):[\.:\w_\-=!@\$%^&?/<>*]* 227 | name 228 | constant.keyword.janet 229 | 230 | symbol 231 | 232 | match 233 | (?<![\.:\w_\-=!@\$%^&?/<>*])[\.a-zA-Z_\-=!@\$%^&?/<>*][\.:\w_\-=!@\$%^&?/<>*]* 234 | name 235 | variable.other.janet 236 | 237 | hex-number 238 | 239 | match 240 | (?<![\.:\w_\-=!@\$%^&?/<>*])[-+]?0x([_\da-fA-F]+|[_\da-fA-F]+\.[_\da-fA-F]*|\.[_\da-fA-F]+)(&[+-]?[\da-fA-F]+)?(?![\.:\w_\-=!@\$%^&?/<>*]) 241 | name 242 | constant.numeric.hex.janet 243 | 244 | dec-number 245 | 246 | match 247 | (?<![\.:\w_\-=!@\$%^&?/<>*])[-+]?([_\d]+|[_\d]+\.[_\d]*|\.[_\d]+)([eE&][+-]?[\d]+)?(?![\.:\w_\-=!@\$%^&?/<>*]) 248 | name 249 | constant.numeric.decimal.janet 250 | 251 | r-number 252 | 253 | match 254 | (?<![\.:\w_\-=!@\$%^&?/<>*])[-+]?\d\d?r([_\w]+|[_\w]+\.[_\w]*|\.[_\w]+)(&[+-]?[\w]+)?(?![\.:\w_\-=!@\$%^&?/<>*]) 255 | name 256 | constant.numeric.decimal.janet 257 | 258 | string 259 | 260 | begin 261 | (@?") 262 | beginCaptures 263 | 264 | 1 265 | 266 | name 267 | punctuation.definition.string.begin.janet 268 | 269 | 270 | end 271 | (") 272 | endCaptures 273 | 274 | 1 275 | 276 | name 277 | punctuation.definition.string.end.janet 278 | 279 | 280 | name 281 | string.quoted.double.janet 282 | patterns 283 | 284 | 285 | match 286 | (\\[nevr0zft"\\']|\\x[0-9a-fA-F]{2}|\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{6}) 287 | name 288 | constant.character.escape.janet 289 | 290 | 291 | 292 | longstring 293 | 294 | begin 295 | (@?)(`+) 296 | beginCaptures 297 | 298 | 1 299 | 300 | name 301 | punctuation.definition.string.begin.janet 302 | 303 | 2 304 | 305 | name 306 | punctuation.definition.string.begin.janet 307 | 308 | 309 | end 310 | \2 311 | endCaptures 312 | 313 | 1 314 | 315 | name 316 | punctuation.definition.string.end.janet 317 | 318 | 319 | name 320 | string.quoted.triple.janet 321 | 322 | nomatch 323 | 324 | match 325 | \S+ 326 | name 327 | invalid.illegal.janet 328 | 329 | 330 | scopeName 331 | source.janet 332 | uuid 333 | 3743190f-20c4-44d0-8640-6611a983296b 334 | 335 | 336 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es2019", 5 | "outDir": "out", 6 | "lib": ["ES2019"], 7 | "sourceMap": true, 8 | "rootDir": "src" 9 | }, 10 | "exclude": ["node_modules", ".vscode-test"] 11 | } 12 | --------------------------------------------------------------------------------