neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

ps1.vim (2489B)


      1 " Vim filetype plugin file
      2 " Language:    Windows PowerShell
      3 " URL:         https://github.com/PProvost/vim-ps1
      4 " Last Change: 2021 Apr 02
      5 "              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 buffer
     11 if exists("b:did_ftplugin") | finish | endif
     12 
     13 " Don't load another plug-in for this buffer
     14 let b:did_ftplugin = 1
     15 
     16 let s:cpo_save = &cpo
     17 set cpo&vim
     18 
     19 setlocal tw=0
     20 setlocal commentstring=#\ %s
     21 setlocal formatoptions=tcqro
     22 " Enable autocompletion of hyphenated PowerShell commands,
     23 " e.g. Get-Content or Get-ADUser
     24 setlocal iskeyword+=-
     25 
     26 " Change the browse dialog on Win32 and GTK to show mainly PowerShell-related files
     27 if (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 else
     36 	let b:browsefilter .= "All Files (*)\t*\n"
     37 endif
     38 endif
     39 
     40 " Undo the stuff we changed
     41 let 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 MacOS
     46 if executable('pwsh') | let s:pwsh_cmd = 'pwsh'
     47  " on Windows Subsystem for Linux, check for PowerShell Core in Windows
     48 elseif exists('$WSLENV') && executable('pwsh.exe') | let s:pwsh_cmd = 'pwsh.exe'
     49  " check for PowerShell <= 5.1 in Windows
     50 elseif executable('powershell.exe') | let s:pwsh_cmd = 'powershell.exe'
     51 endif
     52 
     53 if exists('s:pwsh_cmd')
     54  if exists(':terminal') == 2
     55    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  else
     57    command! -buffer -nargs=1 GetHelp echo system(s:pwsh_cmd . ' -NoLogo -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -Command Get-Help -Full <args>')
     58  endif
     59  setlocal keywordprg=:GetHelp
     60  let b:undo_ftplugin ..= " | setl kp< | sil! delc -buffer GetHelp"
     61 endif
     62 
     63 let &cpo = s:cpo_save
     64 unlet s:cpo_save