mirror of
https://github.com/junegunn/fzf.vim.git
synced 2025-12-07 05:04:30 +08:00
@@ -97,7 +97,10 @@ let g:fzf_action = {
|
||||
" - window (nvim only)
|
||||
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"'
|
||||
|
||||
" Advanced customization using autoload functions
|
||||
|
||||
@@ -352,15 +352,43 @@ endfunction
|
||||
" ------------------------------------------------------------------
|
||||
" 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)
|
||||
if len(a:lines) < 2
|
||||
return
|
||||
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], '')
|
||||
if !empty(cmd)
|
||||
execute 'silent' cmd
|
||||
endif
|
||||
execute 'buffer' matchstr(a:lines[1], '\[\zs[0-9]*\ze\]')
|
||||
execute 'buffer' b
|
||||
endfunction
|
||||
|
||||
function! s:format_buffer(b)
|
||||
@@ -693,8 +721,7 @@ endfunction
|
||||
|
||||
function! s:windows_sink(line)
|
||||
let list = matchlist(a:line, '\([ 0-9]*\):\([ 0-9]*\)')
|
||||
execute 'normal!' list[1].'gt'
|
||||
execute list[2].'wincmd w'
|
||||
call s:jump(list[1], list[2])
|
||||
endfunction
|
||||
|
||||
function! fzf#vim#windows(...)
|
||||
|
||||
Reference in New Issue
Block a user