first try at squiggle syntax highlighting
This commit is contained in:
parent
a2a6ff8ad0
commit
7441027e0f
1
packages/vscode-ext/.gitignore
vendored
1
packages/vscode-ext/.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
/media/vendor
|
/media/vendor
|
||||||
/out
|
/out
|
||||||
/*.vsix
|
/*.vsix
|
||||||
|
/syntaxes/*.json
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"displayName": "Squiggle",
|
"displayName": "Squiggle",
|
||||||
"description": "Squiggle language support",
|
"description": "Squiggle language support",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "0.0.4",
|
"version": "0.1.0",
|
||||||
"publisher": "QURI",
|
"publisher": "QURI",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -34,6 +34,13 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"grammars": [
|
||||||
|
{
|
||||||
|
"language": "squiggle",
|
||||||
|
"scopeName": "source.squiggle",
|
||||||
|
"path": "./syntaxes/squiggle.tmLanguage.json"
|
||||||
|
}
|
||||||
|
],
|
||||||
"customEditors": [
|
"customEditors": [
|
||||||
{
|
{
|
||||||
"viewType": "squiggle.wysiwyg",
|
"viewType": "squiggle.wysiwyg",
|
||||||
|
@ -102,21 +109,23 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"vscode:prepublish": "yarn run compile",
|
"vscode:prepublish": "yarn run compile",
|
||||||
"compile:tsc": "tsc -p ./",
|
"compile:tsc": "tsc -p ./",
|
||||||
|
"compile:grammar": "js-yaml syntaxes/squiggle.tmLanguage.yaml >syntaxes/squiggle.tmLanguage.json",
|
||||||
"compile:vendor": "(cd ../squiggle-lang && yarn run build) && (cd ../components && yarn run bundle && yarn run build:css) && mkdir -p media/vendor && cp ../components/dist/bundle.js media/vendor/components.js && cp ../components/dist/main.css media/vendor/components.css && cp ../../node_modules/react/umd/react.production.min.js media/vendor/react.js && cp ../../node_modules/react-dom/umd/react-dom.production.min.js media/vendor/react-dom.js && cp ../website/static/img/quri-logo.png media/vendor/icon.png",
|
"compile:vendor": "(cd ../squiggle-lang && yarn run build) && (cd ../components && yarn run bundle && yarn run build:css) && mkdir -p media/vendor && cp ../components/dist/bundle.js media/vendor/components.js && cp ../components/dist/main.css media/vendor/components.css && cp ../../node_modules/react/umd/react.production.min.js media/vendor/react.js && cp ../../node_modules/react-dom/umd/react-dom.production.min.js media/vendor/react-dom.js && cp ../website/static/img/quri-logo.png media/vendor/icon.png",
|
||||||
"compile": "yarn run compile:tsc && yarn run compile:vendor",
|
"compile": "yarn run compile:tsc && yarn run compile:grammar && yarn run compile:vendor",
|
||||||
"watch": "tsc -watch -p ./",
|
"watch": "tsc -watch -p ./",
|
||||||
"pretest": "yarn run compile && yarn run lint",
|
"pretest": "yarn run compile && yarn run lint",
|
||||||
"lint": "eslint src --ext ts",
|
"lint": "eslint src --ext ts",
|
||||||
"format": "eslint src --ext ts --fix"
|
"format": "eslint src --ext ts --fix"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/vscode": "^1.68.0",
|
|
||||||
"@types/glob": "^7.2.0",
|
"@types/glob": "^7.2.0",
|
||||||
"@types/node": "18.x",
|
"@types/node": "18.x",
|
||||||
|
"@types/vscode": "^1.68.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
||||||
"@typescript-eslint/parser": "^5.27.0",
|
"@typescript-eslint/parser": "^5.27.0",
|
||||||
"eslint": "^8.18.0",
|
"eslint": "^8.18.0",
|
||||||
"glob": "^8.0.3",
|
"glob": "^8.0.3",
|
||||||
"typescript": "^4.7.4"
|
"typescript": "^4.7.4",
|
||||||
|
"js-yaml": "^4.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
89
packages/vscode-ext/syntaxes/squiggle.tmLanguage.yaml
Normal file
89
packages/vscode-ext/syntaxes/squiggle.tmLanguage.yaml
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
scopeName: source.squiggle
|
||||||
|
patterns:
|
||||||
|
- include: "#statement"
|
||||||
|
- include: "#expression"
|
||||||
|
- include: "#comment-block"
|
||||||
|
- include: "#comment-line"
|
||||||
|
repository:
|
||||||
|
statement:
|
||||||
|
patterns:
|
||||||
|
- include: "#let"
|
||||||
|
- include: "#defun"
|
||||||
|
expression:
|
||||||
|
patterns:
|
||||||
|
- include: "#integer"
|
||||||
|
- include: "#float"
|
||||||
|
- include: "#string"
|
||||||
|
- include: "#block"
|
||||||
|
- include: "#function-call"
|
||||||
|
let:
|
||||||
|
match: ^\s*(\w+)\s*=
|
||||||
|
captures:
|
||||||
|
"1":
|
||||||
|
name: variable.other.squiggle
|
||||||
|
defun:
|
||||||
|
begin: ^\s*(\w+)\s*(\()
|
||||||
|
end: (\))\s*=
|
||||||
|
beginCaptures:
|
||||||
|
"1":
|
||||||
|
name: entity.name.function.squiggle
|
||||||
|
"2":
|
||||||
|
name: punctuation.definition.arguments.begin.squiggle
|
||||||
|
endCaptures:
|
||||||
|
"1":
|
||||||
|
name: punctuation.definition.arguments.end.squiggle
|
||||||
|
patterns:
|
||||||
|
- include: "#array-parameters"
|
||||||
|
array-parameters:
|
||||||
|
begin: \b([\$_a-z]+[\$_a-zA-Z0-9]*)
|
||||||
|
end: \s*(?:(,)|(?=\)))
|
||||||
|
beginCaptures:
|
||||||
|
"1":
|
||||||
|
name: variable.parameter.function.squiggle
|
||||||
|
function-call:
|
||||||
|
begin: (\w+)\s*(\()
|
||||||
|
end: (\))
|
||||||
|
beginCaptures:
|
||||||
|
"1":
|
||||||
|
name: entity.name.function.squiggle
|
||||||
|
"2":
|
||||||
|
name: punctuation.definition.arguments.begin.squiggle
|
||||||
|
endCaptures:
|
||||||
|
"1":
|
||||||
|
name: punctuation.definition.arguments.end.squiggle
|
||||||
|
patterns:
|
||||||
|
- include: "$self"
|
||||||
|
comment-block:
|
||||||
|
begin: /\*
|
||||||
|
end: \*/
|
||||||
|
name: comment.block.squiggle
|
||||||
|
comment-line:
|
||||||
|
patterns:
|
||||||
|
- include: "#comment-line-double-slash"
|
||||||
|
- include: "#comment-line-number-sign"
|
||||||
|
comment-line-double-slash:
|
||||||
|
match: //.*
|
||||||
|
name: comment.line.double-slash.squiggle
|
||||||
|
comment-line-number-sign:
|
||||||
|
match: "#.*"
|
||||||
|
name: comment.line.number-sign.squiggle
|
||||||
|
block:
|
||||||
|
begin: "{"
|
||||||
|
end: "}"
|
||||||
|
beginCaptures:
|
||||||
|
"0":
|
||||||
|
name: punctuation.definition.block.squiggle
|
||||||
|
endCaptures:
|
||||||
|
"0":
|
||||||
|
name: punctuation.definition.block.squiggle
|
||||||
|
patterns:
|
||||||
|
- include: "$self"
|
||||||
|
integer:
|
||||||
|
match: \b\d+([_a-zA-Z]+[_a-zA-Z0-9]*)?
|
||||||
|
name: constant.numeric.integer.squiggle
|
||||||
|
float:
|
||||||
|
match: \b(\d+\.\d*|\.?\d+)([eE]-?\d+)?([_a-zA-Z]+[_a-zA-Z0-9]*)?
|
||||||
|
name: constant.numeric.float.squiggle
|
||||||
|
string:
|
||||||
|
match: \".*?\"
|
||||||
|
name: string.quoted.double.squiggle
|
|
@ -4353,6 +4353,15 @@
|
||||||
"@types/scheduler" "*"
|
"@types/scheduler" "*"
|
||||||
csstype "^3.0.2"
|
csstype "^3.0.2"
|
||||||
|
|
||||||
|
"@types/react@^18.0.9":
|
||||||
|
version "18.0.14"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.14.tgz#e016616ffff51dba01b04945610fe3671fdbe06d"
|
||||||
|
integrity sha512-x4gGuASSiWmo0xjDLpm5mPb52syZHJx02VKbqUKdLmKtAwIh63XClGsiTI1K6DO5q7ox4xAsQrU+Gl3+gGXF9Q==
|
||||||
|
dependencies:
|
||||||
|
"@types/prop-types" "*"
|
||||||
|
"@types/scheduler" "*"
|
||||||
|
csstype "^3.0.2"
|
||||||
|
|
||||||
"@types/resolve@1.17.1":
|
"@types/resolve@1.17.1":
|
||||||
version "1.17.1"
|
version "1.17.1"
|
||||||
resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6"
|
resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-1.17.1.tgz#3afd6ad8967c77e4376c598a82ddd58f46ec45d6"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user