diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 5445de0f..7217703d 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -2,7 +2,8 @@ -- [ ] I have fzf 0.30.0 or above +- [ ] I have fzf 0.54.0 or above + - `:echo system(fzf#exec() .. ' --version')` - [ ] I have read through https://github.com/junegunn/fzf.vim/blob/master/README.md - [ ] I have read through https://github.com/junegunn/fzf/blob/master/README-VIM.md - [ ] I have read through the manual page of fzf (`man fzf`) diff --git a/README.md b/README.md index 59dfa352..35bdefc4 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ so you can omit it if you use a plugin manager that doesn't support hooks. ### Dependencies -- [fzf][fzf-main] 0.41.1 or above +- [fzf][fzf-main] 0.54.0 or above - For syntax-highlighted preview, install [bat](https://github.com/sharkdp/bat) - If [delta](https://github.com/dandavison/delta) is available, `GF?`, `Commits` and `BCommits` will use it to format `git diff` output. diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim index 79956ba4..440dbab2 100755 --- a/autoload/fzf/vim.vim +++ b/autoload/fzf/vim.vim @@ -1337,37 +1337,52 @@ endfunction " Jumps " ------------------------------------------------------------------ function! s:jump_format(line) - return substitute(a:line, '[0-9]\+', '\=s:yellow(submatch(0), "Number")', '') + let line = substitute(a:line, '[0-9]\+', '\=s:yellow(submatch(0), "Number")', '') + let line = substitute(line, '\s.\{-}\ze:[0-9]\+:', '\=s:green(submatch(0), "Directory")', '') + let line = substitute(line, '\%(:[0-9]\+\)\+:', '\=s:black(submatch(0), "NonText")', '') + return line endfunction function! s:jump_sink(lines) if len(a:lines) < 2 return endif - call s:action_for(a:lines[0]) - let idx = index(s:jumplist, a:lines[1]) - if idx == -1 - return - endif - let current = match(s:jumplist, '\v^\s*\>') - let delta = idx - current + keepjumps call s:action_for(a:lines[0]) + let idx = str2nr(a:lines[1]) + let delta = idx - s:jump_current - 1 if delta < 0 execute 'normal! ' . -delta . "\" else execute 'normal! ' . delta . "\" endif + normal! zvzz endfunction function! fzf#vim#jumps(...) - redir => cout - silent jumps - redir END - let s:jumplist = split(cout, '\n') - let current = -match(s:jumplist, '\v^\s*\>') + let [jumps, pos] = getjumplist() + if empty(jumps) + return s:warn('No jumps') + endif + let s:jumplist = [] + for idx in range(len(jumps)) + let jump = jumps[idx] + let loc = expand('#'.jump.bufnr.':p:~:.') + if empty(loc) + let loc = '[No Name]' + endif + let loc .= ':'.jump.lnum + if jump.col + let loc .= ':'.jump.col + endif + let line = printf('%-2d %s: %s', idx+1, loc, getbufoneline(jump.bufnr, jump.lnum)) + call add(s:jumplist, line) + endfor + let s:jump_current = pos + let current = -pos-1 return s:fzf('jumps', { - \ 'source' : extend(s:jumplist[0:0], map(s:jumplist[1:], 's:jump_format(v:val)')), + \ 'source' : map(s:jumplist, 's:jump_format(v:val)'), \ 'sink*' : s:function('s:jump_sink'), - \ 'options' : '+m -x --ansi --tiebreak=index --cycle --scroll-off 999 --sync --bind start:pos:'.current.' --tac --header-lines 1 --tiebreak=begin --prompt "Jumps> "', + \ 'options' : ['+m', '-x', '--ansi', '--tiebreak=index', '--cycle', '--scroll-off=999', '--sync', '--bind', 'start:pos('.current.')+offset-middle', '--tac', '--tiebreak=begin', '--prompt', 'Jumps> ', '--preview-window', '+{3}-/2', '--tabstop=2', '--delimiter', '[:\s]+'], \ }, a:000) endfunction diff --git a/bin/preview.sh b/bin/preview.sh index 8b23c628..a20e85a1 100755 --- a/bin/preview.sh +++ b/bin/preview.sh @@ -47,7 +47,9 @@ fi FILE="${FILE/#\~\//$HOME/}" if [ ! -r "$FILE" ]; then - echo "File not found ${FILE}" + if [[ "${INPUT[0]}" != '[No Name]' ]]; then + echo "File not found ${FILE}" + fi exit 1 fi diff --git a/doc/fzf-vim.txt b/doc/fzf-vim.txt index d0c36ffd..5f2f4c0f 100644 --- a/doc/fzf-vim.txt +++ b/doc/fzf-vim.txt @@ -85,7 +85,7 @@ so you can omit it if you use a plugin manager that doesn't support hooks. < Dependencies >______________________________________________________________~ *fzf-vim-dependencies* - - {fzf}{1} 0.41.1 or above + - {fzf}{1} 0.54.0 or above - For syntax-highlighted preview, install {bat}{4} - If {delta}{5} is available, `GF?`, `Commits` and `BCommits` will use it to format `git diff` output. diff --git a/plugin/fzf.vim b/plugin/fzf.vim index 622fb83e..2e036878 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -66,7 +66,7 @@ call s:defs([ \'command! -bang -nargs=* BTags call fzf#vim#buffer_tags(, fzf#vim#with_preview({ "placeholder": "{2}:{3..}" }), 0)', \'command! -bar -bang Snippets call fzf#vim#snippets(0)', \'command! -bar -bang Commands call fzf#vim#commands(0)', -\'command! -bar -bang Jumps call fzf#vim#jumps(0)', +\'command! -bar -bang Jumps call fzf#vim#jumps(fzf#vim#with_preview({ "placeholder": "{2..4}"}), 0)', \'command! -bar -bang Marks call fzf#vim#marks(0)', \'command! -bar -bang Changes call fzf#vim#changes(0)', \'command! -bar -bang Helptags call fzf#vim#helptags(fzf#vim#with_preview({ "placeholder": "--tag {2}:{3}:{4}" }), 0)',