Allow specifying command-level fzf options

Close #1583
This commit is contained in:
Junegunn Choi
2025-03-03 19:29:55 +09:00
parent f06bd1e69b
commit 245eaf8e50
3 changed files with 33 additions and 4 deletions

View File

@@ -183,6 +183,19 @@ 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,6 +340,10 @@ 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

View File

@@ -1,4 +1,4 @@
fzf-vim.txt fzf-vim Last change: October 29 2024 fzf-vim.txt fzf-vim Last change: March 3 2025
FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-toc* FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-toc*
============================================================================== ==============================================================================
@@ -14,6 +14,7 @@ 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|
@@ -228,7 +229,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 " [Buffers] Jump to the existing window if possible (default: 0)
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)
@@ -253,6 +254,19 @@ 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*
@@ -383,8 +397,6 @@ 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