mirror of
https://github.com/junegunn/fzf.vim.git
synced 2025-12-07 05:04:30 +08:00
[fzf#vim#grep[2]] Deprecate has_column argument
The boolean value tells the function if the output of the command contains column numbers, but we can just see the selected lines if they contain column numbers. The argument is now removed from the documentation, and will be silently ignored for backward compatibility. Close #1480
This commit is contained in:
61
README.md
61
README.md
@@ -165,16 +165,16 @@ let g:fzf_commands_expect = 'alt-enter,ctrl-x'
|
|||||||
Each command in fzf.vim is backed by a Vim function. You can override
|
Each command in fzf.vim is backed by a Vim function. You can override
|
||||||
a command or define a variation of it by calling its corresponding function.
|
a command or define a variation of it by calling its corresponding function.
|
||||||
|
|
||||||
| Command | Vim function |
|
| Command | Vim function |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `Files` | `fzf#vim#files(dir, [spec dict], [fullscreen bool])` |
|
| `Files` | `fzf#vim#files(dir, [spec dict], [fullscreen bool])` |
|
||||||
| `GFiles` | `fzf#vim#gitfiles(git_options, [spec dict], [fullscreen bool])` |
|
| `GFiles` | `fzf#vim#gitfiles(git_options, [spec dict], [fullscreen bool])` |
|
||||||
| `GFiles?` | `fzf#vim#gitfiles('?', [spec dict], [fullscreen bool])` |
|
| `GFiles?` | `fzf#vim#gitfiles('?', [spec dict], [fullscreen bool])` |
|
||||||
| `Buffers` | `fzf#vim#buffers([spec dict], [fullscreen bool])` |
|
| `Buffers` | `fzf#vim#buffers([spec dict], [fullscreen bool])` |
|
||||||
| `Colors` | `fzf#vim#colors([spec dict], [fullscreen bool])` |
|
| `Colors` | `fzf#vim#colors([spec dict], [fullscreen bool])` |
|
||||||
| `Rg` | `fzf#vim#grep(command, [has_column bool], [spec dict], [fullscreen bool])` |
|
| `Rg` | `fzf#vim#grep(command, [spec dict], [fullscreen bool])` |
|
||||||
| `RG` | `fzf#vim#grep2(command_prefix, query, [has_column bool], [spec dict], [fullscreen bool])` |
|
| `RG` | `fzf#vim#grep2(command_prefix, query, [spec dict], [fullscreen bool])` |
|
||||||
| ... | ... |
|
| ... | ... |
|
||||||
|
|
||||||
(We can see that the last two optional arguments of each function are
|
(We can see that the last two optional arguments of each function are
|
||||||
identical. They are directly passed to `fzf#wrap` function. If you haven't
|
identical. They are directly passed to `fzf#wrap` function. If you haven't
|
||||||
@@ -243,8 +243,6 @@ command! -bang -nargs=? -complete=dir Files
|
|||||||
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`.
|
||||||
|
|
||||||
- The second argument to `fzf#vim#grep` is 0 (false), because `git grep` does
|
|
||||||
not print column numbers.
|
|
||||||
- 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](bin/preview.sh) supports `grep` format
|
- [The preview script](bin/preview.sh) supports `grep` format
|
||||||
@@ -254,47 +252,10 @@ predefined `Ag` or `Rg` using `fzf#vim#grep`.
|
|||||||
```vim
|
```vim
|
||||||
command! -bang -nargs=* GGrep
|
command! -bang -nargs=* GGrep
|
||||||
\ call fzf#vim#grep(
|
\ call fzf#vim#grep(
|
||||||
\ 'git grep --line-number -- '.shellescape(<q-args>), 0,
|
\ 'git grep --line-number -- '.shellescape(<q-args>),
|
||||||
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
|
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Example: Advanced ripgrep integration
|
|
||||||
|
|
||||||
> The example shown here is now available as the `RG` (all uppercase) command
|
|
||||||
> that uses `fzf#vim#grep2(command_prefix, query, has_column, ...)` function.
|
|
||||||
> You no longer need to define it in your Vim configuration file.
|
|
||||||
|
|
||||||
In the default implementation of `Rg`, ripgrep process starts only once with
|
|
||||||
the initial query (e.g. `:Rg foo`) and fzf filters the output of the process.
|
|
||||||
|
|
||||||
This is okay in most cases because fzf is quite performant even with millions
|
|
||||||
of lines, but we can make fzf completely delegate its search responsibliity to
|
|
||||||
ripgrep process by making it restart ripgrep whenever the query string is
|
|
||||||
updated. In this scenario, fzf becomes a simple selector interface rather than
|
|
||||||
a "fuzzy finder".
|
|
||||||
|
|
||||||
- We will name the new command all-uppercase `RG` so we can still access the
|
|
||||||
default version.
|
|
||||||
- `--bind 'change:reload:rg ... {q}'` will make fzf restart ripgrep process
|
|
||||||
whenever the query string, denoted by `{q}`, is changed.
|
|
||||||
- With `--disabled` option, fzf will no longer perform search. The query
|
|
||||||
string you type on fzf prompt is only used for restarting ripgrep process.
|
|
||||||
- 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
|
|
||||||
function! RipgrepFzf(query, fullscreen)
|
|
||||||
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 reload_command = printf(command_fmt, '{q}')
|
|
||||||
let spec = {'options': ['--disabled', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
|
|
||||||
let spec = fzf#vim#with_preview(spec, 'right', 'ctrl-/')
|
|
||||||
call fzf#vim#grep(initial_command, 1, spec, a:fullscreen)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
|
|
||||||
```
|
|
||||||
|
|
||||||
Mappings
|
Mappings
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ let s:bin_dir = expand('<sfile>:p:h:h:h').'/bin/'
|
|||||||
let s:bin = {
|
let s:bin = {
|
||||||
\ 'preview': s:bin_dir.'preview.sh',
|
\ 'preview': s:bin_dir.'preview.sh',
|
||||||
\ 'tags': s:bin_dir.'tags.pl' }
|
\ 'tags': s:bin_dir.'tags.pl' }
|
||||||
let s:TYPE = {'dict': type({}), 'funcref': type(function('call')), 'string': type(''), 'list': type([])}
|
let s:TYPE = {'bool': type(0), 'dict': type({}), 'funcref': type(function('call')), 'string': type(''), 'list': type([])}
|
||||||
|
|
||||||
let s:wide = 120
|
let s:wide = 120
|
||||||
let s:checked = 0
|
let s:checked = 0
|
||||||
@@ -793,22 +793,22 @@ endfunction
|
|||||||
" ------------------------------------------------------------------
|
" ------------------------------------------------------------------
|
||||||
" Ag / Rg
|
" Ag / Rg
|
||||||
" ------------------------------------------------------------------
|
" ------------------------------------------------------------------
|
||||||
function! s:ag_to_qf(line, has_column)
|
function! s:ag_to_qf(line)
|
||||||
let parts = matchlist(a:line, '\(.\{-}\)\s*:\s*\(\d\+\)\%(\s*:\s*\(\d\+\)\)\?\%(\s*:\(.*\)\)\?')
|
let parts = matchlist(a:line, '\(.\{-}\)\s*:\s*\(\d\+\)\%(\s*:\s*\(\d\+\)\)\?\%(\s*:\(.*\)\)\?')
|
||||||
let dict = {'filename': &acd ? fnamemodify(parts[1], ':p') : parts[1], 'lnum': parts[2], 'text': parts[4]}
|
let dict = {'filename': &acd ? fnamemodify(parts[1], ':p') : parts[1], 'lnum': parts[2], 'text': parts[4]}
|
||||||
if a:has_column
|
if len(parts[3])
|
||||||
let dict.col = parts[3]
|
let dict.col = parts[3]
|
||||||
endif
|
endif
|
||||||
return dict
|
return dict
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:ag_handler(lines, has_column)
|
function! s:ag_handler(lines)
|
||||||
if len(a:lines) < 2
|
if len(a:lines) < 2
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let cmd = s:action_for(a:lines[0], 'e')
|
let cmd = s:action_for(a:lines[0], 'e')
|
||||||
let list = map(filter(a:lines[1:], 'len(v:val)'), 's:ag_to_qf(v:val, a:has_column)')
|
let list = map(filter(a:lines[1:], 'len(v:val)'), 's:ag_to_qf(v:val)')
|
||||||
if empty(list)
|
if empty(list)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -817,7 +817,7 @@ function! s:ag_handler(lines, has_column)
|
|||||||
try
|
try
|
||||||
call s:open(cmd, first.filename)
|
call s:open(cmd, first.filename)
|
||||||
execute first.lnum
|
execute first.lnum
|
||||||
if a:has_column
|
if has_key(first, 'col')
|
||||||
call cursor(0, first.col)
|
call cursor(0, first.col)
|
||||||
endif
|
endif
|
||||||
normal! zvzz
|
normal! zvzz
|
||||||
@@ -847,8 +847,9 @@ function! fzf#vim#ag_raw(command_suffix, ...)
|
|||||||
return call('fzf#vim#grep', extend(['ag --nogroup --column --color '.a:command_suffix, 1], a:000))
|
return call('fzf#vim#grep', extend(['ag --nogroup --column --color '.a:command_suffix, 1], a:000))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" command (string), has_column (bool), [spec (dict)], [fullscreen (bool)]
|
" command (string), [spec (dict)], [fullscreen (bool)]
|
||||||
function! fzf#vim#grep(grep_command, has_column, ...)
|
function! fzf#vim#grep(grep_command, ...)
|
||||||
|
let args = copy(a:000)
|
||||||
let words = []
|
let words = []
|
||||||
for word in split(a:grep_command)
|
for word in split(a:grep_command)
|
||||||
if word !~# '^[a-z]'
|
if word !~# '^[a-z]'
|
||||||
@@ -860,27 +861,31 @@ function! fzf#vim#grep(grep_command, has_column, ...)
|
|||||||
let name = join(words, '-')
|
let name = join(words, '-')
|
||||||
let capname = join(map(words, 'toupper(v:val[0]).v:val[1:]'), '')
|
let capname = join(map(words, 'toupper(v:val[0]).v:val[1:]'), '')
|
||||||
let opts = {
|
let opts = {
|
||||||
\ 'column': a:has_column,
|
|
||||||
\ '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
|
||||||
|
call remove(args, 0)
|
||||||
|
endif
|
||||||
|
|
||||||
function! opts.sink(lines)
|
function! opts.sink(lines)
|
||||||
return s:ag_handler(a:lines, self.column)
|
return s:ag_handler(a:lines)
|
||||||
endfunction
|
endfunction
|
||||||
let opts['sink*'] = remove(opts, 'sink')
|
let opts['sink*'] = remove(opts, 'sink')
|
||||||
try
|
try
|
||||||
let prev_default_command = $FZF_DEFAULT_COMMAND
|
let prev_default_command = $FZF_DEFAULT_COMMAND
|
||||||
let $FZF_DEFAULT_COMMAND = a:grep_command
|
let $FZF_DEFAULT_COMMAND = a:grep_command
|
||||||
return s:fzf(name, opts, a:000)
|
return s:fzf(name, opts, args)
|
||||||
finally
|
finally
|
||||||
let $FZF_DEFAULT_COMMAND = prev_default_command
|
let $FZF_DEFAULT_COMMAND = prev_default_command
|
||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" command_prefix (string), initial_query (string), has_column (bool), [spec (dict)], [fullscreen (bool)]
|
" command_prefix (string), initial_query (string), [spec (dict)], [fullscreen (bool)]
|
||||||
function! fzf#vim#grep2(command_prefix, query, has_column, ...)
|
function! fzf#vim#grep2(command_prefix, query, ...)
|
||||||
|
let args = copy(a:000)
|
||||||
let words = []
|
let words = []
|
||||||
for word in split(a:command_prefix)
|
for word in split(a:command_prefix)
|
||||||
if word !~# '^[a-z]'
|
if word !~# '^[a-z]'
|
||||||
@@ -892,7 +897,6 @@ function! fzf#vim#grep2(command_prefix, query, has_column, ...)
|
|||||||
let name = join(words, '-')
|
let name = join(words, '-')
|
||||||
let opts = {
|
let opts = {
|
||||||
\ 'source': ':',
|
\ 'source': ':',
|
||||||
\ 'column': a:has_column,
|
|
||||||
\ 'options': ['--ansi', '--prompt', toupper(name).'> ', '--query', a:query,
|
\ 'options': ['--ansi', '--prompt', toupper(name).'> ', '--query', a:query,
|
||||||
\ '--disabled',
|
\ '--disabled',
|
||||||
\ '--bind', 'start:reload:'.a:command_prefix.' '.shellescape(a:query),
|
\ '--bind', 'start:reload:'.a:command_prefix.' '.shellescape(a:query),
|
||||||
@@ -900,11 +904,14 @@ function! fzf#vim#grep2(command_prefix, query, has_column, ...)
|
|||||||
\ '--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
|
||||||
|
call remove(args, 0)
|
||||||
|
endif
|
||||||
function! opts.sink(lines)
|
function! opts.sink(lines)
|
||||||
return s:ag_handler(a:lines, self.column)
|
return s:ag_handler(a:lines)
|
||||||
endfunction
|
endfunction
|
||||||
let opts['sink*'] = remove(opts, 'sink')
|
let opts['sink*'] = remove(opts, 'sink')
|
||||||
return s:fzf(name, opts, a:000)
|
return s:fzf(name, opts, args)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" ------------------------------------------------------------------
|
" ------------------------------------------------------------------
|
||||||
|
|||||||
@@ -2,30 +2,29 @@ fzf-vim.txt fzf-vim Last change: June 4 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-vim-fzfheart-vim|
|
fzf :heart: vim |fzf-vim-fzfheart-vim|
|
||||||
Rationale |fzf-vim-rationale|
|
Rationale |fzf-vim-rationale|
|
||||||
Why you should use fzf on Vim |fzf-vim-why-you-should-use-fzf-on-vim|
|
Why you should use fzf on Vim |fzf-vim-why-you-should-use-fzf-on-vim|
|
||||||
Installation |fzf-vim-installation|
|
Installation |fzf-vim-installation|
|
||||||
Using vim-plug |fzf-vim-using-vim-plug|
|
Using vim-plug |fzf-vim-using-vim-plug|
|
||||||
Dependencies |fzf-vim-dependencies|
|
Dependencies |fzf-vim-dependencies|
|
||||||
Commands |fzf-vim-commands|
|
Commands |fzf-vim-commands|
|
||||||
Customization |fzf-vim-customization|
|
Customization |fzf-vim-customization|
|
||||||
Global options |fzf-vim-global-options|
|
Global options |fzf-vim-global-options|
|
||||||
Preview window |fzf-vim-preview-window|
|
Preview window |fzf-vim-preview-window|
|
||||||
Command-local options |fzf-vim-command-local-options|
|
Command-local options |fzf-vim-command-local-options|
|
||||||
Advanced customization |fzf-vim-advanced-customization|
|
Advanced customization |fzf-vim-advanced-customization|
|
||||||
Vim functions |fzf-vim-vim-functions|
|
Vim functions |fzf-vim-vim-functions|
|
||||||
Example: Customizing Files command |fzf-vim-example-customizing-files-command|
|
Example: Customizing Files command |fzf-vim-example-customizing-files-command|
|
||||||
Example: git grep wrapper |fzf-vim-example-git-grep-wrapper|
|
Example: git grep wrapper |fzf-vim-example-git-grep-wrapper|
|
||||||
Example: Advanced ripgrep integration |fzf-vim-example-advanced-ripgrep-integration|
|
Mappings |fzf-vim-mappings|
|
||||||
Mappings |fzf-vim-mappings|
|
Completion functions |fzf-vim-completion-functions|
|
||||||
Completion functions |fzf-vim-completion-functions|
|
Custom completion |fzf-vim-custom-completion|
|
||||||
Custom completion |fzf-vim-custom-completion|
|
Reducer example |fzf-vim-reducer-example|
|
||||||
Reducer example |fzf-vim-reducer-example|
|
Status line of terminal buffer |fzf-vim-status-line-of-terminal-buffer|
|
||||||
Status line of terminal buffer |fzf-vim-status-line-of-terminal-buffer|
|
Hide statusline |fzf-vim-hide-statusline|
|
||||||
Hide statusline |fzf-vim-hide-statusline|
|
Custom statusline |fzf-vim-custom-statusline|
|
||||||
Custom statusline |fzf-vim-custom-statusline|
|
License |fzf-vim-license|
|
||||||
License |fzf-vim-license|
|
|
||||||
|
|
||||||
FZF :HEART: VIM *fzf-vim-fzfheart-vim*
|
FZF :HEART: VIM *fzf-vim-fzfheart-vim*
|
||||||
==============================================================================
|
==============================================================================
|
||||||
@@ -237,18 +236,18 @@ Vim functions~
|
|||||||
Each command in fzf.vim is backed by a Vim function. You can override a
|
Each command in fzf.vim is backed by a Vim function. You can override a
|
||||||
command or define a variation of it by calling its corresponding function.
|
command or define a variation of it by calling its corresponding function.
|
||||||
|
|
||||||
----------+------------------------------------------------------------------------------------------
|
----------+-----------------------------------------------------------------------
|
||||||
Command | Vim function ~
|
Command | Vim function ~
|
||||||
----------+------------------------------------------------------------------------------------------
|
----------+-----------------------------------------------------------------------
|
||||||
`Files` | `fzf#vim#files(dir, [spec dict], [fullscreen bool])`
|
`Files` | `fzf#vim#files(dir, [spec dict], [fullscreen bool])`
|
||||||
`GFiles` | `fzf#vim#gitfiles(git_options, [spec dict], [fullscreen bool])`
|
`GFiles` | `fzf#vim#gitfiles(git_options, [spec dict], [fullscreen bool])`
|
||||||
`GFiles?` | `fzf#vim#gitfiles('?', [spec dict], [fullscreen bool])`
|
`GFiles?` | `fzf#vim#gitfiles('?', [spec dict], [fullscreen bool])`
|
||||||
`Buffers` | `fzf#vim#buffers([spec dict], [fullscreen bool])`
|
`Buffers` | `fzf#vim#buffers([spec dict], [fullscreen bool])`
|
||||||
`Colors` | `fzf#vim#colors([spec dict], [fullscreen bool])`
|
`Colors` | `fzf#vim#colors([spec dict], [fullscreen bool])`
|
||||||
`Rg` | `fzf#vim#grep(command, [has_column bool], [spec dict], [fullscreen bool])`
|
`Rg` | `fzf#vim#grep(command, [spec dict], [fullscreen bool])`
|
||||||
`RG` | `fzf#vim#grep2(command_prefix, query, [has_column bool], [spec dict], [fullscreen bool])`
|
`RG` | `fzf#vim#grep2(command_prefix, query, [spec dict], [fullscreen bool])`
|
||||||
... | ...
|
... | ...
|
||||||
----------+------------------------------------------------------------------------------------------
|
----------+-----------------------------------------------------------------------
|
||||||
|
|
||||||
(We can see that the last two optional arguments of each function are
|
(We can see that the last two optional arguments of each function are
|
||||||
identical. They are directly passed to `fzf#wrap` function. If you haven't
|
identical. They are directly passed to `fzf#wrap` function. If you haven't
|
||||||
@@ -322,49 +321,12 @@ predefined `Ag` or `Rg` using `fzf#vim#grep`.
|
|||||||
>
|
>
|
||||||
command! -bang -nargs=* GGrep
|
command! -bang -nargs=* GGrep
|
||||||
\ call fzf#vim#grep(
|
\ call fzf#vim#grep(
|
||||||
\ 'git grep --line-number -- '.shellescape(<q-args>), 0,
|
\ 'git grep --line-number -- '.shellescape(<q-args>),
|
||||||
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
|
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
|
||||||
<
|
<
|
||||||
{12} bin/preview.sh
|
{12} bin/preview.sh
|
||||||
|
|
||||||
|
|
||||||
Example: Advanced ripgrep integration~
|
|
||||||
*fzf-vim-example-advanced-ripgrep-integration*
|
|
||||||
|
|
||||||
The example shown here is now available as the `RG` (all uppercase) command
|
|
||||||
that uses `fzf#vim#grep2(command_prefix, query, has_column, ...)` function.
|
|
||||||
You no longer need to define it in your Vim configuration file.
|
|
||||||
|
|
||||||
In the default implementation of `Rg`, ripgrep process starts only once with
|
|
||||||
the initial query (e.g. `:Rg foo`) and fzf filters the output of the process.
|
|
||||||
|
|
||||||
This is okay in most cases because fzf is quite performant even with millions
|
|
||||||
of lines, but we can make fzf completely delegate its search responsibliity to
|
|
||||||
ripgrep process by making it restart ripgrep whenever the query string is
|
|
||||||
updated. In this scenario, fzf becomes a simple selector interface rather than
|
|
||||||
a "fuzzy finder".
|
|
||||||
|
|
||||||
- We will name the new command all-uppercase `RG` so we can still access the
|
|
||||||
default version.
|
|
||||||
- `--bind 'change:reload:rg ... {q}'` will make fzf restart ripgrep process
|
|
||||||
whenever the query string, denoted by `{q}`, is changed.
|
|
||||||
- With `--disabled` option, fzf will no longer perform search. The query string
|
|
||||||
you type on fzf prompt is only used for restarting ripgrep process.
|
|
||||||
- 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)
|
|
||||||
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 reload_command = printf(command_fmt, '{q}')
|
|
||||||
let spec = {'options': ['--disabled', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
|
|
||||||
let spec = fzf#vim#with_preview(spec, 'right', 'ctrl-/')
|
|
||||||
call fzf#vim#grep(initial_command, 1, spec, a:fullscreen)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
|
|
||||||
<
|
|
||||||
|
|
||||||
MAPPINGS *fzf-vim-mappings*
|
MAPPINGS *fzf-vim-mappings*
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ call s:defs([
|
|||||||
\'command! -bar -bang Colors call fzf#vim#colors(<bang>0)',
|
\'command! -bar -bang Colors call fzf#vim#colors(<bang>0)',
|
||||||
\'command! -bang -nargs=+ -complete=dir Locate call fzf#vim#locate(<q-args>, fzf#vim#with_preview(), <bang>0)',
|
\'command! -bang -nargs=+ -complete=dir Locate call fzf#vim#locate(<q-args>, fzf#vim#with_preview(), <bang>0)',
|
||||||
\'command! -bang -nargs=* Ag call fzf#vim#ag(<q-args>, fzf#vim#with_preview(), <bang>0)',
|
\'command! -bang -nargs=* Ag call fzf#vim#ag(<q-args>, fzf#vim#with_preview(), <bang>0)',
|
||||||
\'command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case -- ".shellescape(<q-args>), 1, fzf#vim#with_preview(), <bang>0)',
|
\'command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case -- ".shellescape(<q-args>), fzf#vim#with_preview(), <bang>0)',
|
||||||
\'command! -bang -nargs=* RG call fzf#vim#grep2("rg --column --line-number --no-heading --color=always --smart-case -- ", <q-args>, 1, fzf#vim#with_preview(), <bang>0)',
|
\'command! -bang -nargs=* RG call fzf#vim#grep2("rg --column --line-number --no-heading --color=always --smart-case -- ", <q-args>, fzf#vim#with_preview(), <bang>0)',
|
||||||
\'command! -bang -nargs=* Tags call fzf#vim#tags(<q-args>, fzf#vim#with_preview({ "placeholder": "--tag {2}:{-1}:{3..}" }), <bang>0)',
|
\'command! -bang -nargs=* Tags call fzf#vim#tags(<q-args>, fzf#vim#with_preview({ "placeholder": "--tag {2}:{-1}:{3..}" }), <bang>0)',
|
||||||
\'command! -bang -nargs=* BTags call fzf#vim#buffer_tags(<q-args>, fzf#vim#with_preview({ "placeholder": "{2}:{3..}" }), <bang>0)',
|
\'command! -bang -nargs=* BTags call fzf#vim#buffer_tags(<q-args>, fzf#vim#with_preview({ "placeholder": "{2}:{3..}" }), <bang>0)',
|
||||||
\'command! -bar -bang Snippets call fzf#vim#snippets(<bang>0)',
|
\'command! -bar -bang Snippets call fzf#vim#snippets(<bang>0)',
|
||||||
|
|||||||
Reference in New Issue
Block a user