fzf_changes_jumps.vim (1469B)
1 function s:GoTo(jumpline) 2 let values = split(a:jumpline, ":") 3 execute "e ".values[0] 4 call cursor(str2nr(values[1]), str2nr(values[2])) 5 execute "normal zvzz" 6 endfunction 7 8 function s:GetLine(bufnr, lnum) 9 let lines = getbufline(a:bufnr, a:lnum) 10 if len(lines)>0 11 return trim(lines[0]) 12 else 13 return '' 14 endif 15 endfunction 16 17 function! fzf_changes_jumps#Jumps() 18 " Get jumps with filename added 19 let jumps = map(reverse(copy(getjumplist()[0])), 20 \ { key, val -> extend(val, {'name': getbufinfo(val.bufnr)[0].name }) }) 21 22 let jumptext = map(copy(jumps), { index, val -> 23 \ (val.name).':'.(val.lnum).':'.(val.col+1).': '.s:GetLine(val.bufnr, val.lnum) }) 24 25 call fzf#run(fzf#vim#with_preview(fzf#wrap({ 26 \ 'source': jumptext, 27 \ 'column': 1, 28 \ 'options': ['--delimiter', ':', '--bind', 'alt-a:select-all,alt-d:deselect-all', '--preview-window', '+{2}-/2'], 29 \ 'sink': function('s:GoTo')}))) 30 endfunction 31 32 33 function! fzf_changes_jumps#Changes() 34 let changes = reverse(copy(getchangelist()[0])) 35 36 let changetext = map(copy(changes), { index, val -> 37 \ expand('%').':'.(val.lnum).':'.(val.col+1).': '.s:GetLine(bufnr('%'), val.lnum) }) 38 39 call fzf#run(fzf#vim#with_preview(fzf#wrap({ 40 \ 'source': changetext, 41 \ 'column': 1, 42 \ 'options': ['--delimiter', ':', '--bind', 'alt-a:select-all,alt-d:deselect-all', '--preview-window', '+{2}-/2'], 43 \ 'sink': function('s:GoTo')}))) 44 endfunction