mirror of
https://github.com/junegunn/fzf.vim.git
synced 2025-12-08 21:44:48 +08:00
@@ -97,7 +97,10 @@ let g:fzf_action = {
|
|||||||
" - window (nvim only)
|
" - window (nvim only)
|
||||||
let g:fzf_layout = { 'down': '~40%' }
|
let g:fzf_layout = { 'down': '~40%' }
|
||||||
|
|
||||||
" For Commits and BCommits to customize the options used by 'git log':
|
" [Buffers] Jump to the existing window if possible
|
||||||
|
let g:fzf_buffers_jump = 1
|
||||||
|
|
||||||
|
" [[B]Commits] to customize the options used by 'git log':
|
||||||
let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'
|
let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'
|
||||||
|
|
||||||
" Advanced customization using autoload functions
|
" Advanced customization using autoload functions
|
||||||
|
|||||||
@@ -352,15 +352,43 @@ endfunction
|
|||||||
" ------------------------------------------------------------------
|
" ------------------------------------------------------------------
|
||||||
" Buffers
|
" Buffers
|
||||||
" ------------------------------------------------------------------
|
" ------------------------------------------------------------------
|
||||||
|
function! s:find_open_window(b)
|
||||||
|
let [tcur, tcnt] = [tabpagenr() - 1, tabpagenr('$')]
|
||||||
|
for toff in range(0, tabpagenr('$') - 1)
|
||||||
|
let t = (tcur + toff) % tcnt + 1
|
||||||
|
let buffers = tabpagebuflist(t)
|
||||||
|
for w in range(1, len(buffers))
|
||||||
|
let b = buffers[w - 1]
|
||||||
|
if b == a:b
|
||||||
|
return [t, w]
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfor
|
||||||
|
return [0, 0]
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:jump(t, w)
|
||||||
|
execute 'normal!' a:t.'gt'
|
||||||
|
execute a:w.'wincmd w'
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:bufopen(lines)
|
function! s:bufopen(lines)
|
||||||
if len(a:lines) < 2
|
if len(a:lines) < 2
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
let b = matchstr(a:lines[1], '\[\zs[0-9]*\ze\]')
|
||||||
|
if empty(a:lines[0]) && get(g:, 'fzf_buffers_jump')
|
||||||
|
let [t, w] = s:find_open_window(b)
|
||||||
|
if t
|
||||||
|
call s:jump(t, w)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
endif
|
||||||
let cmd = get(get(g:, 'fzf_action', s:default_action), a:lines[0], '')
|
let cmd = get(get(g:, 'fzf_action', s:default_action), a:lines[0], '')
|
||||||
if !empty(cmd)
|
if !empty(cmd)
|
||||||
execute 'silent' cmd
|
execute 'silent' cmd
|
||||||
endif
|
endif
|
||||||
execute 'buffer' matchstr(a:lines[1], '\[\zs[0-9]*\ze\]')
|
execute 'buffer' b
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:format_buffer(b)
|
function! s:format_buffer(b)
|
||||||
@@ -693,8 +721,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:windows_sink(line)
|
function! s:windows_sink(line)
|
||||||
let list = matchlist(a:line, '\([ 0-9]*\):\([ 0-9]*\)')
|
let list = matchlist(a:line, '\([ 0-9]*\):\([ 0-9]*\)')
|
||||||
execute 'normal!' list[1].'gt'
|
call s:jump(list[1], list[2])
|
||||||
execute list[2].'wincmd w'
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! fzf#vim#windows(...)
|
function! fzf#vim#windows(...)
|
||||||
|
|||||||
Reference in New Issue
Block a user