mirror of
https://github.com/junegunn/fzf.vim.git
synced 2025-12-06 12:44:24 +08:00
Update RG example
This commit is contained in:
12
README.md
12
README.md
@@ -279,17 +279,19 @@ a "fuzzy finder".
|
|||||||
default version.
|
default version.
|
||||||
- `--bind 'change:reload:rg ... {q}'` will make fzf restart ripgrep process
|
- `--bind 'change:reload:rg ... {q}'` will make fzf restart ripgrep process
|
||||||
whenever the query string, denoted by `{q}`, is changed.
|
whenever the query string, denoted by `{q}`, is changed.
|
||||||
- With `--phony` option, fzf will no longer perform search. The query string
|
- With `--disabled` option, fzf will no longer perform search. The query
|
||||||
you type on fzf prompt is only used for restarting ripgrep process.
|
string you type on fzf prompt is only used for restarting ripgrep process.
|
||||||
- Also note that we enabled previewer with `fzf#vim#with_preview`.
|
- Also note that we enabled previewer with `fzf#vim#with_preview`. The last
|
||||||
|
argument to the function, `ctrl-/`, is the key to toggle the preview window.
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
function! RipgrepFzf(query, fullscreen)
|
function! RipgrepFzf(query, fullscreen)
|
||||||
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case -- %s || true'
|
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case -- %s || true'
|
||||||
let initial_command = printf(command_fmt, shellescape(a:query))
|
let initial_command = printf(command_fmt, shellescape(a:query))
|
||||||
let reload_command = printf(command_fmt, '{q}')
|
let reload_command = printf(command_fmt, '{q}')
|
||||||
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
|
let spec = {'options': ['--disabled', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
|
||||||
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
|
let spec = fzf#vim#with_preview(spec, 'right', 'ctrl-/')
|
||||||
|
call fzf#vim#grep(initial_command, 1, spec, a:fullscreen)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
|
command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
fzf-vim.txt fzf-vim Last change: May 24 2021
|
fzf-vim.txt fzf-vim Last change: January 8 2023
|
||||||
FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-toc*
|
FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-toc*
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
fzf :heart: vim
|
fzf :heart: vim |fzf-vim-fzfheart-vim|
|
||||||
Rationale
|
Rationale |fzf-vim-rationale|
|
||||||
Why you should use fzf on Vim
|
Why you should use fzf on Vim |fzf-vim-why-you-should-use-fzf-on-vim|
|
||||||
Installation
|
Installation |fzf-vim-installation|
|
||||||
Using vim-plug
|
Using vim-plug |fzf-vim-using-vim-plug|
|
||||||
Dependencies
|
Dependencies |fzf-vim-dependencies|
|
||||||
Commands
|
Commands |fzf-vim-commands|
|
||||||
Customization
|
Customization |fzf-vim-customization|
|
||||||
Global options
|
Global options |fzf-vim-global-options|
|
||||||
Preview window
|
Preview window |fzf-vim-preview-window|
|
||||||
Command-local options
|
Command-local options |fzf-vim-command-local-options|
|
||||||
Advanced customization
|
Advanced customization |fzf-vim-advanced-customization|
|
||||||
Vim functions
|
Vim functions |fzf-vim-vim-functions|
|
||||||
Example: Customizing Files command
|
Example: Customizing Files command |fzf-vim-example-customizing-files-command|
|
||||||
Example: git grep wrapper
|
Example: git grep wrapper |fzf-vim-example-git-grep-wrapper|
|
||||||
Example: Rg command with preview window
|
Example: Rg command with preview window |fzf-vim-example-rg-command-with-preview-window|
|
||||||
Example: Advanced ripgrep integration
|
Example: Advanced ripgrep integration |fzf-vim-example-advanced-ripgrep-integration|
|
||||||
Mappings
|
Mappings |fzf-vim-mappings|
|
||||||
Completion functions
|
Completion functions |fzf-vim-completion-functions|
|
||||||
Custom completion
|
Custom completion |fzf-vim-custom-completion|
|
||||||
Reducer example
|
Reducer example |fzf-vim-reducer-example|
|
||||||
Status line of terminal buffer
|
Status line of terminal buffer |fzf-vim-status-line-of-terminal-buffer|
|
||||||
Hide statusline
|
Hide statusline |fzf-vim-hide-statusline|
|
||||||
Custom statusline
|
Custom statusline |fzf-vim-custom-statusline|
|
||||||
License
|
License |fzf-vim-license|
|
||||||
|
|
||||||
FZF :HEART: VIM *fzf-vim-fzfheart-vim*
|
FZF :HEART: VIM *fzf-vim-fzfheart-vim*
|
||||||
==============================================================================
|
==============================================================================
|
||||||
@@ -39,11 +39,11 @@ Things you can do with {fzf}{1} and Vim.
|
|||||||
RATIONALE *fzf-vim-rationale*
|
RATIONALE *fzf-vim-rationale*
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
{fzf}{1} in itself is not a Vim plugin, and the official repository only
|
{fzf}{1} itself is not a Vim plugin, and the official repository only provides
|
||||||
provides the {basic wrapper function}{2} for Vim and it's up to the users to
|
the {basic wrapper function}{2} for Vim. It's up to the users to write their
|
||||||
write their own Vim commands with it. However, I've learned that many users of
|
own Vim commands with it. However, I've learned that many users of fzf are not
|
||||||
fzf are not familiar with Vimscript and are looking for the "default"
|
familiar with Vimscript and are looking for the "default" implementation of
|
||||||
implementation of the features they can find in the alternative Vim plugins.
|
the features they can find in the alternative Vim plugins.
|
||||||
|
|
||||||
This repository is a bundle of fzf-based commands and mappings extracted from
|
This repository is a bundle of fzf-based commands and mappings extracted from
|
||||||
my {.vimrc}{3} to address such needs. They are not designed to be flexible or
|
my {.vimrc}{3} to address such needs. They are not designed to be flexible or
|
||||||
@@ -112,9 +112,9 @@ COMMANDS *fzf-vim-commands*
|
|||||||
*:Windows* *:Locate* *:History* *:Snippets* *:Commits* *:BCommits* *:Commands* *:Maps*
|
*:Windows* *:Locate* *:History* *:Snippets* *:Commits* *:BCommits* *:Commands* *:Maps*
|
||||||
*:Helptags* *:Filetypes*
|
*:Helptags* *:Filetypes*
|
||||||
|
|
||||||
------------------+-----------------------------------------------------------------------
|
------------------+--------------------------------------------------------------------------------------
|
||||||
Command | List ~
|
Command | List ~
|
||||||
------------------+-----------------------------------------------------------------------
|
------------------+--------------------------------------------------------------------------------------
|
||||||
`:Files [PATH]` | Files (runs `$FZF_DEFAULT_COMMAND` if defined)
|
`:Files [PATH]` | Files (runs `$FZF_DEFAULT_COMMAND` if defined)
|
||||||
`:GFiles [OPTS]` | Git files ( `git ls-files` )
|
`:GFiles [OPTS]` | Git files ( `git ls-files` )
|
||||||
`:GFiles?` | Git files ( `git status` )
|
`:GFiles?` | Git files ( `git status` )
|
||||||
@@ -139,7 +139,7 @@ COMMANDS *fzf-vim-commands*
|
|||||||
`:Maps` | Normal mode mappings
|
`:Maps` | Normal mode mappings
|
||||||
`:Helptags` | Help tags [1]
|
`:Helptags` | Help tags [1]
|
||||||
`:Filetypes` | File types
|
`:Filetypes` | File types
|
||||||
------------------+-----------------------------------------------------------------------
|
------------------+--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
*g:fzf_command_prefix*
|
*g:fzf_command_prefix*
|
||||||
|
|
||||||
@@ -203,8 +203,8 @@ behavior with `g:fzf_preview_window`. Here are some examples:
|
|||||||
A few commands in fzf.vim can be customized with global option variables shown
|
A few commands in fzf.vim can be customized with global option variables shown
|
||||||
below.
|
below.
|
||||||
|
|
||||||
*g:fzf_buffers_jump* *g:fzf_commits_log_options* *g:fzf_tags_command*
|
*g:fzf_commands_expect* *g:fzf_tags_command* *g:fzf_commits_log_options*
|
||||||
*g:fzf_commands_expect*
|
*g:fzf_buffers_jump*
|
||||||
>
|
>
|
||||||
" [Buffers] Jump to the existing window if possible
|
" [Buffers] Jump to the existing window if possible
|
||||||
let g:fzf_buffers_jump = 1
|
let g:fzf_buffers_jump = 1
|
||||||
@@ -349,16 +349,18 @@ a "fuzzy finder".
|
|||||||
default version.
|
default version.
|
||||||
- `--bind 'change:reload:rg ... {q}'` will make fzf restart ripgrep process
|
- `--bind 'change:reload:rg ... {q}'` will make fzf restart ripgrep process
|
||||||
whenever the query string, denoted by `{q}`, is changed.
|
whenever the query string, denoted by `{q}`, is changed.
|
||||||
- With `--phony` option, fzf will no longer perform search. The query string you
|
- With `--disabled` option, fzf will no longer perform search. The query string
|
||||||
type on fzf prompt is only used for restarting ripgrep process.
|
you type on fzf prompt is only used for restarting ripgrep process.
|
||||||
- Also note that we enabled previewer with `fzf#vim#with_preview`.
|
- Also note that we enabled previewer with `fzf#vim#with_preview`. The last
|
||||||
|
argument to the function, `ctrl-/`, is the key to toggle the preview window.
|
||||||
>
|
>
|
||||||
function! RipgrepFzf(query, fullscreen)
|
function! RipgrepFzf(query, fullscreen)
|
||||||
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case -- %s || true'
|
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case -- %s || true'
|
||||||
let initial_command = printf(command_fmt, shellescape(a:query))
|
let initial_command = printf(command_fmt, shellescape(a:query))
|
||||||
let reload_command = printf(command_fmt, '{q}')
|
let reload_command = printf(command_fmt, '{q}')
|
||||||
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
|
let spec = {'options': ['--disabled', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
|
||||||
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
|
let spec = fzf#vim#with_preview(spec, 'right', 'ctrl-/')
|
||||||
|
call fzf#vim#grep(initial_command, 1, spec, a:fullscreen)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
|
command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
|
||||||
|
|||||||
Reference in New Issue
Block a user