diff options
| author | Ben Beltran <ben@nsovocal.com> | 2019-02-05 22:35:04 +0100 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2019-02-05 22:35:04 +0100 |
| commit | 55ab0586626b0a833e7b3801164699e4b3a640c2 (patch) | |
| tree | 7ebd3f76327b8d9f5e4840592ce3f37e9fe63827 | |
| parent | 4549164147a331c583651f87d3d0490eb0a0397f (diff) | |
| parent | b1cf6d7ccd532b35c845ba93170996f700ce59a7 (diff) | |
Merge branch 'release/1.0.0'1.0.0
| -rw-r--r-- | .vscode/launch.json | 18 | ||||
| -rw-r--r-- | .vscodeignore | 4 | ||||
| -rw-r--r-- | CHANGELOG.md | 10 | ||||
| -rw-r--r-- | README.md | 71 | ||||
| -rw-r--r-- | example-syntax.api | 19 | ||||
| -rw-r--r-- | language-configuration.json | 30 | ||||
| -rw-r--r-- | package.json | 39 | ||||
| -rw-r--r-- | syntaxes/api-notation.tmLanguage | 217 | ||||
| -rw-r--r-- | vsc-extension-quickstart.md | 29 |
9 files changed, 435 insertions, 2 deletions
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..07b93a4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +# 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. + +## 1.0.0 - 2019-02-05 +- Import from https://gitlab.com/rbdr/api-notation.tmLanguage +- Add VSCode publishing info + +[Unreleased]: https://gitlab.com/rbdr/api-notation.vscode/compare/v1.0.0...HEAD @@ -1,3 +1,70 @@ -# 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 + +`code --install-extension rbdr.api-notation` + +### From GUI + +#### Open the Extension Manager from Palette Manager + +1. Press `⌘⇧P` on OSX or `⌃⇧P` on Windows/Linux to open the palette manager +2. Look for `Install Ext4ensions + +#### Open the Package Manager from Preferences + +1. Go to `Code -> Preferences -> Extensions` menu item + +#### Install it + +1. Search for `api-notation` in the search bar +2. Click Install + + +## 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 +<xx> 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 <IModuleInterface> + +staticProperty <String> + +anotherStaticProperty <Boolean> + ::toggleAnotherStaticProperty() + ::setStaticProperty(newValue <String>) + -instanceProperty <Number> + -anotherInstanceProperty <String> + #instanceMethodSync([optionalParameter]<Boolean>) => resultOfCall <String> + #instanceMethodAsync(someValue <Number>, [callback] <Function>) ->(error <String|null>, result <Number|null>) + + +// Comment +EventHypotheticalClass + +>AnotherClass<+staticEventToListen(eventData <PredefinedObject>) // More Comments + <+staticEventDispatched(someData <SomeData>) + ~>listenedSocketEvent(eventData <SomeObject>) + <~dispatchedSocketEvent(eventData <BlaBla>) + ->AnotherClass<-instanceEventToListen(eventData <Object>) + <-instanceEventDispatched(specificDataType <DefinedObject>) 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..2319e61 --- /dev/null +++ b/package.json @@ -0,0 +1,39 @@ +{ + "name": "api-notation", + "displayName": "API Notation", + "description": "Syntax Highlighting for API notation", + "publisher": "rbdr", + "version": "1.0.0", + "engines": { + "vscode": "^1.30.0" + }, + "categories": [ + "Programming Languages" + ], + "repository": { + "type": "git", + "url": "https://gitlab.com/rbdr/api-notation.vscode.git" + }, + "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" + } + ] + } +} 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>fileTypes</key> + <array> + <string>api</string> + </array> + <key>name</key> + <string>API Notation</string> + <key>patterns</key> + <array> + <dict> + <key>begin</key> + <string>([a-zA-Z0-9_.]+)</string> + <key>end</key> + <string>\n</string> + <key>name</key> + <string>constant.language</string> + <key>patterns</key> + <array> + <dict> + <key>include</key> + <string>#dataTypes</string> + </dict> + <dict> + <key>include</key> + <string>#comment</string> + </dict> + </array> + </dict> + <dict> + <key>begin</key> + <string>^//.*</string> + <key>end</key> + <string>\n</string> + <key>name</key> + <string>comment.line</string> + </dict> + <dict> + <key>begin</key> + <string>[ \t]+</string> + <key>end</key> + <string>\n</string> + <key>patterns</key> + <array> + <dict> + <key>include</key> + <string>#apiMember</string> + </dict> + <dict> + <key>include</key> + <string>#parameterList</string> + </dict> + <dict> + <key>include</key> + <string>#dataTypes</string> + </dict> + <dict> + <key>include</key> + <string>#operators</string> + </dict> + <dict> + <key>include</key> + <string>#parameters</string> + </dict> + <dict> + <key>include</key> + <string>#comment</string> + </dict> + </array> + </dict> + <dict> + <key>begin</key> + <string>^.</string> + <key>end</key> + <string>\n</string> + <key>patterns</key> + <array> + <dict> + <key>include</key> + <string>#comment</string> + </dict> + </array> + </dict> + </array> + <key>repository</key> + <dict> + <key>apiMember</key> + <dict> + <key>captures</key> + <dict> + <key>1</key> + <dict> + <key>name</key> + <string>keyword.control</string> + </dict> + <key>2</key> + <dict> + <key>name</key> + <string>variable.language</string> + </dict> + </dict> + <key>match</key> + <string>((?:<\+)|(?:<\~)|(?:<\-)|(?:\+>)|(?:\~>)|(?:\->)|\-|\+|(?:::)|#)([a-zA-z0-9_]+)</string> + </dict> + <key>comment</key> + <dict> + <key>match</key> + <string>[ \t]*//[ \t]*.*</string> + <key>name</key> + <string>comment.line</string> + </dict> + <key>dataType</key> + <dict> + <key>match</key> + <string>[a-zA-Z0-9_.]+</string> + <key>name</key> + <string>support.function</string> + </dict> + <key>dataTypes</key> + <dict> + <key>begin</key> + <string>\<</string> + <key>end</key> + <string>\></string> + <key>name</key> + <string>keyword.operator</string> + <key>patterns</key> + <array> + <dict> + <key>include</key> + <string>#dataType</string> + </dict> + <dict> + <key>include</key> + <string>#separators</string> + </dict> + </array> + </dict> + <key>operators</key> + <dict> + <key>match</key> + <string>(?:\->)|(?:\=>)</string> + <key>name</key> + <string>keyword.control</string> + </dict> + <key>optionalParameter</key> + <dict> + <key>match</key> + <string>[a-zA-Z0-9_.]+</string> + <key>name</key> + <string>comment.line</string> + </dict> + <key>optionalParameters</key> + <dict> + <key>begin</key> + <string>\[</string> + <key>end</key> + <string>\]</string> + <key>patterns</key> + <array> + <dict> + <key>include</key> + <string>#optionalParameter</string> + </dict> + </array> + </dict> + <key>parameterList</key> + <dict> + <key>begin</key> + <string>\(</string> + <key>end</key> + <string>\)</string> + <key>name</key> + <string>keyword.operator</string> + <key>patterns</key> + <array> + <dict> + <key>include</key> + <string>#parameters</string> + </dict> + <dict> + <key>include</key> + <string>#optionalParameters</string> + </dict> + <dict> + <key>include</key> + <string>#dataTypes</string> + </dict> + <dict> + <key>include</key> + <string>#separators</string> + </dict> + </array> + </dict> + <key>parameters</key> + <dict> + <key>match</key> + <string>[a-zA-Z0-9_.]+</string> + <key>name</key> + <string>string.other</string> + </dict> + <key>separators</key> + <dict> + <key>match</key> + <string>\||,</string> + <key>name</key> + <string>comment.line</string> + </dict> + </dict> + <key>scopeName</key> + <string>source.api-notation</string> + <key>uuid</key> + <string>fc8dc5cf-b7aa-4b64-a665-80e8dc1b2553</string> +</dict> +</plist> 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 `<user home>/.vscode/extensions` folder and restart Code. +* To share your extension with the world, read on https://code.visualstudio.com/docs about publishing an extension. |