summaryrefslogtreecommitdiffstats
path: root/ftplugin/ps1.vim
diff options
context:
space:
mode:
Diffstat (limited to 'ftplugin/ps1.vim')
-rw-r--r--ftplugin/ps1.vim24
1 files changed, 23 insertions, 1 deletions
diff --git a/ftplugin/ps1.vim b/ftplugin/ps1.vim
index 4baa4665..f14a31eb 100644
--- a/ftplugin/ps1.vim
+++ b/ftplugin/ps1.vim
@@ -30,8 +30,30 @@ if has("gui_win32")
\ "All Files (*.*)\t*.*\n"
endif
+" Look up keywords by Get-Help:
+" check for PowerShell Core in Windows, Linux or MacOS
+if executable('pwsh') | let s:pwsh_cmd = 'pwsh'
+ " on Windows Subsystem for Linux, check for PowerShell Core in Windows
+elseif exists('$WSLENV') && executable('pwsh.exe') | let s:pwsh_cmd = 'pwsh.exe'
+ " check for PowerShell <= 5.1 in Windows
+elseif executable('powershell.exe') | let s:pwsh_cmd = 'powershell.exe'
+endif
+
+if exists('s:pwsh_cmd')
+ if !has('gui_running') && executable('less') &&
+ \ !(exists('$ConEmuBuild') && &term =~? '^xterm')
+ " For exclusion of ConEmu, see https://github.com/Maximus5/ConEmu/issues/2048
+ command! -buffer -nargs=1 GetHelp silent exe '!' . s:pwsh_cmd . ' -NoLogo -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -Command Get-Help -Full "<args>" | ' . (has('unix') ? 'LESS= less' : 'less') | redraw!
+ elseif has('terminal')
+ command! -buffer -nargs=1 GetHelp silent exe 'term ' . s:pwsh_cmd . ' -NoLogo -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -Command Get-Help -Full "<args>"' . (executable('less') ? ' | less' : '')
+ else
+ command! -buffer -nargs=1 GetHelp echo system(s:pwsh_cmd . ' -NoLogo -NoProfile -NonInteractive -ExecutionPolicy RemoteSigned -Command Get-Help -Full <args>')
+ endif
+endif
+setlocal keywordprg=:GetHelp
+
" Undo the stuff we changed
-let b:undo_ftplugin = "setlocal tw< cms< fo<" .
+let b:undo_ftplugin = "setlocal tw< cms< fo< iskeyword< keywordprg<" .
\ " | unlet! b:browsefilter"