diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim index 25403f4..1983a25 100755 --- a/autoload/fzf/vim.vim +++ b/autoload/fzf/vim.vim @@ -1267,16 +1267,19 @@ function! s:commits(range, buffer_local, args) let managed = !v:shell_error endif + let args = copy(a:args) + let log_opts = len(args) && type(args[0]) == type('') ? remove(args, 0) : '' + if len(a:range) || a:buffer_local if !managed return s:warn('The current buffer is not in the working tree') endif let source .= len(a:range) - \ ? printf(' -L %d,%d:%s --no-patch', a:range[0], a:range[1], fzf#shellescape(current)) - \ : (' --follow '.fzf#shellescape(current)) + \ ? join([printf(' -L %d,%d:%s --no-patch', a:range[0], a:range[1], fzf#shellescape(current)), log_opts]) + \ : join([' --follow', log_opts, fzf#shellescape(current)]) let command = 'BCommits' else - let source .= ' --graph' + let source .= join([' --graph', log_opts]) let command = 'Commits' endif @@ -1303,7 +1306,7 @@ function! s:commits(range, buffer_local, args) \ ['--preview', 'echo {} | grep -o "[a-f0-9]\{7,\}" | head -1 | xargs ' . prefix . 'show -O'.fzf#shellescape(orderfile).' --format=format: --color=always ' . suffix]) endif - return s:fzf(a:buffer_local ? 'bcommits' : 'commits', options, a:args) + return s:fzf(a:buffer_local ? 'bcommits' : 'commits', options, args) endfunction " Heuristically determine if the user specified a range @@ -1320,6 +1323,7 @@ function! s:given_range(line1, line2) return [] endfunction +" [git-log-args], [spec (dict)], [fullscreen (bool)] function! fzf#vim#commits(...) range if exists('b:fzf_winview') call winrestview(b:fzf_winview) @@ -1328,6 +1332,7 @@ function! fzf#vim#commits(...) range return s:commits(s:given_range(a:firstline, a:lastline), 0, a:000) endfunction +" [git-log-args], [spec (dict)], [fullscreen (bool)] function! fzf#vim#buffer_commits(...) range if exists('b:fzf_winview') call winrestview(b:fzf_winview) diff --git a/plugin/fzf.vim b/plugin/fzf.vim index f7ae7d1..971076e 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -45,28 +45,28 @@ function! s:defs(commands) endfunction call s:defs([ -\'command! -bang -nargs=? -complete=dir Files call fzf#vim#files(, fzf#vim#with_preview(), 0)', -\'command! -bang -nargs=? GitFiles call fzf#vim#gitfiles(, fzf#vim#with_preview( == "?" ? { "placeholder": "" } : {}), 0)', -\'command! -bang -nargs=? GFiles call fzf#vim#gitfiles(, fzf#vim#with_preview( == "?" ? { "placeholder": "" } : {}), 0)', -\'command! -bar -bang -nargs=? -complete=buffer Buffers call fzf#vim#buffers(, fzf#vim#with_preview({ "placeholder": "{1}" }), 0)', -\'command! -bang -nargs=* Lines call fzf#vim#lines(, 0)', -\'command! -bang -nargs=* BLines call fzf#vim#buffer_lines(, 0)', -\'command! -bar -bang Colors call fzf#vim#colors(0)', -\'command! -bang -nargs=+ -complete=dir Locate call fzf#vim#locate(, fzf#vim#with_preview(), 0)', -\'command! -bang -nargs=* Ag call fzf#vim#ag(, fzf#vim#with_preview(), 0)', -\'command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case -- ".shellescape(), 1, fzf#vim#with_preview(), 0)', -\'command! -bang -nargs=* Tags call fzf#vim#tags(, fzf#vim#with_preview({ "placeholder": "--tag {2}:{-1}:{3..}" }), 0)', -\'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 Marks call fzf#vim#marks(0)', -\'command! -bar -bang Helptags call fzf#vim#helptags(fzf#vim#with_preview({ "placeholder": "--tag {2}:{3}:{4}" }), 0)', -\'command! -bar -bang Windows call fzf#vim#windows(0)', -\'command! -bar -bang -range=% Commits let b:fzf_winview = winsaveview() | ,call fzf#vim#commits(fzf#vim#with_preview({ "placeholder": "" }), 0)', -\'command! -bar -bang -range=% BCommits let b:fzf_winview = winsaveview() | ,call fzf#vim#buffer_commits(fzf#vim#with_preview({ "placeholder": "" }), 0)', -\'command! -bar -bang Maps call fzf#vim#maps("n", 0)', -\'command! -bar -bang Filetypes call fzf#vim#filetypes(0)', -\'command! -bang -nargs=* History call s:history(, fzf#vim#with_preview(), 0)']) +\'command! -bang -nargs=? -complete=dir Files call fzf#vim#files(, fzf#vim#with_preview(), 0)', +\'command! -bang -nargs=? GitFiles call fzf#vim#gitfiles(, fzf#vim#with_preview( == "?" ? { "placeholder": "" } : {}), 0)', +\'command! -bang -nargs=? GFiles call fzf#vim#gitfiles(, fzf#vim#with_preview( == "?" ? { "placeholder": "" } : {}), 0)', +\'command! -bar -bang -nargs=? -complete=buffer Buffers call fzf#vim#buffers(, fzf#vim#with_preview({ "placeholder": "{1}" }), 0)', +\'command! -bang -nargs=* Lines call fzf#vim#lines(, 0)', +\'command! -bang -nargs=* BLines call fzf#vim#buffer_lines(, 0)', +\'command! -bar -bang Colors call fzf#vim#colors(0)', +\'command! -bang -nargs=+ -complete=dir Locate call fzf#vim#locate(, fzf#vim#with_preview(), 0)', +\'command! -bang -nargs=* Ag call fzf#vim#ag(, fzf#vim#with_preview(), 0)', +\'command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case -- ".shellescape(), 1, fzf#vim#with_preview(), 0)', +\'command! -bang -nargs=* Tags call fzf#vim#tags(, fzf#vim#with_preview({ "placeholder": "--tag {2}:{-1}:{3..}" }), 0)', +\'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 Marks call fzf#vim#marks(0)', +\'command! -bar -bang Helptags call fzf#vim#helptags(fzf#vim#with_preview({ "placeholder": "--tag {2}:{3}:{4}" }), 0)', +\'command! -bar -bang Windows call fzf#vim#windows(0)', +\'command! -bar -bang -nargs=* -range=% -complete=file Commits let b:fzf_winview = winsaveview() | ,call fzf#vim#commits(, fzf#vim#with_preview({ "placeholder": "" }), 0)', +\'command! -bar -bang -nargs=* -range=% BCommits let b:fzf_winview = winsaveview() | ,call fzf#vim#buffer_commits(, fzf#vim#with_preview({ "placeholder": "" }), 0)', +\'command! -bar -bang Maps call fzf#vim#maps("n", 0)', +\'command! -bar -bang Filetypes call fzf#vim#filetypes(0)', +\'command! -bang -nargs=* History call s:history(, fzf#vim#with_preview(), 0)']) function! s:history(arg, extra, bang) let bang = a:bang || a:arg[len(a:arg)-1] == '!'