Skip to content

Commit

Permalink
Merge pull request #55 from corbob/Add-Snippets
Browse files Browse the repository at this point in the history
Add Snippets
  • Loading branch information
Yatao Li authored Jul 29, 2019
2 parents 087ef36 + aef8b67 commit ee00661
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.zip
PowerShellEditorServices/
Snippets/
.pses
node_modules
out
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ let g:coc_global_extensions=[ 'coc-powershell', ... ]

## Recommended plugins

[vim-polyglot](https://github.com/sheerun/vim-polyglot) for syntax highlighting 🎨
* [coc-snippets](https://github.com/neoclide/coc-snippets) Used to allow snippets [(requires neovim 0.4 or latest vim8)](https://github.com/neoclide/coc.nvim/wiki/F.A.Q#how-to-make-preview-window-shown-aside-with-pum).
* Can be installed with `:CocInstall coc-snippets`
* [vim-polyglot](https://github.com/sheerun/vim-polyglot) for syntax highlighting 🎨
4 changes: 4 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ if (!(Test-Path "$PSScriptRoot/PowerShellEditorServices")) {
& "$PSScriptRoot/downloadPSES.ps1"
}

if (!(Test-Path "$PSScriptRoot/Snippets")) {
& "$PSScriptRoot/downloadSnippets.ps1"
}

if (!(Get-Command npm)) {
throw "You must install Node.js & npm."
}
Expand Down
2 changes: 0 additions & 2 deletions downloadPSES.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ Write-Host Latest Release: $tag

$download = "https://github.com/$repo/releases/download/$tag/$file"
$zip = "pses.zip"

$null = New-Item -Name $dir -ItemType Directory -Force
Write-Host Downloading PowerShell Editor Services: $tag
Invoke-WebRequest $download -OutFile $zip

Expand Down
25 changes: 25 additions & 0 deletions downloadSnippets.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env pwsh

Write-Host Starting download of Snippets from vscode-powershell
if (!$IsCoreCLR) {
# We only need to do this in Windows PowerShell.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
}

# Fail on anything
$ErrorActionPreference = "Stop"
# Progress doesn't display properly in vim
$ProgressPreference = "SilentlyContinue"

Push-Location $PSScriptRoot

$download = "https://raw.githubusercontent.com/PowerShell/vscode-powershell/master/snippets/PowerShell.json"

$dir = "$PSScriptRoot/Snippets/"

$null = New-Item -Path $dir -ItemType Directory -Force
Invoke-WebRequest $download -OutFile "$dir\PowerShell.json"

Pop-Location

Write-Host Completed downloading Snippets.
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@
"src/downloadPSES.ps1",
"README.md",
"LICENSE",
"Snippets",
"PowerShellEditorServices"
],
"contributes": {
"snippets": [
{
"language": "ps1",
"path": "Snippets/PowerShell.json"
}
],
"languages": [
{
"id": "ps1",
Expand Down

0 comments on commit ee00661

Please sign in to comment.