man.vim: refactoring and autocmd fix

- man#open_page_command and man#open_page_mapping are now a single
  function
- New autocmd to fix #5172
This commit is contained in:
Anmol Sethi
2016-08-06 05:52:36 -04:00
committed by Anmol Sethi (nhooyr)
parent f665bde183
commit e89eb5d21b
2 changed files with 67 additions and 65 deletions

View File

@@ -5,6 +5,15 @@ if exists('g:loaded_man')
endif
let g:loaded_man = 1
command! -count=0 -complete=customlist,man#complete -nargs=* Man call man#open_page_command(v:count, v:count1, <f-args>)
command! -count=0 -complete=customlist,man#complete -nargs=* Man call man#open_page(v:count, v:count1, <f-args>)
nnoremap <silent> <Plug>(Man) :<C-U>call man#open_page_mapping(v:count, v:count1, &filetype ==# 'man' ? expand('<cWORD>') : expand('<cword>'))<CR>
nnoremap <silent> <Plug>(Man) :<C-U>call man#open_page(v:count, v:count1, &filetype ==# 'man' ? expand('<cWORD>') : expand('<cword>'))<CR>
augroup man
autocmd!
autocmd BufReadCmd man://* call man#read_page(matchstr(expand('<amatch>'), 'man://\zs.*'))
" Need this because without it, if you do ':Man printf(3)' and then later,
" open a session that contains a buffer named 'man://printf(3)', the buffer
" will become listed.
autocmd BufEnter man://* set nobuflisted
augroup END