Skip to content

Commit

Permalink
Allow pwsh and work crossplat
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerLeonhardt committed Apr 17, 2019
1 parent 9d7130a commit c750659
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion install.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Write-Host Dowloading $tag
Invoke-WebRequest $download -Out $zip

Write-Host Extracting release files...
Expand-Archive $zip -Force
Expand-Archive $zip -Force $pwd

Remove-Item $zip -Force
Write-Host install completed.
28 changes: 28 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env pwsh

if (!$IsCoreCLR) {
# We only need to do this in Windows PowerShell.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
}

$ErrorActionPreference = "Stop"
$repo = "PowerShell/PowerShellEditorServices"
$file = "PowerShellEditorServices.zip"

$releases = "https://api.github.com/repos/$repo/releases"

Write-Host Determining latest release...
$tag = (Invoke-RestMethod $releases)[0].tag_name

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

New-Item -Name $dir -ItemType Directory -Force
Write-Host Downloading $tag
Invoke-WebRequest $download -OutFile $zip

Write-Host Extracting release files...
Expand-Archive $zip $pwd -Force

Remove-Item $zip -Force
Write-Host install completed.
15 changes: 14 additions & 1 deletion plugin/pses.vim → plugin/coc-pses.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ let s:vimscript_dir = expand('<sfile>:p:h')
let g:pses_dir = resolve(expand(s:vimscript_dir . '/../PowerShellEditorServices/PowerShellEditorServices'))
let g:pses_script = g:pses_dir . "/Start-EditorServices.ps1"

if(!exists("g:pses_powershell_executable"))
let g:pses_powershell_executable = "powershell"
if(executable("pwsh"))
let g:pses_powershell_executable = "pwsh"
endif
endif

function! s:PSESSetup ()
call coc#config("languageserver", {
\ "pses": {
\ "command": "powershell",
\ "command": g:pses_powershell_executable,
\ "filetypes": ["ps1", "psm1", "psd1"],
\ "rootPatterns": [".pses/", ".vim/", ".git/", ".hg/"],
\ "trace.server": "verbose",
Expand All @@ -28,4 +35,10 @@ function! s:PSESSetup ()
\)
endfunction

" Set the file type to ps1 for ps1, psm1, and psd1
" 'ps1' is what vim-polyglot uses for styling
if(&filetype == "")
autocmd BufNewFile,BufRead *.ps*1 set filetype=ps1
endif

autocmd FileType ps1,psd1,psm1 call s:PSESSetup()

0 comments on commit c750659

Please sign in to comment.