From 21ae737f04d0247f2ad229665bab8b7369b0bab4 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Mon, 9 Nov 2015 15:26:37 +0000 Subject: [PATCH] Add `g:vim_man_cmd` to change default man command Closes #24, closes #32 --- autoload/man.vim | 2 +- autoload/man/grep.vim | 2 +- autoload/man/grep/vanilla.vim | 2 +- autoload/man/helpers.vim | 2 +- doc/man.txt | 5 +++++ plugin/man.vim | 4 ++++ 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/autoload/man.vim b/autoload/man.vim index 1fb3f3d..c3654ff 100644 --- a/autoload/man.vim +++ b/autoload/man.vim @@ -44,7 +44,7 @@ function! s:manpage_exists(sect, page) return 0 endif let find_arg = man#helpers#find_arg() - let where = system('/usr/bin/man '.find_arg.' '.man#helpers#get_cmd_arg(a:sect, a:page)) + let where = system(g:vim_man_cmd.' '.find_arg.' '.man#helpers#get_cmd_arg(a:sect, a:page)) if where !~# '^\s*/' " result does not look like a file path return 0 diff --git a/autoload/man/grep.vim b/autoload/man/grep.vim index e37a98b..57ea0cf 100644 --- a/autoload/man/grep.vim +++ b/autoload/man/grep.vim @@ -126,7 +126,7 @@ function! man#grep#command(path_glob, insensitive_flag, pattern) " xargs is used to feed manpages one-by-one let command .= 'xargs -I{} -n1 sh -c "manpage={};' " inner variables execute within a shell started by xargs - let command .= '/usr/bin/man \$manpage 2>/dev/null|col -b|' + let command .= g:vim_man_cmd.' \$manpage 2>/dev/null|col -b|' " if the first manpage line is blank, remove it (stupid semicolons are required) let command .= "sed '1 {;/^\s*$/d;}'|" let command .= 'grep '.a:insensitive_flag.' -nE '.a:pattern.'|' diff --git a/autoload/man/grep/vanilla.vim b/autoload/man/grep/vanilla.vim index 9bd809a..932d762 100644 --- a/autoload/man/grep/vanilla.vim +++ b/autoload/man/grep/vanilla.vim @@ -15,7 +15,7 @@ function! man#grep#vanilla#run(bang, insensitive, pattern, files) let $MANWIDTH = man#helpers#manwidth() let insensitive_flag = a:insensitive ? '-i' : '' for file in a:files - let output_manfile = '/usr/bin/man '.file.' | col -b |' + let output_manfile = g:vim_man_cmd.' '.file.' | col -b |' let trim_whitespace = "sed '1 {; /^\s*$/d; }' |" let grep = 'grep '.insensitive_flag.' -n -E '.a:pattern let matches = systemlist(output_manfile . trim_whitespace . grep) diff --git a/autoload/man/helpers.vim b/autoload/man/helpers.vim index 11939c0..45531b0 100644 --- a/autoload/man/helpers.vim +++ b/autoload/man/helpers.vim @@ -69,7 +69,7 @@ function! man#helpers#load_manpage_text(page, section) setlocal modifiable silent keepj norm! 1GdG let $MANWIDTH = man#helpers#manwidth() - silent exec 'r!/usr/bin/man '.man#helpers#get_cmd_arg(a:section, a:page). ' 2>/dev/null | col -b' + silent exec 'r!'.g:vim_man_cmd.' '.man#helpers#get_cmd_arg(a:section, a:page). ' 2>/dev/null | col -b' call s:remove_blank_lines_from_top_and_bottom() setlocal filetype=man setlocal nomodifiable diff --git a/doc/man.txt b/doc/man.txt index d640660..7ff4088 100644 --- a/doc/man.txt +++ b/doc/man.txt @@ -110,7 +110,12 @@ in your |vimrc|: > map v (Vman) < +OPTIONS *man-options* +Default man command is '/usr/bin/man', but it can be changed: +> + let g:vim_man_cmd = 'LANG=ja_JP.UTF-8 /usr/bin/man' +< CONTRIBUTING *man-contributing* *man-bugs* Contributing and bug fixes are welcome. If you have an idea for a new feature diff --git a/plugin/man.vim b/plugin/man.vim index 23a4a88..a1a97ae 100644 --- a/plugin/man.vim +++ b/plugin/man.vim @@ -6,6 +6,10 @@ let g:loaded_man = 1 let s:save_cpo = &cpo set cpo&vim +if !exists('g:vim_man_cmd') + let g:vim_man_cmd='/usr/bin/man' +endif + command! -nargs=* -bar -complete=customlist,man#completion#run Man call man#get_page('horizontal', ) command! -nargs=* -bar -complete=customlist,man#completion#run Sman call man#get_page('horizontal', ) command! -nargs=* -bar -complete=customlist,man#completion#run Vman call man#get_page('vertical', )