diff runtime/ftplugin/man.vim @ 13125:371ceeebbdaa

Update runtime files. commit https://github.com/vim/vim/commit/40962ec9c0e7b8699e101182b06ddd39dc0e1212 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 28 22:47:25 2018 +0100 Update runtime files.
author Christian Brabandt <cb@256bit.org>
date Sun, 28 Jan 2018 23:00:08 +0100
parents f690da1b3c04
children e751b5c9dff3
line wrap: on
line diff
--- a/runtime/ftplugin/man.vim
+++ b/runtime/ftplugin/man.vim
@@ -1,7 +1,7 @@
 " Vim filetype plugin file
 " Language:	man
 " Maintainer:	SungHyun Nam <goweol@gmail.com>
-" Last Change: 	2017 Nov 11
+" Last Change: 	2018 Jan 15
 
 " To make the ":Man" command available before editing a manual page, source
 " this script from your startup vimrc file.
@@ -39,7 +39,7 @@ if &filetype == "man"
 endif
 
 if exists(":Man") != 2
-  com -nargs=+ Man call s:GetPage(<f-args>)
+  com -nargs=+ -complete=shellcmd Man call s:GetPage(<f-args>)
   nmap <Leader>K :call <SID>PreGetPage(0)<CR>
   nmap <Plug>ManPreGetPage :call <SID>PreGetPage(0)<CR>
 endif
@@ -173,7 +173,15 @@ func <SID>GetPage(...)
 
   " Ensure Vim is not recursively invoked (man-db does this) when doing ctrl-[
   " on a man page reference by unsetting MANPAGER.
-  silent exec "r !env -u MANPAGER man ".s:GetCmdArg(sect, page)." | col -b"
+  " Some versions of env(1) do not support the '-u' option, and in such case
+  " we set MANPAGER=cat.
+  if !exists('s:env_has_u')
+    call system('env -u x true')
+    let s:env_has_u = (v:shell_error == 0)
+  endif
+  let env_cmd = s:env_has_u ? 'env -u MANPAGER' : 'env MANPAGER=cat'
+  let man_cmd = env_cmd . ' man ' . s:GetCmdArg(sect, page) . ' | col -b'
+  silent exec "r !" . man_cmd
 
   if unsetwidth
     let $MANWIDTH = ''