Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into move-to-editor-syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
jrsconfitto committed May 23, 2018
2 parents 30c2c8b + 6a561fc commit 4b55e57
Show file tree
Hide file tree
Showing 13 changed files with 473 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .github/CONTRIBUTING.md
@@ -0,0 +1,3 @@
Any grammar-related issues (ex: syntax highlight problems) should be made in the [PowerShell/EditorSyntax][PSES] project instead, since that is the backing grammar for this project.

[PSES]:https://github.com/PowerShell/EditorSyntax
12 changes: 12 additions & 0 deletions LICENSE.md
Expand Up @@ -20,6 +20,18 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

---

Utilizes grammar files and code from https://github.com/SublimeText/PowerShell, which is released under the following license:

Copyright (c) 2011 Guillermo López-Anglada

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.

---

Utilizes grammar files and code from https://github.com/PowerShell/EditorSyntax, which is released under the following license:

Copyright (c) Microsoft Corporation
Expand Down
12 changes: 10 additions & 2 deletions README.md
@@ -1,3 +1,11 @@
# PowerShell language support in Atom [![Build Status](https://travis-ci.org/jugglingnutcase/language-powershell.svg?branch=master)](https://travis-ci.org/jugglingnutcase/language-powershell)
# PowerShell language support in Atom [![Build Status](https://travis-ci.org/jrsconfitto/language-powershell.svg?branch=master)](https://travis-ci.org/jrsconfitto/language-powershell)

This package provides [PowerShell](https://msdn.microsoft.com/en-us/mt173057.aspx) language support in the [Atom editor](https://atom.io) by leveraging the [PowerShell syntax](https://github.com/PowerShell/EditorSyntax) from Microsoft.
This package provides [PowerShell](https://msdn.microsoft.com/en-us/mt173057.aspx) language support in the [Atom editor](https://atom.io) by leveraging the [PowerShell syntax][ES] from Microsoft.

## Issues

If you discover any issues with the way the syntax is highlighted, please open an issue against the [PowerShell/EditorSyntax][ES] repository instead of this one, since this package is based on that grammar.

Any issues that aren't related to the grammar are fair game here, though! Start one [here](https://github.com/jugglingnutcase/language-powershell/issues/new).

[ES]:https://github.com/PowerShell/EditorSyntax
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "language-powershell",
"version": "2.1.1",
"version": "4.0.1",
"description": "PowerShell language support for Atom",
"keywords": [
"powershell",
Expand Down
19 changes: 11 additions & 8 deletions scripts/convert-grammar.js
@@ -1,19 +1,22 @@
var fs = require('fs'),
plist = require('plist'),
CSON = require('cson');
var fs = require("fs"),
plist = require("plist"),
CSON = require("cson");

// Read grammar from plist
var psGrammarPlist = fs.readFileSync('vendor/EditorSyntax/PowerShellSyntax.tmLanguage', 'utf8');
var psGrammarPlist = fs.readFileSync(
"vendor/EditorSyntax/PowershellSyntax.tmLanguage",
"utf8"
);
var grammar = plist.parse(psGrammarPlist);

// Write out grammar as CSON
var csonGrammar = CSON.stringify(filterObject(grammar));
fs.writeFileSync('grammars/powershell.cson', csonGrammar, 'utf8');
fs.writeFileSync("grammars/powershell.cson", csonGrammar, "utf8");

// Helper function
// References: https://github.com/atom/apm/blob/c0d657af13a0da4acda6fd4be39eddded7aac1e3/src/package-converter.coffee#L73-75
function filterObject(obj) {
delete obj.uuid
delete obj.keyEquivalent
return obj
delete obj.uuid;
delete obj.keyEquivalent;
return obj;
}
1 change: 1 addition & 0 deletions spec/fixtures/functions/function-dash.ps1
@@ -0,0 +1 @@
Set-PSReadLineKeyHandler -Chord 'Ctrl+p' -Function PreviousHistory
4 changes: 4 additions & 0 deletions spec/fixtures/functions/function-in-function.ps1
@@ -0,0 +1,4 @@
function Test-Highlighting {
Get-Command -Name Get-Alias -CommandType Function -ErrorAction SilentlyContinue
}
# Test thanks to @kborowinski: https://github.com/PowerShell/EditorSyntax/pull/93
3 changes: 3 additions & 0 deletions spec/fixtures/functions/functions.ps1
@@ -0,0 +1,3 @@
Function Test-Function () {
Write-Host "Hi!"
}
4 changes: 4 additions & 0 deletions spec/fixtures/indents/foreach-indent-test.ps1
@@ -0,0 +1,4 @@
foreach($foo in $myArray)
{
Write-Host "Value $foo"
}
4 changes: 4 additions & 0 deletions spec/fixtures/indents/param-indent-example.ps1
@@ -0,0 +1,4 @@
Param (
[switch] $arg1
[switch] $arg2
)
9 changes: 9 additions & 0 deletions spec/fixtures/indents/pstree-indent-test.ps1
@@ -0,0 +1,9 @@
$ProcessesWithoutParents = @()
$ProcessesByParent = @{}
foreach ($Pair in $ProcessesById.GetEnumerator()) {
$Process = $Pair.Value
if (($Process.ParentProcessId -eq 0) -or !$ProcessesById.ContainsKey($Process.ParentProcessId)) {
$ProcessesWithoutParents += $Process
continue
}
}

0 comments on commit 4b55e57

Please sign in to comment.