Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
syntaxes/
tools/node_modules/
tools/package-lock.json
38 changes: 38 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!--
BEFORE SUBMITTING A NEW ISSUE...

Please try a different theme to make sure the problem
is not with the theme and is actually with the syntax.

If you are not reporting a bug please remove this template
and describe the issue in your own words.
-->

### Environment

- Editor and Version (VS Code, Atom, Sublime):
- Your primary theme:

### Issue Description

<!-- Describe the issue in detail -->

#### Screenshots

<!-- If possible include screenshots of the issue -->

### Expected Behavior

<!-- How would you expect it to behave -->

### Code Samples

<!--
Include any code sippets that can be used to reproduce the
described behavior.
-->

```PowerShell


```
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,36 @@ both VS Code and Sublime Text. There are a number of existing issues with the g
that we need to track down and fix. Please see [issue #1](https://github.com/PowerShell/EditorSyntax/issues/1)
for more details.

## Build and Import (VS Code)

### Prerequisites

- Node.JS, >= 8.9.1

### Build

1. Navigate via command line to the `./tools/` directory and install dependencies:

```
npm install
```

2. Run the `build-grammar` script to generate the json file.

```
npm run build-grammar
```

3. The .json file will be generated in `./syntaxes/` at the root of the project. You will need to copy it in to VS Code manually.

1. Locate the VS Code installation directory and navigate to to `resources/app/extensions/powershell/syntaxes`

2. Rename `powershell.tmLanguage.json` to `powershell.tmLanguage.json_default`

3. Copy `powershell.tmLanguage.json` from `./syntaxes/` within the project folder to where you just renamed the file under VS Code's path.

4. If VS Code is already running you will need to run "Reload Window" from the command pallete.

## Contributing

We would love to have community contributions to this project to make PowerShell syntax
Expand Down
16 changes: 16 additions & 0 deletions tools/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "editorsyntax",
"license" : "MIT",
"description": "PowerShell language syntax",
"repository": {
"type": "git",
"url": "https://github.com/PowerShell/EditorSyntax.git"
},
"version": "1.0.0",
"dependencies": {
"fast-plist": "0.1.2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to register that we are using this library (internal process). I'm expecting it to be approved quickly but I wanted to let you know. It might take a day.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it helps fast-plist was written by Microsoft https://github.com/Microsoft/node-fast-plist

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well that makes things a lot easier

},
"scripts": {
"build-grammar": "node ./scripts/build-grammar.js ../PowerShellSyntax.tmLanguage ../syntaxes/powershell.tmLanguage.json"
}
}
55 changes: 55 additions & 0 deletions tools/scripts/build-grammar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------------------------
* Licensed under the MIT License. See License.txt in the project root for license information.
*
* Modified for PowerShell\EditorSyntax from Microsoft\vscode (update-grammar.js)
* This script generates the JSON file using the same tools as vscode's build.
*--------------------------------------------------------------------------------------------*/

'use strict';

var path = require('path');
var fs = require('fs');
var plist = require('fast-plist');

exports.update = function (tmlPath, dest) {
console.log('... Reading source file.');
var content = fs.readFileSync(tmlPath).toString();

console.log('... Parsing content.');
var grammar;
grammar = plist.parse(content);

console.log('... Building contents.');
let result = {
information_for_contributors: [
'This file has been converted from source and may not be in line with the official build.',
'The current master branch for this syntax can be found here: https://github.com/PowerShell/EditorSyntax',
'If you want to provide a fix or improvement, please create a pull request against the original repository.'
]
};

result.version = require('child_process')
.execSync('git rev-parse HEAD')
.toString().trim()

let keys = ['name', 'scopeName', 'comment', 'injections', 'patterns', 'repository'];
for (let key of keys) {
if (grammar.hasOwnProperty(key)) {
result[key] = grammar[key];
}
}

var dirname = path.dirname(dest);
if (!fs.existsSync(dirname)) {
console.log('... Creating directory: ' + dirname);
fs.mkdirSync(dirname);
}

fs.writeFileSync(dest, JSON.stringify(result, null, '\t'));
console.log('[Finished] File written to: ' + dest);
};

if (path.basename(process.argv[1]) === 'build-grammar.js') {
console.log('[Starting] Converting ' + process.argv[2] + ' to json.');
exports.update(process.argv[2], process.argv[3]);
}