Added vscode syntax highlighting under /tools

This commit is contained in:
2022-11-07 09:44:26 +00:00
parent a55338d8e3
commit 0c8e036de8
8 changed files with 171 additions and 2 deletions

View File

@@ -0,0 +1,17 @@
// A launch configuration that launches the extension inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
]
}
]
}

View File

@@ -0,0 +1,4 @@
.vscode/**
.vscode-test/**
.gitignore
vsc-extension-quickstart.md

View File

@@ -0,0 +1,2 @@
# Change Log

View File

@@ -0,0 +1,8 @@
# Toy vscode Highlighting
This is included in the core repo under `/tools`, and is supposed to make your time writing Toy code easier.
## Installing
Just copy the whole folder into the extensions folder for VSCode.

View File

@@ -0,0 +1,28 @@
{
"comments": {
// symbol used for single line comment. Remove this entry if your language does not support line comments
"lineComment": "//",
// symbols used for start and end a block comment. Remove this entry if your language does not support block comments
"blockComment": [ "/*", "*/" ]
},
// symbols used as brackets
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
// symbols that are auto closed when typing
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
],
// symbols that can be used to surround a selection
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
]
}

View File

@@ -0,0 +1,25 @@
{
"name": "toy-syntax-highlighting",
"displayName": "Toy Syntax Highlighting",
"description": "A toy programming language",
"version": "0.0.1",
"engines": {
"vscode": "^1.73.0"
},
"categories": [
"Programming Languages"
],
"contributes": {
"languages": [{
"id": "toy",
"aliases": ["Toy", "toy"],
"extensions": [".toy"],
"configuration": "./language-configuration.json"
}],
"grammars": [{
"language": "toy",
"scopeName": "source.toy",
"path": "./syntaxes/toy.tmLanguage.json"
}]
}
}

View File

@@ -0,0 +1,85 @@
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "Toy",
"patterns": [
{
"include": "#comments"
},
{
"include": "#keywords"
},
{
"include": "#strings"
},
{
"include": "#numbers"
},
{
"include": "#booleans"
},
{
"include": "#null"
},
{
"include": "#reserved"
}
],
"repository": {
"comments": {
"patterns": [{
"name": "comment.line.toy",
"begin": "\/\/",
"end": "\\n"
},
{
"name": "comment.block.toy",
"begin": "/\\*",
"end": "\\*/"
}]
},
"keywords": {
"patterns": [{
"name": "keyword.control.toy",
"match": "\\b(if|else|while|for|return|break|continue)\\b"
},
{
"name": "keyword.type.toy",
"match": "\\b(any|bool|const|float|int|string|type)\\b"
},
{
"name": "keyword.other.toy",
"match": "\\b(as|astype|assert|export|fn|import|print|typeof|var)\\b"
}]
},
"strings": {
"name": "string.quoted.double.toy",
"begin": "\"",
"end": "\""
},
"numbers": {
"patterns": [{
"match": "[-]?[0-9]+(.[0-9]+)?",
"name": "constant.numeric.toy"
}]
},
"booleans": {
"patterns": [{
"match": "\\b(true|false)\\b",
"name": "constant.numeric.toy"
}]
},
"null": {
"patterns": [{
"match": "\\b(null)\\b",
"name": "constant.numeric.toy"
}]
},
"reserved": {
"patterns": [{
"name": "keyword.reserved.toy",
"match": "\\b(class|do|foreach|in|of)\\b"
}]
}
},
"scopeName": "source.toy"
}