man.vim: use 'tagfunc' instead of remapping

man#pop_tag() is also no longer used
This commit is contained in:
Rob Pilling 2019-10-22 23:40:16 +01:00
parent ed72d9597d
commit 63f0ca3263
2 changed files with 17 additions and 10 deletions

View File

@ -264,14 +264,6 @@ function! s:push_tag() abort
\ }]
endfunction
function! man#pop_tag() abort
if !empty(s:tag_stack)
let tag = remove(s:tag_stack, -1)
execute 'silent' tag['buf'].'buffer'
call cursor(tag['lnum'], tag['col'])
endif
endfunction
" extracts the name and sect out of 'path/name.sect'
function! s:extract_sect_and_name_path(path) abort
let tail = fnamemodify(a:path, ':t')
@ -410,4 +402,19 @@ function! man#init_pager() abort
endif
endfunction
function! man#goto_tag(pattern, flags, info) abort
" currently no support for section completion
let sect = ""
let candidates = s:get_paths(sect, a:pattern)
return map(candidates, {
\ _, path -> {
\ 'name': s:extract_sect_and_name_path(path)[1],
\ 'filename': 'man://' . path,
\ 'cmd': '1'
\ }
\ })
endfunction
call s:init()

View File

@ -20,13 +20,13 @@ setlocal wrap breakindent linebreak
setlocal nonumber norelativenumber
setlocal foldcolumn=0 colorcolumn=0 nolist nofoldenable
setlocal tagfunc=man#goto_tag
if !exists('g:no_plugin_maps') && !exists('g:no_man_maps')
nnoremap <silent> <buffer> j gj
nnoremap <silent> <buffer> k gk
nnoremap <silent> <buffer> gO :call man#show_toc()<CR>
nnoremap <silent> <buffer> <C-]> :Man<CR>
nnoremap <silent> <buffer> K :Man<CR>
nnoremap <silent> <buffer> <C-T> :call man#pop_tag()<CR>
if 1 == bufnr('%') || s:pager
nnoremap <silent> <buffer> <nowait> q :lclose<CR>:q<CR>
else