[Windows] Add preview

Close #1487
This commit is contained in:
Junegunn Choi
2023-09-06 18:25:39 +09:00
parent 19dec6c038
commit 2c501dc5a2
3 changed files with 10 additions and 7 deletions

View File

@@ -1272,9 +1272,9 @@ endfunction
function! s:format_win(tab, win, buf)
let modified = getbufvar(a:buf, '&modified')
let name = bufname(a:buf)
let name = empty(name) ? '[No Name]' : name
let name = empty(name) ? s:nbs.s:nbs.'[No Name]' : ' '.s:nbs.name
let active = tabpagewinnr(a:tab) == a:win
return (active? s:blue('> ', 'Operator') : ' ') . name . (modified? s:red(' [+]', 'Exception') : '')
return (active? s:blue('>', 'Operator') : ' ') . name . s:nbs . (modified? s:red(' [+]', 'Exception') : '')
endfunction
function! s:windows_sink(line)
@@ -1295,9 +1295,9 @@ function! fzf#vim#windows(...)
endfor
endfor
return s:fzf('windows', {
\ 'source': extend(['Tab Win Name'], lines),
\ 'source': extend(['Tab Win Name'], lines),
\ 'sink': s:function('s:windows_sink'),
\ 'options': '+m --ansi --tiebreak=begin --header-lines=1'}, a:000)
\ 'options': '+m --ansi --tiebreak=begin --header-lines=1 -d'.s:nbs}, a:000)
endfunction
" ------------------------------------------------------------------

View File

@@ -3,17 +3,20 @@
REVERSE="\x1b[7m"
RESET="\x1b[m"
if [ -z "$1" ]; then
if [[ $# -lt 1 ]]; then
echo "usage: $0 [--tag] FILENAME[:LINENO][:IGNORED]"
exit 1
fi
if [ "$1" = --tag ]; then
if [[ $1 = --tag ]]; then
shift
"$(dirname "${BASH_SOURCE[0]}")/tagpreview.sh" "$@"
exit $?
fi
# Ignore if an empty path is given
[[ -z $1 ]] && exit
IFS=':' read -r -a INPUT <<< "$1"
FILE=${INPUT[0]}
CENTER=${INPUT[1]}

View File

@@ -69,7 +69,7 @@ call s:defs([
\'command! -bar -bang Jumps call fzf#vim#jumps(<bang>0)',
\'command! -bar -bang Marks call fzf#vim#marks(<bang>0)',
\'command! -bar -bang Helptags call fzf#vim#helptags(fzf#vim#with_preview({ "placeholder": "--tag {2}:{3}:{4}" }), <bang>0)',
\'command! -bar -bang Windows call fzf#vim#windows(<bang>0)',
\'command! -bar -bang Windows call fzf#vim#windows(fzf#vim#with_preview({ "placeholder": "{2}" }), <bang>0)',
\'command! -bar -bang -nargs=* -range=% -complete=file Commits let b:fzf_winview = winsaveview() | <line1>,<line2>call fzf#vim#commits(<q-args>, fzf#vim#with_preview({ "placeholder": "" }), <bang>0)',
\'command! -bar -bang -nargs=* -range=% BCommits let b:fzf_winview = winsaveview() | <line1>,<line2>call fzf#vim#buffer_commits(<q-args>, fzf#vim#with_preview({ "placeholder": "" }), <bang>0)',
\'command! -bar -bang Maps call fzf#vim#maps("n", <bang>0)',