mirror of
https://github.com/junegunn/fzf.vim.git
synced 2026-05-18 14:29:51 +08:00
Merge branch 'icholy-master'
This commit is contained in:
@@ -49,6 +49,7 @@ Commands
|
|||||||
| Command | List |
|
| Command | List |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `Files [PATH]` | Files (similar to `:FZF`) |
|
| `Files [PATH]` | Files (similar to `:FZF`) |
|
||||||
|
| `GitFiles` | Git files
|
||||||
| `Buffers` | Open buffers |
|
| `Buffers` | Open buffers |
|
||||||
| `Colors` | Color schemes |
|
| `Colors` | Color schemes |
|
||||||
| `Ag [PATTERN]` | [ag][ag] search result (`CTRL-A` to select all, `CTRL-D` to deselect all) |
|
| `Ag [PATTERN]` | [ag][ag] search result (`CTRL-A` to select all, `CTRL-D` to deselect all) |
|
||||||
@@ -173,6 +174,21 @@ inoremap <expr> <c-x><c-s> fzf#complete({
|
|||||||
\ 'left': 20})
|
\ 'left': 20})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Status line (neovim)
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
```vim
|
||||||
|
function! s:fzf_statusline()
|
||||||
|
" Override statusline as you like
|
||||||
|
highlight fzf1 ctermfg=161 ctermbg=251
|
||||||
|
highlight fzf2 ctermfg=23 ctermbg=251
|
||||||
|
highlight fzf3 ctermfg=237 ctermbg=251
|
||||||
|
setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
autocmd! User FzfStatusLine call <SID>fzf_statusline()
|
||||||
|
```
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|||||||
@@ -323,6 +323,24 @@ function! fzf#vim#history(...)
|
|||||||
\}, a:000)
|
\}, a:000)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" ------------------------------------------------------------------
|
||||||
|
" GitFiles
|
||||||
|
" ------------------------------------------------------------------
|
||||||
|
|
||||||
|
function! fzf#vim#gitfiles(...)
|
||||||
|
let root = systemlist('git rev-parse --show-toplevel')[0]
|
||||||
|
if v:shell_error
|
||||||
|
call s:warn('Not in git repo')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
call s:fzf({
|
||||||
|
\ 'source': 'git ls-tree --name-only -r HEAD',
|
||||||
|
\ 'dir': root,
|
||||||
|
\ 'sink*': s:function('s:common_sink'),
|
||||||
|
\ 'options': '--prompt "GitFiles> " -m'.s:expect(),
|
||||||
|
\}, a:000)
|
||||||
|
endfunction
|
||||||
|
|
||||||
" ------------------------------------------------------------------
|
" ------------------------------------------------------------------
|
||||||
" Buffers
|
" Buffers
|
||||||
" ------------------------------------------------------------------
|
" ------------------------------------------------------------------
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ COMMANDS *fzf-vim-commands*
|
|||||||
Command | List ~
|
Command | List ~
|
||||||
-----------------+---------------------------------------------------------------------
|
-----------------+---------------------------------------------------------------------
|
||||||
`Files [PATH]` | Files (similar to `:FZF` )
|
`Files [PATH]` | Files (similar to `:FZF` )
|
||||||
|
`GitFiles` | Git files
|
||||||
`Buffers` | Open buffers
|
`Buffers` | Open buffers
|
||||||
`Colors` | Color schemes
|
`Colors` | Color schemes
|
||||||
`Ag [PATTERN]` | {ag}{5} search result (CTRL-A to select all, CTRL-D to deselect all)
|
`Ag [PATTERN]` | {ag}{5} search result (CTRL-A to select all, CTRL-D to deselect all)
|
||||||
|
|||||||
+17
-11
@@ -43,6 +43,7 @@ endfunction
|
|||||||
|
|
||||||
call s:defs([
|
call s:defs([
|
||||||
\'command! -bang -nargs=? -complete=dir Files call fzf#vim#files(<q-args>, s:w(<bang>0))',
|
\'command! -bang -nargs=? -complete=dir Files call fzf#vim#files(<q-args>, s:w(<bang>0))',
|
||||||
|
\'command! -bang GitFiles call fzf#vim#gitfiles(s:w(<bang>0))',
|
||||||
\'command! -bang Buffers call fzf#vim#buffers(s:w(<bang>0))',
|
\'command! -bang Buffers call fzf#vim#buffers(s:w(<bang>0))',
|
||||||
\'command! -bang Lines call fzf#vim#lines(s:w(<bang>0))',
|
\'command! -bang Lines call fzf#vim#lines(s:w(<bang>0))',
|
||||||
\'command! -bang BLines call fzf#vim#buffer_lines(s:w(<bang>0))',
|
\'command! -bang BLines call fzf#vim#buffer_lines(s:w(<bang>0))',
|
||||||
@@ -79,14 +80,19 @@ endfunction
|
|||||||
|
|
||||||
if has('nvim') && get(g:, 'fzf_nvim_statusline', 1)
|
if has('nvim') && get(g:, 'fzf_nvim_statusline', 1)
|
||||||
function! s:fzf_restore_colors()
|
function! s:fzf_restore_colors()
|
||||||
if $TERM !~ "256color"
|
if exists('#User#FzfStatusLine')
|
||||||
highlight fzf1 ctermfg=1 ctermbg=8
|
doautocmd User FzfStatusLine
|
||||||
highlight fzf2 ctermfg=2 ctermbg=8
|
|
||||||
highlight fzf3 ctermfg=7 ctermbg=8
|
|
||||||
else
|
else
|
||||||
highlight fzf1 ctermfg=161 ctermbg=238
|
if $TERM !~ "256color"
|
||||||
highlight fzf2 ctermfg=151 ctermbg=238
|
highlight fzf1 ctermfg=1 ctermbg=8
|
||||||
highlight fzf3 ctermfg=252 ctermbg=238
|
highlight fzf2 ctermfg=2 ctermbg=8
|
||||||
|
highlight fzf3 ctermfg=7 ctermbg=8
|
||||||
|
else
|
||||||
|
highlight fzf1 ctermfg=161 ctermbg=238
|
||||||
|
highlight fzf2 ctermfg=151 ctermbg=238
|
||||||
|
highlight fzf3 ctermfg=252 ctermbg=238
|
||||||
|
endif
|
||||||
|
setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -96,13 +102,13 @@ if has('nvim') && get(g:, 'fzf_nvim_statusline', 1)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
setlocal nospell
|
setlocal nospell
|
||||||
setlocal statusline=%#fzf1#\ >\ %#fzf2#fz%#fzf3#f
|
call s:fzf_restore_colors()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
augroup fzf_statusline
|
augroup _fzf_statusline
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd TermOpen *bin/fzf* call s:fzf_nvim_term() | autocmd WinEnter <buffer> call s:fzf_nvim_term()
|
autocmd FileType fzf call s:fzf_nvim_term()
|
||||||
autocmd VimEnter,ColorScheme * call s:fzf_restore_colors()
|
\| autocmd WinEnter,ColorScheme <buffer> call s:fzf_restore_colors()
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user