diff options
author | Anmol Sethi <hi@nhooyr.io> | 2020-07-21 11:46:42 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-21 11:46:42 -0400 |
commit | a6917f840d8609ca5dd0d52977b0e9c5d2a07a68 (patch) | |
tree | 8d609acca057b3e42375f58fa1a4e60e10d622c7 | |
parent | 459800db43146680ef75f3cd251dd4d57d72bf48 (diff) | |
download | rneovim-a6917f840d8609ca5dd0d52977b0e9c5d2a07a68.tar.gz rneovim-a6917f840d8609ca5dd0d52977b0e9c5d2a07a68.tar.bz2 rneovim-a6917f840d8609ca5dd0d52977b0e9c5d2a07a68.zip |
man.vim: Simplify man#init to reduce load time (#12482)
I removed the SunOS stuff since no one uses SunOS and I've never tested
it on there.
I removed the section_flag init as we can just use -S instead of -s
and -S is used by every implementation as far as I know.
This brings man#init's time from 50-70ms to 15-20ms for me.
Closes #12318
Related #6766
Related #6815
-rw-r--r-- | runtime/autoload/man.vim | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 930db3ceb7..dab88fde23 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -7,22 +7,10 @@ let s:loaded_man = 1 let s:find_arg = '-w' let s:localfile_arg = v:true " Always use -l if possible. #6683 -let s:section_arg = '-s' +let s:section_arg = '-S' -function! s:init_section_flag() - call system(['env', 'MANPAGER=cat', 'man', s:section_arg, '1', 'man']) - if v:shell_error - let s:section_arg = '-S' - endif -endfunction - -function! s:init() abort - call s:init_section_flag() - " TODO(nhooyr): Does `man -l` on SunOS list searched directories? +function! man#init() abort try - if !has('win32') && $OSTYPE !~? 'cygwin\|linux' && system('uname -s') =~? 'SunOS' && system('uname -r') =~# '^5' - let s:find_arg = '-l' - endif " Check for -l support. call s:get_page(s:get_path('', 'man')) catch /E145:/ @@ -141,7 +129,7 @@ function! s:get_page(path) abort " Disable hard-wrap by using a big $MANWIDTH (max 1000 on some systems #9065). " Soft-wrap: ftplugin/man.vim sets wrap/breakindent/…. " Hard-wrap: driven by `man`. - let manwidth = !get(g:,'man_hardwrap', 1) ? 999 : (empty($MANWIDTH) ? winwidth(0) : $MANWIDTH) + let manwidth = !get(g:, 'man_hardwrap', 1) ? 999 : (empty($MANWIDTH) ? winwidth(0) : $MANWIDTH) " Force MANPAGER=cat to ensure Vim is not recursively invoked (by man-db). " http://comments.gmane.org/gmane.editors.vim.devel/29085 " Set MAN_KEEP_FORMATTING so Debian man doesn't discard backspaces. @@ -466,4 +454,4 @@ function! man#goto_tag(pattern, flags, info) abort \ }) endfunction -call s:init() +call man#init() |