From: Ben Beltran Date: Tue, 5 Feb 2019 21:01:25 +0000 (+0100) Subject: Import from api-notation.tmLanguage X-Git-Tag: v0.1.0~2 X-Git-Url: https://git.r.bdr.sh/rbdr/api-notation.vscode/commitdiff_plain/e6c2e653ab8ad7d115d29a407c99aaecb179adb1?ds=sidebyside Import from api-notation.tmLanguage --- diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..7bc18a4 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,18 @@ +// 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", + "runtimeExecutable": "${execPath}", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}" + ] + } + ] +} \ No newline at end of file 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..2f5deae --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Change Log +All notable changes to the "api-notation" extension will be documented in this file. + +Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. + +## [Unreleased] +- Import from https://gitlab.com/rbdr/api-notation.tmLanguage diff --git a/README.md b/README.md index 99d0857..2d5e725 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,53 @@ -# API Notation for VSCode +# API Notation Syntax for Atom -Syntax Highlight Plugin for VSCode \ No newline at end of file +This is a grammar for api notation, a simple notation I've been using for +annotating module APIs in specs and other documents. + +## Installing + +### From Command Line + +TBD + +## Usage + +Open a `.api` file, or set it as your syntax. + +## API Notation Reference + +The most recent reference as of now is in this [gist][api-reference], so +check that to be sure. But here's a reproduction of the notation. + +``` +NameOfClass.WithPossibleNamespace + + class property + - instance property + ~> listened events (socket) + +> listened events (class/module) + -> listened events (instance) + <~ dispatched events (socket) + <+ dispatched events(class/module) + <- dispatched events (instance) + :: class method + # instance method + +Other symbols + => returns +->() callback return +[xx] optional + data type + +Recommended order: class first, then sockets, then instance. Internally: +Properties, events, methods. + +// Anything after two forward slashes is a comment +``` + +## How does it look like? + +Like this. + +![Like this.][api-example] + +[api-reference]: https://gist.github.com/rbdr/4694c46fcec131468e34 +[api-example]: https://i.imgur.com/63TyFMe.png diff --git a/example-syntax.api b/example-syntax.api new file mode 100644 index 0000000..8c52870 --- /dev/null +++ b/example-syntax.api @@ -0,0 +1,19 @@ +HypotheticalModule + +staticProperty + +anotherStaticProperty + ::toggleAnotherStaticProperty() + ::setStaticProperty(newValue ) + -instanceProperty + -anotherInstanceProperty + #instanceMethodSync([optionalParameter]) => resultOfCall + #instanceMethodAsync(someValue , [callback] ) ->(error , result ) + + +// Comment +EventHypotheticalClass + +>AnotherClass<+staticEventToListen(eventData ) // More Comments + <+staticEventDispatched(someData ) + ~>listenedSocketEvent(eventData ) + <~dispatchedSocketEvent(eventData ) + ->AnotherClass<-instanceEventToListen(eventData ) + <-instanceEventDispatched(specificDataType ) diff --git a/language-configuration.json b/language-configuration.json new file mode 100644 index 0000000..aa25710 --- /dev/null +++ b/language-configuration.json @@ -0,0 +1,30 @@ +{ + "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 that can be used to surround a selection + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""], + ["'", "'"] + ] +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..1f0bc38 --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "api-notation", + "displayName": "API Notation", + "description": "Syntax Highlighting for API notation", + "version": "0.0.1", + "engines": { + "vscode": "^1.30.0" + }, + "categories": [ + "Programming Languages" + ], + "contributes": { + "languages": [{ + "id": "api-notation", + "aliases": ["API Notation", "api-notation"], + "extensions": [".api"], + "configuration": "./language-configuration.json" + }], + "grammars": [{ + "language": "api-notation", + "scopeName": "source.api-notation", + "path": "./syntaxes/api-notation.tmLanguage" + }] + } +} \ No newline at end of file diff --git a/syntaxes/api-notation.tmLanguage b/syntaxes/api-notation.tmLanguage new file mode 100644 index 0000000..e546929 --- /dev/null +++ b/syntaxes/api-notation.tmLanguage @@ -0,0 +1,217 @@ + + + + + fileTypes + + api + + name + API Notation + patterns + + + begin + ([a-zA-Z0-9_.]+) + end + \n + name + constant.language + patterns + + + include + #dataTypes + + + include + #comment + + + + + begin + ^//.* + end + \n + name + comment.line + + + begin + [ \t]+ + end + \n + patterns + + + include + #apiMember + + + include + #parameterList + + + include + #dataTypes + + + include + #operators + + + include + #parameters + + + include + #comment + + + + + begin + ^. + end + \n + patterns + + + include + #comment + + + + + repository + + apiMember + + captures + + 1 + + name + keyword.control + + 2 + + name + variable.language + + + match + ((?:<\+)|(?:<\~)|(?:<\-)|(?:\+>)|(?:\~>)|(?:\->)|\-|\+|(?:::)|#)([a-zA-z0-9_]+) + + comment + + match + [ \t]*//[ \t]*.* + name + comment.line + + dataType + + match + [a-zA-Z0-9_.]+ + name + support.function + + dataTypes + + begin + \< + end + \> + name + keyword.operator + patterns + + + include + #dataType + + + include + #separators + + + + operators + + match + (?:\->)|(?:\=>) + name + keyword.control + + optionalParameter + + match + [a-zA-Z0-9_.]+ + name + comment.line + + optionalParameters + + begin + \[ + end + \] + patterns + + + include + #optionalParameter + + + + parameterList + + begin + \( + end + \) + name + keyword.operator + patterns + + + include + #parameters + + + include + #optionalParameters + + + include + #dataTypes + + + include + #separators + + + + parameters + + match + [a-zA-Z0-9_.]+ + name + string.other + + separators + + match + \||, + name + comment.line + + + scopeName + source.api-notation + uuid + fc8dc5cf-b7aa-4b64-a665-80e8dc1b2553 + + diff --git a/vsc-extension-quickstart.md b/vsc-extension-quickstart.md new file mode 100644 index 0000000..06a7355 --- /dev/null +++ b/vsc-extension-quickstart.md @@ -0,0 +1,29 @@ +# Welcome to your VS Code Extension + +## What's in the folder + +* This folder contains all of the files necessary for your extension. +* `package.json` - this is the manifest file in which you declare your language support and define the location of the grammar file that has been copied into your extension. +* `syntaxes/api-notation.tmLanguage` - this is the Text mate grammar file that is used for tokenization. +* `language-configuration.json` - this is the language configuration, defining the tokens that are used for comments and brackets. + +## Get up and running straight away + +* Make sure the language configuration settings in `language-configuration.json` are accurate. +* Press `F5` to open a new window with your extension loaded. +* Create a new file with a file name suffix matching your language. +* Verify that syntax highlighting works and that the language configuration settings are working. + +## Make changes + +* You can relaunch the extension from the debug toolbar after making changes to the files listed above. +* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. + +## Add more language features + +* To add features such as intellisense, hovers and validators check out the VS Code extenders documentation at https://code.visualstudio.com/docs + +## Install your extension + +* To start using your extension with Visual Studio Code copy it into the `/.vscode/extensions` folder and restart Code. +* To share your extension with the world, read on https://code.visualstudio.com/docs about publishing an extension.