Update documentation: fuzzy completion functions

This commit is contained in:
Junegunn Choi
2020-05-03 17:24:11 +09:00
parent 4cf475b753
commit 5b6f282d97
2 changed files with 49 additions and 25 deletions

View File

@@ -289,12 +289,9 @@ Mappings
| `<plug>(fzf-complete-word)` | `cat /usr/share/dict/words` | | `<plug>(fzf-complete-word)` | `cat /usr/share/dict/words` |
| `<plug>(fzf-complete-path)` | Path completion using `find` (file + dir) | | `<plug>(fzf-complete-path)` | Path completion using `find` (file + dir) |
| `<plug>(fzf-complete-file)` | File completion using `find` | | `<plug>(fzf-complete-file)` | File completion using `find` |
| `<plug>(fzf-complete-file-ag)` | File completion using `ag` |
| `<plug>(fzf-complete-line)` | Line completion (all open buffers) | | `<plug>(fzf-complete-line)` | Line completion (all open buffers) |
| `<plug>(fzf-complete-buffer-line)` | Line completion (current buffer only) | | `<plug>(fzf-complete-buffer-line)` | Line completion (current buffer only) |
### Usage
```vim ```vim
" Mapping selecting mappings " Mapping selecting mappings
nmap <leader><tab> <plug>(fzf-maps-n) nmap <leader><tab> <plug>(fzf-maps-n)
@@ -304,14 +301,30 @@ omap <leader><tab> <plug>(fzf-maps-o)
" Insert mode completion " Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word) imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path) imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line) imap <c-x><c-l> <plug>(fzf-complete-line)
" Advanced customization using Vim function
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'left': '15%'})
``` ```
### Completion helper Completion functions
--------------------
| Function | Description |
| --- | --- |
| `fzf#vim#complete#path(command, [spec])` | Path completion |
| `fzf#vim#complete#word([spec])` | Word completion |
| `fzf#vim#complete#line([spec])` | Line completion (all open buffers) |
| `fzf#vim#complete#buffer_line([spec])` | Line completion (current buffer only) |
```vim
" Path completion with custom source command
inoremap <expr> <c-x><c-j> fzf#vim#complete#path('fd')
inoremap <expr> <c-x><c-j> fzf#vim#complete#path('rg --files')
" Word completion with custom spec with popup layout option
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'window': { 'width': 0.2, 'height': 0.9, 'xoffset': 1 }})
```
Custom completion
-----------------
`fzf#vim#complete` is a helper function for creating custom fuzzy completion `fzf#vim#complete` is a helper function for creating custom fuzzy completion
using fzf. If the first parameter is a command string or a Vim list, it will using fzf. If the first parameter is a command string or a Vim list, it will
@@ -344,7 +357,7 @@ inoremap <expr> <c-x><c-l> fzf#vim#complete(fzf#wrap({
\ 'reducer': { lines -> join(split(lines[0], ':\zs')[2:], '') }})) \ 'reducer': { lines -> join(split(lines[0], ':\zs')[2:], '') }}))
``` ```
#### Reducer example ### Reducer example
```vim ```vim
function! s:make_sentence(lines) function! s:make_sentence(lines)

View File

@@ -1,4 +1,4 @@
fzf-vim.txt fzf-vim Last change: March 17 2020 fzf-vim.txt fzf-vim Last change: May 3 2020
FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-toc* FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-toc*
============================================================================== ==============================================================================
@@ -19,9 +19,9 @@ FZF-VIM - TABLE OF CONTENTS *fzf-vim* *fzf-vim-to
Example: Rg command with preview window Example: Rg command with preview window
Example: Advanced ripgrep integration Example: Advanced ripgrep integration
Mappings Mappings
Usage Completion functions
Completion helper Custom completion
Reducer example Reducer example
Status line of terminal buffer Status line of terminal buffer
Hide statusline Hide statusline
Custom statusline Custom statusline
@@ -350,14 +350,9 @@ MAPPINGS *fzf-vim-mappings*
<plug>(fzf-complete-word) | `cat/usr/share/dict/words` <plug>(fzf-complete-word) | `cat/usr/share/dict/words`
<plug>(fzf-complete-path) | Path completion using `find` (file + dir) <plug>(fzf-complete-path) | Path completion using `find` (file + dir)
<plug>(fzf-complete-file) | File completion using `find` <plug>(fzf-complete-file) | File completion using `find`
<plug>(fzf-complete-file-ag) | File completion using `ag`
<plug>(fzf-complete-line) | Line completion (all open buffers) <plug>(fzf-complete-line) | Line completion (all open buffers)
<plug>(fzf-complete-buffer-line) | Line completion (current buffer only) <plug>(fzf-complete-buffer-line) | Line completion (current buffer only)
---------------------------------+------------------------------------------ ---------------------------------+------------------------------------------
< Usage >_____________________________________________________________________~
*fzf-vim-usage*
> >
" Mapping selecting mappings " Mapping selecting mappings
nmap <leader><tab> <plug>(fzf-maps-n) nmap <leader><tab> <plug>(fzf-maps-n)
@@ -367,15 +362,31 @@ MAPPINGS *fzf-vim-mappings*
" Insert mode completion " Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word) imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path) imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line) imap <c-x><c-l> <plug>(fzf-complete-line)
" Advanced customization using Vim function
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'left': '15%'})
< <
< Completion helper >_________________________________________________________~ COMPLETION FUNCTIONS *fzf-vim-completion-functions*
*fzf-vim-completion-helper* ==============================================================================
-----------------------------------------+--------------------------------------
Function | Description ~
-----------------------------------------+--------------------------------------
`fzf#vim#complete#path(command,[spec])` | Path completion
`fzf#vim#complete#word([spec])` | Word completion
`fzf#vim#complete#line([spec])` | Line completion (all open buffers)
`fzf#vim#complete#buffer_line([spec])` | Line completion (current buffer only)
-----------------------------------------+--------------------------------------
>
" Path completion with custom source command
inoremap <expr> <c-x><c-j> fzf#vim#complete#path('fd')
inoremap <expr> <c-x><c-j> fzf#vim#complete#path('rg --files')
" Word completion with custom spec with popup layout option
inoremap <expr> <c-x><c-k> fzf#vim#complete#word({'window': { 'width': 0.2, 'height': 0.9, 'xoffset': 1 }})
<
CUSTOM COMPLETION *fzf-vim-custom-completion*
==============================================================================
`fzf#vim#complete` is a helper function for creating custom fuzzy completion `fzf#vim#complete` is a helper function for creating custom fuzzy completion
using fzf. If the first parameter is a command string or a Vim list, it will using fzf. If the first parameter is a command string or a Vim list, it will
@@ -405,7 +416,7 @@ following exceptions:
\ 'reducer': { lines -> join(split(lines[0], ':\zs')[2:], '') }})) \ 'reducer': { lines -> join(split(lines[0], ':\zs')[2:], '') }}))
< <
Reducer example~ < Reducer example >___________________________________________________________~
*fzf-vim-reducer-example* *fzf-vim-reducer-example*
> >
function! s:make_sentence(lines) function! s:make_sentence(lines)