From 63f0ca326322376271c68f51cf8908daad524339 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Tue, 22 Oct 2019 23:40:16 +0100 Subject: [PATCH] man.vim: use 'tagfunc' instead of remapping man#pop_tag() is also no longer used --- runtime/autoload/man.vim | 23 +++++++++++++++-------- runtime/ftplugin/man.vim | 4 ++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index ec48d96dd6..8825719ec7 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -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() diff --git a/runtime/ftplugin/man.vim b/runtime/ftplugin/man.vim index 6c7f095f62..b3b23833ba 100644 --- a/runtime/ftplugin/man.vim +++ b/runtime/ftplugin/man.vim @@ -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 j gj nnoremap k gk nnoremap gO :call man#show_toc() - nnoremap :Man nnoremap K :Man - nnoremap :call man#pop_tag() if 1 == bufnr('%') || s:pager nnoremap q :lclose:q else