runtime(misc): simplify keywordprg in various ftplugins
closes: #15696
Signed-off-by: Konfekt <Konfekt@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/ftplugin/ps1.vim b/runtime/ftplugin/ps1.vim
index 9d698f2..e09bbf8 100644
--- a/runtime/ftplugin/ps1.vim
+++ b/runtime/ftplugin/ps1.vim
@@ -4,6 +4,7 @@
" Last Change: 2021 Apr 02
" 2024 Jan 14 by Vim Project (browsefilter)
" 2024 May 23 by Riley Bruins <ribru17@gmail.com> ('commentstring')
+" 2024 Sep 19 by Konfekt (simplify keywordprg #15696)
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin") | finish | endif
@@ -35,6 +36,10 @@
endif
endif
+" Undo the stuff we changed
+let b:undo_ftplugin = "setlocal tw< cms< fo< iskeyword<" .
+ \ " | unlet! b:browsefilter"
+
" Look up keywords by Get-Help:
" check for PowerShell Core in Windows, Linux or MacOS
if executable('pwsh') | let s:pwsh_cmd = 'pwsh'
@@ -45,21 +50,14 @@
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')
+ if exists(':terminal') == 2
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
+ setlocal keywordprg=:GetHelp
+ let b:undo_ftplugin ..= " | setl kp< | sil! delc -buffer GetHelp"
endif
-setlocal keywordprg=:GetHelp
-
-" Undo the stuff we changed
-let b:undo_ftplugin = "setlocal tw< cms< fo< iskeyword< keywordprg<" .
- \ " | unlet! b:browsefilter"
let &cpo = s:cpo_save
unlet s:cpo_save