Skip to content

Commit c750659

Browse files
Allow pwsh and work crossplat
1 parent 9d7130a commit c750659

3 files changed

Lines changed: 43 additions & 2 deletions

File tree

install.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Write-Host Dowloading $tag
1919
Invoke-WebRequest $download -Out $zip
2020

2121
Write-Host Extracting release files...
22-
Expand-Archive $zip -Force
22+
Expand-Archive $zip -Force $pwd
2323

2424
Remove-Item $zip -Force
2525
Write-Host install completed.

install.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env pwsh
2+
3+
if (!$IsCoreCLR) {
4+
# We only need to do this in Windows PowerShell.
5+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
6+
}
7+
8+
$ErrorActionPreference = "Stop"
9+
$repo = "PowerShell/PowerShellEditorServices"
10+
$file = "PowerShellEditorServices.zip"
11+
12+
$releases = "https://api.github.com/repos/$repo/releases"
13+
14+
Write-Host Determining latest release...
15+
$tag = (Invoke-RestMethod $releases)[0].tag_name
16+
17+
$download = "https://github.com/$repo/releases/download/$tag/$file"
18+
$zip = "pses.zip"
19+
20+
New-Item -Name $dir -ItemType Directory -Force
21+
Write-Host Downloading $tag
22+
Invoke-WebRequest $download -OutFile $zip
23+
24+
Write-Host Extracting release files...
25+
Expand-Archive $zip $pwd -Force
26+
27+
Remove-Item $zip -Force
28+
Write-Host install completed.

plugin/pses.vim renamed to plugin/coc-pses.vim

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@ let s:vimscript_dir = expand('<sfile>:p:h')
22
let g:pses_dir = resolve(expand(s:vimscript_dir . '/../PowerShellEditorServices/PowerShellEditorServices'))
33
let g:pses_script = g:pses_dir . "/Start-EditorServices.ps1"
44

5+
if(!exists("g:pses_powershell_executable"))
6+
let g:pses_powershell_executable = "powershell"
7+
if(executable("pwsh"))
8+
let g:pses_powershell_executable = "pwsh"
9+
endif
10+
endif
11+
512
function! s:PSESSetup ()
613
call coc#config("languageserver", {
714
\ "pses": {
8-
\ "command": "powershell",
15+
\ "command": g:pses_powershell_executable,
916
\ "filetypes": ["ps1", "psm1", "psd1"],
1017
\ "rootPatterns": [".pses/", ".vim/", ".git/", ".hg/"],
1118
\ "trace.server": "verbose",
@@ -28,4 +35,10 @@ function! s:PSESSetup ()
2835
\)
2936
endfunction
3037

38+
" Set the file type to ps1 for ps1, psm1, and psd1
39+
" 'ps1' is what vim-polyglot uses for styling
40+
if(&filetype == "")
41+
autocmd BufNewFile,BufRead *.ps*1 set filetype=ps1
42+
endif
43+
3144
autocmd FileType ps1,psd1,psm1 call s:PSESSetup()

0 commit comments

Comments
 (0)