aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/autoload/man.vim28
-rw-r--r--runtime/ftplugin/man.vim4
-rw-r--r--runtime/plugin/man.vim4
3 files changed, 19 insertions, 17 deletions
diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim
index 79931b61b1..1434fc7cf8 100644
--- a/runtime/autoload/man.vim
+++ b/runtime/autoload/man.vim
@@ -22,7 +22,7 @@ catch /E145:/
" Ignore the error in restricted mode
endtry
-function! man#open_page_command(...) abort
+function! man#open_page_command(count, count1, ...) abort
if a:0 > 2
call s:error('too many arguments')
return
@@ -40,6 +40,10 @@ function! man#open_page_command(...) abort
endif
try
let [sect, name] = s:extract_sect_and_name_ref(ref)
+ if a:count ==# a:count1
+ " user explicitly set a count
+ let sect = string(a:count)
+ endif
let [sect, name] = s:verify_exists(sect, name)
catch
call s:error(v:exception)
@@ -54,7 +58,7 @@ endfunction
" are equal was the count explicitly set.
function! man#open_page_mapping(count, count1, ref) abort
if empty(a:ref)
- call s:error('what manual page do you want?')
+ call s:error('missing argument')
return
endif
try
@@ -164,25 +168,23 @@ function! s:open_page(sect, name)
endif
if getbufvar(bufname, 'manwidth') ==# manwidth
if found_man
- silent execute 'buf '.bufnr(bufname)
+ silent execute 'buf' bufnr(bufname)
else
- execute 'split '.bufname
+ execute 'split' bufname
+ setlocal nobuflisted
endif
keepjumps 1
return
endif
- let already_opened = bufexists(bufname)
if found_man
- execute 'edit '.bufname
+ execute 'edit' bufname
else
- execute 'split '.bufname
- endif
- if already_opened
- setlocal modifiable
- setlocal noreadonly
- keepjumps %delete _
+ execute 'split' bufname
endif
- silent execute 'read!env MANWIDTH='.manwidth.' '.s:man_cmd.' '.s:man_args(a:sect, a:name)
+ setlocal modifiable
+ setlocal noreadonly
+ keepjumps %delete _
+ silent execute 'read!env MANWIDTH='.manwidth s:man_cmd s:man_args(a:sect, a:name)
let b:manwidth = manwidth
" remove all the backspaced text
silent keeppatterns keepjumps %substitute,.\b,,ge
diff --git a/runtime/ftplugin/man.vim b/runtime/ftplugin/man.vim
index a45a380eb2..06b61bd8aa 100644
--- a/runtime/ftplugin/man.vim
+++ b/runtime/ftplugin/man.vim
@@ -17,9 +17,9 @@ if has('vim_starting')
else
keepjumps 1
endif
- " This is not perfect.See `man glDrawArraysInstanced`. Since the title is
+ " This is not perfect. See `man glDrawArraysInstanced`. Since the title is
" all caps it is impossible to tell what the original capitilization was.
- execute 'file '.'man://'.tolower(matchstr(getline(1), '^\S\+'))
+ execute 'file man://'.tolower(matchstr(getline(1), '^\S\+'))
endif
setlocal buftype=nofile
diff --git a/runtime/plugin/man.vim b/runtime/plugin/man.vim
index c47459a551..82ef154725 100644
--- a/runtime/plugin/man.vim
+++ b/runtime/plugin/man.vim
@@ -5,6 +5,6 @@ if exists('g:loaded_man')
endif
let g:loaded_man = 1
-command! -complete=customlist,man#complete -nargs=* Man call man#open_page_command(<f-args>)
+command! -count=0 -complete=customlist,man#complete -nargs=* Man call man#open_page_command(v:count, v:count1, <f-args>)
-nnoremap <silent> <Plug>(Man) :<C-U>call man#open_page_mapping(v:count, v:count1, expand('<cWORD>'))<CR>
+nnoremap <silent> <Plug>(Man) :<C-U>call man#open_page_mapping(v:count, v:count1, &filetype ==# 'man' ? expand('<cWORD>') : expand('<cword>'))<CR>