Skip to content

Commit

Permalink
Added source.yaml, text.yaml and streamlined tmLanguage scopes.
Browse files Browse the repository at this point in the history
  • Loading branch information
wfurphy committed Jan 12, 2023
1 parent 091bfd6 commit 1e4a8ff
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 128 deletions.
2 changes: 2 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.vscode-test/**
.gitignore
vsc-extension-quickstart.md
*.vsix
images
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,14 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

## [Unreleased]

- Initial release
## [0.1.0]

### Added

- JS Triple Square Bracket Injection Grammar for `home-assistant` YAML language. To be used in combination with [Home Assistant Config Helper](https://github.com/keesschollaart81/vscode-home-assistant) extension.

## [0.2.0]

### Added

- JS Tripple Square Brackets Injection Grammar for YAML language.
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

The MIT License (MIT)
Copyright (c) 2023, Will Furphy | https://github.com/wfurphy

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.
69 changes: 12 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,20 @@
# vscode-home-assistant-button-card-js README
# Button Card Javascript Syntax Highlighting in VSCode

This is the README for your extension "vscode-home-assistant-button-card-js". After writing up a brief description, we recommend including the following sections.
![release](https://img.shields.io/github/v/release/wfurphy/vscode-home-assistant-button-card-js)
![license](https://img.shields.io/github/license/wfurphy/vscode-home-assistant-button-card-js)

## Features
This is a very niche extension for Visual Studio Code which provides syntax highlighting of Javascript code blocks in YAML which are enclosed by triple square brackets (`[[[ ... ]]]`). Used when configuring the advanced _javascript templates_ properties of [Button-Card](https://github.com/custom-cards/button-card) cards for Home Assistant Lovelace dashboards.

Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file.
* Syntax highlighting provided using built-in Javascript grammar
* "Double quoted" and block YAML strings supported
* Works with the standard YAML language and the `home-assistant` YAML language created by the [Home Assistant Config Helper](https://github.com/keesschollaart81/vscode-home-assistant) plugin.

For example if there is an image subfolder under your extension project workspace:
## Preview

\!\[feature X\]\(images/feature-x.png\)
![VSCode BC JS Example](images/vscodebcjs-example.png)

> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow.
_The preview above is using the OneDark Pro theme. This plugin only provides language grammar and will work with any theme you currently use._

## Requirements
## Installation

If you have any requirements or dependencies, add a section describing those and how to install and configure them.

## Extension Settings

Include if your extension adds any VS Code settings through the `contributes.configuration` extension point.

For example:

This extension contributes the following settings:

* `myExtension.enable`: Enable/disable this extension.
* `myExtension.thing`: Set to `blah` to do something.

## Known Issues

Calling out known issues can help limit users opening duplicate issues against your extension.

## Release Notes

Users appreciate release notes as you update your extension.

### 1.0.0

Initial release of ...

### 1.0.1

Fixed issue #.

### 1.1.0

Added features X, Y, and Z.

---

## Working with Markdown

You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:

* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux).
* Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux).
* Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets.

## For more information

* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown)
* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/)

**Enjoy!**
I will eventually publish this on the marketplace. Until then you need to [download the latest release](https://github.com/wfurphy/vscode-home-assistant-button-card-js/releases/latest) as a VSIX file. Then in Visual Studio Code navigate to your Extensions screen. From the three dots at the top right of the Extension browser chose "Install from VSIX...", select the file and follow the prompts. Restart Visual Studio Code. Enjoy.
Binary file added images/vscodebcjs-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 17 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"name": "vscode-home-assistant-button-card-js",
"displayName": "Javascript Highlighting for Button-Card Templates in VSCode",
"description": "Syntax Highlighting for Javascript code blocks enclosed in triple square brackets [[[ * ]]]. Used by Button-Card Templates for Home Assistant Lovelace Dashboards. This is to be used as an addition to https://github.com/keesschollaart81/vscode-home-assistant as it injects into the `source.home-assistant` YAML replacement language provided by this plugin.",
"displayName": "Button Card Javascript Syntax Highlighting in VSCode",
"description": "Syntax highlighting of Javascript code blocks in YAML which are enclosed by triple square brackets (`[[[ ... ]]]`). Used when configuring the advanced _javascript templates_ properties of [Button-Card](https://github.com/custom-cards/button-card) cards for Home Assistant Lovelace dashboards.",
"homepage": "https://github.com/wfurphy/vscode-home-assistant-button-card-js",
"author": "Will Furphy (https://github.com/wfurphy)",
"repository": {
"type": "git",
"url": "https://github.com/wfurphy/vscode-home-assistant-button-card-js.git"
},
"license": "MIT",
"version": "0.2.0",
"engines": {
"vscode": "^1.45.1"
Expand All @@ -12,20 +19,24 @@
"contributes": {
"grammars": [
{
"scopeName": "js-inline.homeassistant.injection",
"scopeName": "js-inline.injection",
"path": "./syntaxes/js-inline.tmLanguage.json",
"injectTo": [
"source.home-assistant"
"source.home-assistant",
"text.yaml",
"source.yaml"
],
"embeddedLanguages": {
"meta.embedded.inline.js": "js"
}
},
{
"scopeName": "js-block.homeassistant.injection",
"scopeName": "js-block.injection",
"path": "./syntaxes/js-block.tmLanguage.json",
"injectTo": [
"source.home-assistant"
"source.home-assistant",
"text.yaml",
"source.yaml"
],
"embeddedLanguages": {
"meta.embedded.block.js": "js"
Expand Down
25 changes: 7 additions & 18 deletions syntaxes/js-block.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
{
"scopeName": "js-block.homeassistant.injection",
"injectionSelector": "L:string.unquoted.block.homeassistant",
"name": "Grammar for Button-Card Javascript blocks expressions surrounded by triple square brackets",
"scopeName": "js-block.injection",
"injectionSelector": "L:string.unquoted.block",
"name": "Grammar for Button-Card Javascript blocks surrounded by triple square brackets",
"patterns": [
{
"include": "#js-block-expression"
}
],
"repository": {
"js-block-expression": {
"comment": "The 'name' is used to undo highlighting as string",
"name": "keyword.operator.homeassistant",
"name": "keyword.operator",
"begin": "\\[\\[\\[",
"end": "\\]\\]\\]",
"beginCaptures": {
"0": {
"name": "constant.character.escape.homeassistant"
}
},
"endCaptures": {
"captures": {
"0": {
"name": "constant.character.escape.homeassistant"
"name": "constant.character.escape"
}
},
"contentName": "meta.embedded.block.js",
Expand All @@ -30,5 +19,5 @@
}
]
}
}
]
}
23 changes: 6 additions & 17 deletions syntaxes/js-inline.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
{
"scopeName": "js-inline.homeassistant.injection",
"injectionSelector": "L:string.quoted.double.homeassistant",
"scopeName": "js-inline.injection",
"injectionSelector": "L:string.quoted.double",
"name": "Grammar for Button-Card Javascript expressions surrounded by triple square brackets in quoted strings",
"patterns": [
{
"include": "#js-inline-expression"
}
],
"repository": {
"js-inline-expression": {
"comment": "The 'name' is used to undo highlighting as string",
"name": "keyword.operator.homeassistant",
"name": "keyword.operator",
"begin": "\\[\\[\\[",
"end": "\\]\\]\\]",
"beginCaptures": {
"0": {
"name": "constant.character.escape.homeassistant"
}
},
"endCaptures": {
"captures": {
"0": {
"name": "constant.character.escape.homeassistant"
"name": "constant.character.escape"
}
},
"contentName": "meta.embedded.inline.js",
Expand All @@ -30,5 +19,5 @@
}
]
}
}
]
}
29 changes: 0 additions & 29 deletions vsc-extension-quickstart.md

This file was deleted.

0 comments on commit 1e4a8ff

Please sign in to comment.