codekingpro/portable-devtools
114k
1" Vim filetype plugin file2" Language: Windows PowerShell3" URL: https://github.com/PProvost/vim-ps14" Last Change: 2021 Apr 025" 2024 Jan 14 by Vim Project (browsefilter)6" 2024 May 23 by Riley Bruins <ribru17@gmail.com> ('commentstring')7" 2024 Sep 19 by Konfekt (simplify keywordprg #15696)8" 2025 Jul 22 by phanium (use :hor term #17822)9 10" Only do this when not done yet for this buffer11if exists("b:did_ftplugin") | finish | endif12 13" Don't load another plug-in for this buffer14let b:did_ftplugin = 115 16let s:cpo_save = &cpo17set cpo&vim18 19setlocal tw=020setlocal commentstring=#\ %s21setlocal formatoptions=tcqro22" Enable autocompletion of hyphenated PowerShell commands,23" e.g. Get-Content or Get-ADUser24setlocal iskeyword+=-25 26" Change the browse dialog on Win32 and GTK to show mainly PowerShell-related files27if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")28 let b:browsefilter =29 \ "All PowerShell Files (*.ps1, *.psd1, *.psm1, *.ps1xml)\t*.ps1;*.psd1;*.psm1;*.ps1xml\n" .30 \ "PowerShell Script Files (*.ps1)\t*.ps1\n" .31 \ "PowerShell Module Files (*.psd1, *.psm1)\t*.psd1;*.psm1\n" .32 \ "PowerShell XML Files (*.ps1xml)\t*.ps1xml\n"33 if has("win32")34 let b:browsefilter .= "All Files (*.*)\t*\n"35 else36 let b:browsefilter .= "All Files (*)\t*\n"37 endif38endif39 40" Undo the stuff we changed41let b:undo_ftplugin = "setlocal tw< cms< fo< iskeyword<" .42 \ " | unlet! b:browsefilter"43 44" Look up keywords by Get-Help:45" check for PowerShell Core in Windows, Linux or MacOS46if executable('pwsh') | let s:pwsh_cmd = 'pwsh'47 " on Windows Subsystem for Linux, check for PowerShell Core in Windows48elseif exists('$WSLENV') && executable('pwsh.exe') | let s:pwsh_cmd = 'pwsh.exe'49 " check for PowerShell <= 5.1 in Windows50elseif executable('powershell.exe') | let s:pwsh_cmd = 'powershell.exe'51endif52 53if exists('s:pwsh_cmd')54 if exists(':terminal') == 255 command! -buffer -nargs=1 GetHelp silent exe 'hor term ' . s:pwsh_cmd . ' -NoLogo -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -Command Get-Help -Full "<args>"' . (executable('less') ? ' | less' : '')56 else57 command! -buffer -nargs=1 GetHelp echo system(s:pwsh_cmd . ' -NoLogo -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -Command Get-Help -Full <args>')58 endif59 setlocal keywordprg=:GetHelp60 let b:undo_ftplugin ..= " | setl kp< | sil! delc -buffer GetHelp"61endif62 63let &cpo = s:cpo_save64unlet s:cpo_save65 