From 2a0b47fa48087a615f1706a239ef1e1724860136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Reuh=20Fildadut?= Date: Sun, 22 Dec 2024 16:14:47 +0100 Subject: [PATCH] Initial commit --- .gitattributes | 2 + .gitignore | 2 + .vscode/launch.json | 17 + .vscodeignore | 4 + CHANGELOG.md | 9 + LICENSE.md | 21 + README.md | 13 + language-configuration.json | 34 ++ package-lock.json | 15 + package.json | 35 ++ syntaxes/candran.tmLanguage.json | 998 +++++++++++++++++++++++++++++++ 11 files changed, 1150 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .vscode/launch.json create mode 100644 .vscodeignore create mode 100644 CHANGELOG.md create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 language-configuration.json create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 syntaxes/candran.tmLanguage.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..70e63ff --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Set default behavior to automatically normalize line endings. +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..67dfeb3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +*.vsix \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..44a86ab --- /dev/null +++ b/.vscode/launch.json @@ -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}" + ] + } + ] +} diff --git a/.vscodeignore b/.vscodeignore new file mode 100644 index 0000000..f369b5e --- /dev/null +++ b/.vscodeignore @@ -0,0 +1,4 @@ +.vscode/** +.vscode-test/** +.gitignore +vsc-extension-quickstart.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e48337c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Change Log + +All notable changes to the "candran" extension will be documented in this file. + +Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. + +## [Unreleased] + +- Initial release \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..89118ae --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 最萌小汐 + +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: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..35bac89 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# candran README + +Basic support for the Candran language for Visual Studio Code. + +Based on VS Code's built-in (Lua grammar)[https://github.com/LuaLS/lua.tmbundle]. + +## Installation + +Clone this repository into your VS Code extension directory: + +* Windows: `%USERPROFILE%\.vscode\extensions` +* macOS: `~/.vscode/extensions` +* Linux: `~/.vscode/extensions` diff --git a/language-configuration.json b/language-configuration.json new file mode 100644 index 0000000..673f83f --- /dev/null +++ b/language-configuration.json @@ -0,0 +1,34 @@ +{ + "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": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + { "open": "\"", "close": "\"", "notIn": ["string"] }, + { "open": "'", "close": "'", "notIn": ["string"] } + ], + // symbols that can be used to surround a selection + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"] + ], + "indentationRules": { + "increaseIndentPattern": "((^\\s*\\b(((local|let)?[\\s\\w=]+)?function|repeat|else|elseif|if|while)\\b|^.*\\b(do|then)\\b|^.*([\\(\\,\\=\\[\\{\\+\\-\\*\\/\\^\\%\\&\\|\\:]|and|or|\\/\\/|\\.\\.|\\>\\>|\\<\\<)\\s*(\\(\\)|\\([A-Za-z_][A-Za-z0-9_]*[=,\\)]))((?!\\bend\\b).)*$|^.*\\{((?!\\}).)*$)", + "decreaseIndentPattern": "(^\\s*\\b(elsei|elseif|else|end|until)\\b.*$|^((?!\\{).)*\\}\\;?.*$)" + } +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..4497276 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,15 @@ +{ + "name": "candran", + "version": "0.0.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "candran", + "version": "0.0.1", + "engines": { + "vscode": "^1.96.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..1e4a01d --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "candran", + "displayName": "candran", + "description": "Add language support for Candran", + "version": "0.0.1", + "engines": { + "vscode": "^1.96.0" + }, + "categories": [ + "Programming Languages" + ], + "contributes": { + "languages": [ + { + "id": "candran", + "aliases": [ + "Candran", + "candran" + ], + "extensions": [ + "can", + "candran" + ], + "configuration": "./language-configuration.json" + } + ], + "grammars": [ + { + "language": "candran", + "scopeName": "source.candran", + "path": "./syntaxes/candran.tmLanguage.json" + } + ] + } +} diff --git a/syntaxes/candran.tmLanguage.json b/syntaxes/candran.tmLanguage.json new file mode 100644 index 0000000..10c8ebf --- /dev/null +++ b/syntaxes/candran.tmLanguage.json @@ -0,0 +1,998 @@ +{ + "name": "Candran", + "scopeName": "source.candran", + "patterns": [ + { + "begin": "\\b(?:(local)\\s+)?(function)\\b(?![,:])", + "beginCaptures": { + "1": { + "name": "keyword.local.candran" + }, + "2": { + "name": "keyword.control.candran" + } + }, + "end": "(?<=[\\)\\-{}\\[\\]\"'])", + "name": "meta.function.candran", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#function-parameters" + }, + { + "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b\\s*(?=:)", + "name": "entity.name.class.candran" + }, + { + "match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b", + "name": "entity.name.function.candran" + } + ] + }, + { + "begin": ":(?=\\()", + "beginCaptures": { + "0": { + "name": "keyword.control.candran" + } + }, + "end": "(?<=[\\)\\-{}\\[\\]\"'])", + "name": "meta.function.candran", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#function-parameters" + } + ] + }, + { + "match": "(?", + "captures": { + "0": { + "name": "storage.type.attribute.candran" + } + } + }, + { + "match": "\\<[a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*\\>", + "name": "storage.type.generic.candran" + }, + { + "match": "\\b(break|do|else|for|if|elseif|goto|return|then|repeat|while|until|end|in|continue|push)\\b", + "name": "keyword.control.candran" + }, + { + "match": "\\b(local|let)\\b", + "name": "keyword.local.candran" + }, + { + "match": "\\b(const)\\b", + "name": "keyword.const.candran" + }, + { + "match": "\\b(close)\\b", + "name": "keyword.close.candran" + }, + { + "match": "\\b(function)\\b(?![,:])", + "name": "keyword.control.candran" + }, + { + "match": "(?>|<<|==?|~=|!=|<=?|>=?|(?|\\<", + "name": "keyword.operator.candran" + } + ] + }, + { + "begin": "(?<=---)[ \\t]*@see", + "beginCaptures": { + "0": { + "name": "storage.type.annotation.candran" + } + }, + "end": "(?=[\\n@#])", + "patterns": [ + { + "match": "\\b([a-zA-Z_\\*][a-zA-Z0-9_\\.\\*\\-]*)", + "name": "support.class.candran" + }, + { + "match": "#", + "name": "keyword.operator.candran" + } + ] + }, + { + "begin": "(?<=---)[ \\t]*@diagnostic", + "beginCaptures": { + "0": { + "name": "storage.type.annotation.candran" + } + }, + "end": "(?=[\\n@#])", + "patterns": [ + { + "begin": "([a-zA-Z_\\-0-9]+)[ \\t]*(:)?", + "beginCaptures": { + "1": { + "name": "keyword.other.unit" + }, + "2": { + "name": "keyword.operator.unit" + } + }, + "end": "(?=\\n)", + "patterns": [ + { + "match": "\\b([a-zA-Z_\\*][a-zA-Z0-9_\\-]*)", + "name": "support.class.candran" + }, + { + "match": ",", + "name": "keyword.operator.candran" + } + ] + } + ] + }, + { + "begin": "(?<=---)[ \\t]*@module", + "beginCaptures": { + "0": { + "name": "storage.type.annotation.candran" + } + }, + "end": "(?=[\\n@#])", + "patterns": [ + { + "include": "#string" + } + ] + }, + { + "match": "(?<=---)[ \\t]*@(async|nodiscard)", + "name": "storage.type.annotation.candran" + }, + { + "begin": "(?<=---)\\|\\s*[\\>\\+]?", + "beginCaptures": { + "0": { + "name": "storage.type.annotation.candran" + } + }, + "end": "(?=[\\n@#])", + "patterns": [ + { + "include": "#string" + } + ] + } + ] + }, + "emmydoc.type": { + "patterns": [ + { + "begin": "\\bfun\\b", + "beginCaptures": { + "0": { + "name": "keyword.control.candran" + } + }, + "end": "(?=[\\s#])", + "patterns": [ + { + "match": "[\\(\\),:\\?][ \\t]*", + "name": "keyword.operator.candran" + }, + { + "match": "([a-zA-Z_][a-zA-Z0-9_\\.\\*\\[\\]\\<\\>\\,\\-]*)(?", + "name": "storage.type.generic.candran" + }, + { + "match": "\\basync\\b", + "name": "entity.name.tag.candran" + }, + { + "match": "[\\{\\}\\:\\,\\?\\|\\`][ \\t]*", + "name": "keyword.operator.candran" + }, + { + "begin": "(?=[a-zA-Z_\\.\\*\"'\\[])", + "end": "(?=[\\s\\)\\,\\?\\:\\}\\|#])", + "patterns": [ + { + "match": "([a-zA-Z0-9_\\.\\*\\[\\]\\<\\>\\,\\-]+)(?