~gpanders/dotfiles

5ef5d80c353ddefd4fefad2818fd8931073d4f77 — Greg Anders 2 years ago 0f96bd4
Add custom :Helptags command using FZF
2 files changed, 25 insertions(+), 0 deletions(-)

M vim/.vim/after/plugin/fzf.vim
A vim/.vim/autoload/fzf.vim
M vim/.vim/after/plugin/fzf.vim => vim/.vim/after/plugin/fzf.vim +6 -0
@@ 5,7 5,13 @@ if !get(g:, 'loaded_fzf', 0)
  finish
endif

" Ctrl-P to start FZF
nnoremap <silent> <C-P> :FZF<CR>

" Create Helptags command and map it to Ctrl-H
command! -bang Helptags call fzf#helptags(<bang>0)
nnoremap <silent> <C-H> :<C-U>Helptags<CR>

" Hide statusline in FZF buffers
autocmd! FileType fzf set laststatus=0 noruler
      \ | autocmd BufLeave <buffer> set laststatus=2 ruler

A vim/.vim/autoload/fzf.vim => vim/.vim/autoload/fzf.vim +19 -0
@@ 0,0 1,19 @@
" Use FZF to find help tags
" Author: Greg Anders
" Date: 2019-05-07

function! fzf#helptags(bang)
  if !exists('*fzf#run')
    echohl ErrorMsg
    echom 'FZF installation not found'
    echohl None
    return
  endif

  let tags = uniq(sort(globpath(&rtp, 'doc/tags', 0, 1)))
  call fzf#run(fzf#wrap('Helptags', {
        \ 'source': 'grep -ho "^\S\+" ' . join(tags),
        \ 'sink': 'help',
        \ 'options': '+m'
        \ }, a:bang))
endfunction