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/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..f136a00 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,26 @@ +name: build/release vsix package + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + - name: Install dependencies + run: | + npm install -g @vscode/vsce + - name: Build package + run: vsce package + - name: Release + if: startsWith(github.ref, 'refs/tags') + run: | + awk -v ver=${{ github.ref_name }} '/^## Version / { if (p) { exit }; if ($3 == ver) { p=1; next } } p && NF' CHANGELOG.md > RELEASE_NOTES + gh release create ${{ github.ref_name }} -F RELEASE_NOTES *.vsix + env: + GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" 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..ab4ccef --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Change Log + +## Version 0.0.1 - 2024-08-22 + +- Initial release diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..8fb3f53 --- /dev/null +++ b/LICENCE @@ -0,0 +1,8 @@ +The MIT License (MIT) +Copyright (c) 2024 Xiaoqiang Wang + +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..7dd124e --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# vscode-ecmcPLC + +Syntax highlighting for ecmc PLC files. diff --git a/language-configuration.json b/language-configuration.json new file mode 100644 index 0000000..9964d9e --- /dev/null +++ b/language-configuration.json @@ -0,0 +1,35 @@ +{ + "comments": { + // symbol used for single line comment. + "lineComment": "#" + }, + // symbols used as brackets + "brackets": [ + ["{", "}"], + ["(", ")"] + ], + // symbols that are auto closed when typing + "autoClosingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["'", "'"] + ], + // symbols that can be used to surround a selection + "surroundingPairs": [ + ["{", "}"], + ["(", ")"], + ["'", "'"] + ], + "onEnterRules": [ + { + // Decrease indentation after single line if/else if/else, for, or while + "previousLineText": "^\\s*(((else ?)?if|for|while)\\s*\\(.*\\)\\s*|else\\s*)$", + // But make sure line doesn't have braces or is not another if statement + "beforeText": "^\\s+([^{i\\s]|i(?!f\\b))", + "action": { + "indent": "outdent" + } + } + ] +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..81ce3c8 --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "name": "vscode-ecmcPLC", + "displayName": "vscode-ecmcPLC", + "description": "ECMC PLC syntax highlight", + "version": "0.0.1", + "engines": { + "vscode": "*" + }, + "categories": [ + "Programming Languages" + ], + "publisher": "PSI", + "repository": { + "url": "https://github.com/paulscherrerinstitue/vscode-ecmcPLC" + }, + "contributes": { + "languages": [{ + "id": "ecmcPLC", + "aliases": ["ecmcPLC"], + "extensions": [".plc"], + "configuration": "./language-configuration.json" + }], + "grammars": [{ + "language": "ecmcPLC", + "scopeName": "source.ecmcPLC", + "path": "./syntaxes/ecmcPLC.tmLanguage.json" + }] + } +} diff --git a/syntaxes/ecmcPLC.tmLanguage.json b/syntaxes/ecmcPLC.tmLanguage.json new file mode 100644 index 0000000..f27c3d6 --- /dev/null +++ b/syntaxes/ecmcPLC.tmLanguage.json @@ -0,0 +1,213 @@ +{ + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "name": "ecmcPLC", + "scopeName": "source.ecmcPLC", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#keywords" + }, + { + "include": "#operators" + }, + { + "include": "#functions" + }, + { + "include": "#numbers" + }, + { + "include": "#variables" + }, + { + "include": "#strings" + }, + { + "include": "#macros" + }, + { + "include": "#blocks" + } + ], + "repository": { + "keywords": { + "patterns": [ + { + "name": "keyword.operator.logical.ecmcPLC", + "match": "\\b(and|mand|mor|nand|nor|not|or|shl|shr|xnor|xor|true|false)\\b" + }, + { + "name": "keyword.control", + "match": "\\b(for|while|if|else|return|switch|case|repeat|until|break|continue)\\b" + }, + { + "name": "storage.type.ecmcPLC", + "match": "\\b(var)\\b" + } + ] + }, + "operators": { + "patterns": [ + { + "match": "\\+=|-=|\\*=|(?|!=|<=|>=|==|<|>", + "name": "keyword.operator.comparison.ecmcPLC" + }, + { + "match": "%=|\\+=|-=|\\*=|(?