diff options
Diffstat (limited to 'runtime/autoload/man.vim')
-rw-r--r-- | runtime/autoload/man.vim | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 4d6a1f78dc..b8a73a64c9 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -125,9 +125,7 @@ endfunction function! s:set_options(pager) abort setlocal noswapfile buftype=nofile bufhidden=hide setlocal nomodified readonly nomodifiable - if a:pager - nnoremap <silent> <buffer> <nowait> q :lclose<CR>:q<CR> - endif + let b:pager = a:pager setlocal filetype=man endfunction @@ -173,6 +171,12 @@ function! man#show_toc() abort while lnum && lnum < last_line let text = getline(lnum) if text =~# '^\%( \{3\}\)\=\S.*$' + " if text is a section title + call add(toc, {'bufnr': bufnr('%'), 'lnum': lnum, 'text': text}) + elseif text =~# '^\s\+\%(+\|-\)\S\+' + " if text is a flag title. we strip whitespaces and prepend two + " spaces to have a consistent format in the loclist. + let text = ' ' .. substitute(text, '^\s*\(.\{-}\)\s*$', '\1', '') call add(toc, {'bufnr': bufnr('%'), 'lnum': lnum, 'text': text}) endif let lnum = nextnonblank(lnum + 1) |