2 Commits

Author SHA1 Message Date
Jeronimo Garcia
c16b8e38ef Merge d83bef041e into 556f45e79a 2024-11-22 04:59:13 +00:00
bechampion
d83bef041e Adding initial proposal for ignored files 2021-02-17 22:01:25 +00:00
5 changed files with 58 additions and 78 deletions

View File

@@ -1,3 +1,21 @@
<div align="center">
<sup>Special thanks to:</sup>
<br>
<br>
<a href="https://warp.dev/?utm_source=github&utm_medium=referral&utm_campaign=fzfvim_20240209">
<div>
<img src="https://raw.githubusercontent.com/junegunn/i/master/warp.png" width="300" alt="Warp">
</div>
<b>Warp is a modern, Rust-based terminal with AI built in so you and your team can build great software, faster.</b>
<div>
<sup>Visit warp.dev to learn more.</sup>
</div>
</a>
<br>
<hr>
</div>
<br>
fzf :heart: vim fzf :heart: vim
=============== ===============
@@ -79,7 +97,6 @@ Commands
| `:BTags [QUERY]` | Tags in the current buffer | | `:BTags [QUERY]` | Tags in the current buffer |
| `:Changes` | Changelist across all open buffers | | `:Changes` | Changelist across all open buffers |
| `:Marks` | Marks | | `:Marks` | Marks |
| `:BMarks` | Marks in the current buffer |
| `:Jumps` | Jumps | | `:Jumps` | Jumps |
| `:Windows` | Windows | | `:Windows` | Windows |
| `:Locate PATTERN` | `locate` command output | | `:Locate PATTERN` | `locate` command output |
@@ -184,19 +201,6 @@ let g:fzf_vim.tags_command = 'ctags -R'
let g:fzf_vim.commands_expect = 'alt-enter,ctrl-x' let g:fzf_vim.commands_expect = 'alt-enter,ctrl-x'
``` ```
#### Command-level fzf options
You can set fzf options for each command by setting
`g:fzf_vim.{command}_options`.
```vim
" In string
let g:fzf_vim.buffers_options = '--style full --border-label " Open Buffers "'
" In list (No need to quote or escape values)
let g:fzf_vim.buffers_options = ['--style', 'full', '--border-label', ' Open Buffers ']
```
#### List type to handle multiple selections #### List type to handle multiple selections
The following commands will fill the quickfix list when multiple entries are The following commands will fill the quickfix list when multiple entries are

View File

