~gpanders/dotfiles

ref: 2da1dde5ea566f82ebe6532bc6d3b8670fd77ce8 dotfiles/vim/.vim/autoload/fzf.vim -rw-r--r-- 1.4 KiB
2da1dde5Greg Anders Note 'open' subcommand opens editor in NOTES_DIR when no argument given 1 year, 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
" Use FZF to find help tags
" Author: Greg Anders
" Date: 2019-05-07

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

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

function! fzf#tags(bang, query, mod) abort
    if !exists('*fzf#run')
        echohl ErrorMsg
        echom 'FZF installation not found'
        echohl None
        return
    endif

    let tags = map(taglist('.'), {_, v -> printf('%-40s %-10s %s', v.name, v.kind, fnamemodify(v.filename, ':.'))})
    let options = '--select-1 --no-multi --cycle'
    if !empty(a:query)
        let options .= ' --query=' . a:query
    endif

    call fzf#run(fzf#wrap('Tag', {
                \ 'source': tags,
                \ 'sink': {t -> s:tags(t, a:mod)},
                \ 'options': options,
                \ }, a:bang))
endfunction

function! s:tags(line, mod) abort
    let [tag, _, filename] = split(a:line)[0:2]
    let index = index(map(taglist('^' . tag . '$'), 'v:val.filename'), filename) + 1
    execute index . a:mod . 'tag ' . tag
endfunction