@@ -340,10 +340,6 @@ function! s:fzf(name, opts, extra)
let eopts = has_key(extra, 'options') ? remove(extra, 'options') : '' let eopts = has_key(extra, 'options') ? remove(extra, 'options') : ''
let merged = extend(copy(a:opts), extra) let merged = extend(copy(a:opts), extra)
call s:merge_opts(merged, eopts) call s:merge_opts(merged, eopts)
" Command-level fzf options
call s:merge_opts(merged, s:conf(a:name.'_options', []))
return fzf#run(s:wrap(a:name, merged, bang)) return fzf#run(s:wrap(a:name, merged, bang))
endfunction endfunction
@@ -369,7 +365,7 @@ function! s:action_for(key, ...)
" errors. e.g. E471: Argument required: tab drop " errors. e.g. E471: Argument required: tab drop
if !a:0 if !a:0
if !edit if !edit
call setpos("''", getpos('.')) normal! m'
silent! call s:execute_silent(cmd) silent! call s:execute_silent(cmd)
endif endif
else else
@@ -378,7 +374,7 @@ function! s:action_for(key, ...)
" instructed to stay on the current buffer. " instructed to stay on the current buffer.
let stay = edit && (a:0 > 1 && a:2 || fnamemodify(a:1, ':p') ==# expand('%:p')) let stay = edit && (a:0 > 1 && a:2 || fnamemodify(a:1, ':p') ==# expand('%:p'))
if !stay if !stay
call setpos("''", getpos('.')) normal! m'
call s:execute_silent((len(cmd) ? cmd : 'edit').' '.s:escape(a:1)) call s:execute_silent((len(cmd) ? cmd : 'edit').' '.s:escape(a:1))
endif endif
endif endif
@@ -425,8 +421,17 @@ endfunction
function! fzf#vim#_uniq(list) function! fzf#vim#_uniq(list)
let visited = {} let visited = {}
let ret = [] let ret = []
if exists("g:fzf_history_files_ignored") == 0
let g:fzf_history_files_ignored = []
endif
for l in a:list for l in a:list
if !empty(l) && !has_key(visited, l) let skip = 0
for i in g:fzf_history_files_ignored
if len(matchstr(l,i)) > 0
let skip=1
endif
endfor
if !empty(l) && !has_key(visited, l) && skip == 0
call add(ret, l) call add(ret, l)
let visited[l] = 1 let visited[l] = 1
endif endif
@@ -459,7 +464,7 @@ function! fzf#vim#files(dir, ...)
let dir = s:shortpath() let dir = s:shortpath()
endif endif
let args.options = ['--scheme', 'path', '-m', '--prompt', strwidth(dir) < &columns / 2 - 20 ? dir : '> '] let args.options = ['-m', '--prompt', strwidth(dir) < &columns / 2 - 20 ? dir : '> ']
call s:merge_opts(args, s:conf('files_options', [])) call s:merge_opts(args, s:conf('files_options', []))
return s:fzf('files', args, a:000) return s:fzf('files', args, a:000)
endfunction endfunction
@@ -669,8 +674,9 @@ function! s:history_sink(type, lines)
let key = a:lines[0] let key = a:lines[0]
let item = matchstr(a:lines[1], ' *[0-9]\+ *\zs.*') let item = matchstr(a:lines[1], ' *[0-9]\+ *\zs.*')
if key == 'ctrl-e' if key == 'ctrl-e'
call histadd(a:type, item)
redraw redraw
call feedkeys(a:type.item, 'nt') call feedkeys(a:type."\<up>", 'n')
else else
if a:type == ':' if a:type == ':'
call histadd(a:type, item) call histadd(a:type, item)
@@ -714,11 +720,8 @@ endfunction
" ------------------------------------------------------------------ " ------------------------------------------------------------------
function! s:get_git_root(dir) function! s:get_git_root(dir)
if empty(a:dir) && exists('*FugitiveWorkTree')
return FugitiveWorkTree()
endif
let dir = len(a:dir) ? a:dir : substitute(split(expand('%:p:h'), '[/\\]\.git\([/\\]\|$\)')[0], '^fugitive://', '', '') let dir = len(a:dir) ? a:dir : substitute(split(expand('%:p:h'), '[/\\]\.git\([/\\]\|$\)')[0], '^fugitive://', '', '')
silent let root = systemlist('git -C ' . shellescape(dir) . ' rev-parse --show-toplevel')[0] let root = systemlist('git -C ' . fzf#shellescape(dir) . ' rev-parse --show-toplevel')[0]
return v:shell_error ? '' : (len(a:dir) ? fnamemodify(a:dir, ':p') : root) return v:shell_error ? '' : (len(a:dir) ? fnamemodify(a:dir, ':p') : root)
endfunction endfunction
@@ -754,7 +757,7 @@ function! fzf#vim#gitfiles(args, ...)
return s:fzf('gfiles', { return s:fzf('gfiles', {
\ 'source': source, \ 'source': source,
\ 'dir': root, \ 'dir': root,
\ 'options': '--scheme path -m --read0 --prompt "GitFiles> "' \ 'options': '-m --read0 --prompt "GitFiles> "'
\}, a:000) \}, a:000)
endif endif
@@ -772,7 +775,7 @@ function! fzf#vim#gitfiles(args, ...)
let wrapped = fzf#wrap({ let wrapped = fzf#wrap({
\ 'source': prefix . '-c color.status=always status --short --untracked-files=all', \ 'source': prefix . '-c color.status=always status --short --untracked-files=all',
\ 'dir': root, \ 'dir': root,
\ 'options': ['--scheme', 'path', '--ansi', '--multi', '--nth', '2..,..', '--tiebreak=index', '--prompt', 'GitFiles?> ', '--preview', preview] \ 'options': ['--ansi', '--multi', '--nth', '2..,..', '--tiebreak=index', '--prompt', 'GitFiles?> ', '--preview', preview]
\}) \})
call s:remove_layout(wrapped) call s:remove_layout(wrapped)
let wrapped.common_sink = remove(wrapped, 'sink*') let wrapped.common_sink = remove(wrapped, 'sink*')
@@ -862,7 +865,7 @@ function! fzf#vim#buffers(...)
return s:fzf('buffers', { return s:fzf('buffers', {
\ 'source': map(sorted, 'fzf#vim#_format_buffer(v:val)'), \ 'source': map(sorted, 'fzf#vim#_format_buffer(v:val)'),
\ 'sink*': s:function('s:bufopen'), \ 'sink*': s:function('s:bufopen'),
\ 'options': ['+m', '-x', '--tiebreak=index', header_lines, '--ansi', '-d', '\t', '--with-nth', '3..', '-n', '2,1..2', '--prompt', 'Buf> ', '--query', query, '--preview-window', '+{2}/2', '--tabstop', tabstop] \ 'options': ['+m', '-x', '--tiebreak=index', header_lines, '--ansi', '-d', '\t', '--with-nth', '3..', '-n', '2,1..2', '--prompt', 'Buf> ', '--query', query, '--preview-window', '+{2}-/2', '--tabstop', tabstop]
\}, args) \}, args)
endfunction endfunction
@@ -971,7 +974,7 @@ function! fzf#vim#grep(grep_command, ...)
let opts = { let opts = {
\ 'options': ['--ansi', '--prompt', capname.'> ', \ 'options': ['--ansi', '--prompt', capname.'> ',
\ '--multi', '--bind', 'alt-a:select-all,alt-d:deselect-all', \ '--multi', '--bind', 'alt-a:select-all,alt-d:deselect-all',
\ '--delimiter', ':', '--preview-window', '+{2}/2'] \ '--delimiter', ':', '--preview-window', '+{2}-/2']
\} \}
if len(args) && type(args[0]) == s:TYPE.bool if len(args) && type(args[0]) == s:TYPE.bool
call remove(args, 0) call remove(args, 0)
@@ -1007,11 +1010,11 @@ function! fzf#vim#grep2(command_prefix, query, ...)
let name = join(words, '-') let name = join(words, '-')
let fallback = s:is_win ? '' : ' || :' let fallback = s:is_win ? '' : ' || :'
let opts = { let opts = {
\ 'source': s:is_win ? 'cd .' : ':', \ 'source': s:is_win ? 'cd .' : ':',
\ 'options': ['--ansi', '--prompt', toupper(name).'> ', '--query', a:query, \ 'options': ['--ansi', '--prompt', toupper(name).'> ', '--query', a:query,
\ '--disabled', \ '--disabled',
\ '--multi', '--bind', 'alt-a:select-all,alt-d:deselect-all', \ '--multi', '--bind', 'alt-a:select-all,alt-d:deselect-all',
\ '--delimiter', ':', '--preview-window', '+{2}/2'] \ '--delimiter', ':', '--preview-window', '+{2}-/2']
\} \}
let [opts, suffix] = s:grep_multi_line(opts) let [opts, suffix] = s:grep_multi_line(opts)
@@ -1088,7 +1091,7 @@ function! fzf#vim#buffer_tags(query, ...)
return s:fzf('btags', { return s:fzf('btags', {
\ 'source': s:btags_source(tag_cmds), \ 'source': s:btags_source(tag_cmds),
\ 'sink*': s:function('s:btags_sink'), \ 'sink*': s:function('s:btags_sink'),
\ 'options': s:reverse_list(['-m', '-d', '\t', '--with-nth', '1,4..', '-n', '1', '--prompt', 'BTags> ', '--query', a:query, '--preview-window', '+{3}/2'])}, args) \ 'options': s:reverse_list(['-m', '-d', '\t', '--with-nth', '1,4..', '-n', '1', '--prompt', 'BTags> ', '--query', a:query, '--preview-window', '+{3}-/2'])}, args)
catch catch
return s:warn(v:exception) return s:warn(v:exception)
endtry endtry
@@ -1235,9 +1238,9 @@ function! s:command_sink(lines)
endif endif
let cmd = matchstr(a:lines[1], s:tab.'\zs\S*\ze'.s:tab) let cmd = matchstr(a:lines[1], s:tab.'\zs\S*\ze'.s:tab)
if empty(a:lines[0]) if empty(a:lines[0])
call feedkeys(':'.cmd.(a:lines[1][0] == '!' ? '' : ' '), 'nt') call feedkeys(':'.cmd.(a:lines[1][0] == '!' ? '' : ' '), 'n')
else else
call feedkeys(':'.cmd."\<cr>", 'nt') call feedkeys(':'.cmd."\<cr>", 'n')
endif endif
endfunction endfunction
@@ -1361,25 +1364,15 @@ function! s:mark_sink(lines)
execute 'normal! `'.matchstr(a:lines[1], '\S').'zz' execute 'normal! `'.matchstr(a:lines[1], '\S').'zz'
endfunction endfunction
function! fzf#vim#marks(...) abort function! fzf#vim#marks(...)
let [initial_marks, extra] = (a:0 && type(a:1) == type('')) ?
\ [a:1, a:000[1:]] : ['', a:000]
redir => cout redir => cout
execute 'silent! marks' initial_marks silent marks
redir END redir END
let list = split(cout, "\n") let list = split(cout, "\n")
" If first line is not the expected header, no marks found
if empty(list) || list[0] =~# '^E'
return s:warn('No marks found')
endif
return s:fzf('marks', { return s:fzf('marks', {
\ 'source': extend(list[0:0], map(list[1:], 's:format_mark(v:val)')), \ 'source': extend(list[0:0], map(list[1:], 's:format_mark(v:val)')),
\ 'sink*': s:function('s:mark_sink'), \ 'sink*': s:function('s:mark_sink'),
\ 'options': '+m -x --ansi --tiebreak=index --header-lines 1 --tiebreak=begin --prompt "Marks> "'}, extra) \ 'options': '+m -x --ansi --tiebreak=index --header-lines 1 --tiebreak=begin --prompt "Marks> "'}, a:000)
endfunction endfunction
" ------------------------------------------------------------------ " ------------------------------------------------------------------
@@ -1429,9 +1422,9 @@ function! fzf#vim#jumps(...)
let s:jump_current = pos let s:jump_current = pos
let current = -pos-1 let current = -pos-1
return s:fzf('jumps', { return s:fzf('jumps', {
\ 'source': map(s:jumplist, 's:jump_format(v:val)'), \ 'source' : map(s:jumplist, 's:jump_format(v:val)'),
\ 'sink*': s:function('s:jump_sink'), \ 'sink*' : s:function('s:jump_sink'),
\ '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]+'], \ '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) \ }, a:000)
endfunction endfunction

View File

@@ -66,7 +66,7 @@ if [[ -z "$BATCAT" ]]; then
fi fi
fi fi
if [ -z "$FZF_PREVIEW_COMMAND" ] && [ "${BATCAT:+x}" ] && [[ ! -d "$FILE" ]] ; then if [ -z "$FZF_PREVIEW_COMMAND" ] && [ "${BATCAT:+x}" ]; then
${BATCAT} --style="${BAT_STYLE:-numbers}" --color=always --pager=never \ ${BATCAT} --style="${BAT_STYLE:-numbers}" --color=always --pager=never \
--highlight-line=$CENTER -- "$FILE" --highlight-line=$CENTER -- "$FILE"
exit $? exit $?
@@ -74,15 +74,12 @@ fi
FILE_LENGTH=${#FILE} FILE_LENGTH=${#FILE}
MIME=$(file --dereference --mime -- "$FILE") MIME=$(file --dereference --mime -- "$FILE")
if [[ "${MIME:FILE_LENGTH}" =~ binary ]] && [[ ! -d "$FILE" ]]; then if [[ "${MIME:FILE_LENGTH}" =~ binary ]]; then
echo "$MIME" echo "$MIME"
exit 0 exit 0
fi fi
DEFAULT_COMMAND="highlight -O ansi -l {} || coderay {} || rougify {} || cat {}" DEFAULT_COMMAND="highlight -O ansi -l {} || coderay {} || rougify {} || cat {}"
if [[ -d "$FILE" ]]; then
DEFAULT_COMMAND="tree -C -L2 {} || ls -l --color=always {}"
fi
CMD=${FZF_PREVIEW_COMMAND:-$DEFAULT_COMMAND} CMD=${FZF_PREVIEW_COMMAND:-$DEFAULT_COMMAND}
CMD=${CMD//{\}/"$(printf %q "$FILE")"} CMD=${CMD//{\}/"$(printf %q "$FILE")"}

View File

@@ -1,4 +1,4 @@
fzf-vim.txt fzf-vim Last change: June 8 2025 fzf-vim.txt fzf-vim Last change: October 29 2024
FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-toc* FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-toc*
============================================================================== ==============================================================================
@@ -14,7 +14,6 @@ FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-to
Configuration options for fzf.vim |fzf-vim-configuration-options-for-fzf-vim| Configuration options for fzf.vim |fzf-vim-configuration-options-for-fzf-vim|
Preview window |fzf-vim-preview-window| Preview window |fzf-vim-preview-window|
Command-level options |fzf-vim-command-level-options| Command-level options |fzf-vim-command-level-options|
Command-level fzf options |fzf-vim-command-level-fzf-options|
List type to handle multiple selections |fzf-vim-list-type-to-handle-multiple-selections| List type to handle multiple selections |fzf-vim-list-type-to-handle-multiple-selections|
Advanced customization |fzf-vim-advanced-customization| Advanced customization |fzf-vim-advanced-customization|
Vim functions |fzf-vim-vim-functions| Vim functions |fzf-vim-vim-functions|
@@ -110,8 +109,8 @@ COMMANDS *fzf-vim-commands*
============================================================================== ==============================================================================
*:Files* *:GFiles* *:Buffers* *:Colors* *:Ag* *:Rg* *:RG* *:Lines* *:BLines* *:Tags* *:BTags* *:Files* *:GFiles* *:Buffers* *:Colors* *:Ag* *:Rg* *:RG* *:Lines* *:BLines* *:Tags* *:BTags*
*:Changes* *:Marks* *:BMarks* *:Jumps* *:Windows* *:Locate* *:History* *:Snippets* *:Commits* *:Changes* *:Marks* *:Jumps* *:Windows* *:Locate* *:History* *:Snippets* *:Commits* *:BCommits*
*:BCommits* *:Commands* *:Maps* *:Helptags* *:Filetypes* *:Commands* *:Maps* *:Helptags* *:Filetypes*
-----------------------+-------------------------------------------------------------------------------------- -----------------------+--------------------------------------------------------------------------------------
Command | List ~ Command | List ~
@@ -130,7 +129,6 @@ COMMANDS *fzf-vim-commands*
`:BTags [QUERY]` | Tags in the current buffer `:BTags [QUERY]` | Tags in the current buffer
`:Changes` | Changelist across all open buffers `:Changes` | Changelist across all open buffers
`:Marks` | Marks `:Marks` | Marks
`:BMarks` | Marks in the current buffer
`:Jumps` | Jumps `:Jumps` | Jumps
`:Windows` | Windows `:Windows` | Windows
`:Locate PATTERN` | `locate` command output `:Locate PATTERN` | `locate` command output
@@ -230,7 +228,7 @@ Command-level options~
*g:fzf_vim.commands_expect* *g:fzf_vim.tags_command* *g:fzf_vim.commits_log_options* *g:fzf_vim.commands_expect* *g:fzf_vim.tags_command* *g:fzf_vim.commits_log_options*
*g:fzf_vim.buffers_jump* *g:fzf_vim.buffers_jump*
> >
" [Buffers] Jump to the existing window if possible (default: 0) " [Buffers] Jump to the existing window if possible
let g:fzf_vim.buffers_jump = 1 let g:fzf_vim.buffers_jump = 1
" [Ag|Rg|RG] Display path on a separate line for narrow screens (default: 0) " [Ag|Rg|RG] Display path on a separate line for narrow screens (default: 0)
@@ -255,19 +253,6 @@ Command-level options~
let g:fzf_vim.commands_expect = 'alt-enter,ctrl-x' let g:fzf_vim.commands_expect = 'alt-enter,ctrl-x'
< <
Command-level fzf options~
*fzf-vim-command-level-fzf-options*
You can set fzf options for each command by setting
`g:fzf_vim.{command}_options`.
>
" In string
let g:fzf_vim.buffers_options = '--style full --border-label " Open Buffers "'
" In list (No need to quote or escape values)
let g:fzf_vim.buffers_options = ['--style', 'full', '--border-label', ' Open Buffers ']
<
List type to handle multiple selections~ List type to handle multiple selections~
*fzf-vim-list-type-to-handle-multiple-selections* *fzf-vim-list-type-to-handle-multiple-selections*
@@ -398,6 +383,8 @@ Example: git grep wrapper~
The following example implements `GGrep` command that works similarly to The following example implements `GGrep` command that works similarly to
predefined `Ag` or `Rg` using `fzf#vim#grep`. predefined `Ag` or `Rg` using `fzf#vim#grep`.
*:LINE*
- We set the base directory to git root by setting `dir` attribute in spec - We set the base directory to git root by setting `dir` attribute in spec
dictionary. dictionary.
- {The preview script}{12} supports `grep` format (`FILE_PATH:LINE_NO:...`), so - {The preview script}{12} supports `grep` format (`FILE_PATH:LINE_NO:...`), so

View File

@@ -67,8 +67,7 @@ call s:defs([
\'command! -bar -bang Snippets call fzf#vim#snippets(<bang>0)', \'command! -bar -bang Snippets call fzf#vim#snippets(<bang>0)',
\'command! -bar -bang Commands call fzf#vim#commands(<bang>0)', \'command! -bar -bang Commands call fzf#vim#commands(<bang>0)',
\'command! -bar -bang Jumps call fzf#vim#jumps(fzf#vim#with_preview({ "placeholder": "{2..4}"}), <bang>0)', \'command! -bar -bang Jumps call fzf#vim#jumps(fzf#vim#with_preview({ "placeholder": "{2..4}"}), <bang>0)',
\'command! -bar -bang -nargs=* Marks call fzf#vim#marks(<q-args>, <bang>0)', \'command! -bar -bang Marks call fzf#vim#marks(<bang>0)',
\'command! -bar -bang -nargs=* BMarks call fzf#vim#marks("abcdefghijklmnopqrstuvwxyz", <bang>0)',
\'command! -bar -bang Changes call fzf#vim#changes(<bang>0)', \'command! -bar -bang Changes call fzf#vim#changes(<bang>0)',
\'command! -bar -bang Helptags call fzf#vim#helptags(fzf#vim#with_preview({ "placeholder": "--tag {2}:{3}:{4}" }), <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(fzf#vim#with_preview({ "placeholder": "{2}" }), <bang>0)', \'command! -bar -bang Windows call fzf#vim#windows(fzf#vim#with_preview({ "placeholder": "{2}" }), <bang>0)',