GithubHelp home page GithubHelp logo

yuki-yano / fzf-preview.vim Goto Github PK

View Code? Open in Web Editor NEW
897.0 6.0 36.0 5.48 MB

The plugin that powerfully integrates fzf and (Neo)vim. It is also possible to integrate with coc.nvim.

License: MIT License

Perl 0.27% JavaScript 1.32% Shell 0.26% TypeScript 76.74% Vim Script 20.76% Lua 0.64%
vim neovim fzf remote-plugin coc-extensions fuzzy-finder

fzf-preview.vim's Introduction

logo

Build Release RPC Release remote plugin Release coc extensions

Support Support Language Language Lint with Styled with Tested with Powered by Powered by Powered by License Doc All contributors

fzf-preview is a (Neo)vim plugin and coc extension written in TypeScript that provide powerful integration with fzf. It provides multiple presets for fzf and correspondingly powerful preview functionality. It also provides advanced interactive git integration.

Since fzf-preview.vim implements RPC in the Vim script, it will work in both Vim and Neovim if you use the RPC release. It can also be installed as Remote Plugin and coc extensions. If you want to use the integration with coc, install coc extensions.

Introductory Article (Japanese)

This plugin can be easily extended in comparison to fzf.vim.

e.g. Fugitive(launch git commands), bdelete(delete a selected buffer from the buffer list)

TOC

Features

  1. Provides an excellent UI with floating windows by default
  2. Supports devicons and output highlighting by default
  3. Preview the selected item (with an arbitrary command)
  4. Fast file and buffer search by fuzzy matching
  5. Search all project files and history
  6. Search from file history files using oldfiles and mru
  7. Interactive git integration (with Fugitive or Gina)
  8. Jump lines from jumplist or changelist
  9. Interactive grep and preview from the current project
  10. Export the selected items to QuickFix.

Demo

Open file and :bdelete

fzf-preview

Interactive git integration (Integrate with Fugitive or Gina)

fzf-preview

Grep

fzf-preview

Export quickfix and refactor (with vim-qfreplace)

fzf-preview

Requirements

Remote Plugin

coc extensions

Optional

Functional

Appearance

When bat is installed you can highlight the preview and see it. Otherwise, head will be used

Installation

Vim script RPC

Use Dein, vim-plug or any Vim plugin manager of your choice.

Install release/rpc branch.

Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'yuki-yano/fzf-preview.vim', { 'branch': 'release/rpc' }

or

call dein#add('junegunn/fzf', { 'build': './install --all', 'merged': 0 })
call dein#add('yuki-yano/fzf-preview.vim', { 'rev': 'release/rpc' })

Remote Plugin

Install the npm package neovim to get the remote plugin working.

$ npm install -g neovim

Use Dein, vim-plug or any Vim plugin manager of your choice.

Install release/remote branch and execute :UpdateRemotePlugins when after installed plugin.

Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'yuki-yano/fzf-preview.vim', { 'branch': 'release/remote', 'do': ':UpdateRemotePlugins' }

or

call dein#add('junegunn/fzf', { 'build': './install --all', 'merged': 0 })
call dein#add('yuki-yano/fzf-preview.vim', { 'rev': 'release/remote' })

coc extensions

Install the fzf, coc.nvim and install coc-fzf-preview

Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
call dein#add('junegunn/fzf', { 'build': './install --all', 'merged': 0 })
call dein#add('neoclide/coc.nvim', { 'rev': 'release', 'merged': 0 })

and

:CocInstall coc-fzf-preview

Usage

Command

Vim script RPC, Remote Plugin, and coc extensions, in that order.

" Select project files
:FzfPreviewProjectFilesRpc
:FzfPreviewProjectFiles
:CocCommand fzf-preview.ProjectFiles

" Select file from git ls-files
:FzfPreviewGitFilesRpc
:FzfPreviewGitFiles
:CocCommand fzf-preview.GitFiles

" Select file from directory files (default to current working directory) (Required [ripgrep](https://github.com/BurntSushi/ripgrep))
:FzfPreviewDirectoryFilesRpc {path or none}
:FzfPreviewDirectoryFiles {path or none}
:CocCommand fzf-preview.DirectoryFiles

" Select file buffers. Used open-buffer processes.
:FzfPreviewBuffersRpc
:FzfPreviewBuffers
:CocCommand fzf-preview.Buffers

" Select all buffers. Used open-bufnr processes
:FzfPreviewAllBuffersRpc
:FzfPreviewAllBuffers
:CocCommand fzf-preview.AllBuffers

" Select project files from oldfiles
:FzfPreviewProjectOldFilesRpc
:CocCommand fzf-preview.ProjectOldFiles

" Select project mru (Most Recently Used) files
:FzfPreviewProjectMruFilesRpc
:FzfPreviewProjectMruFiles
:CocCommand fzf-preview.ProjectMruFiles

" Select project mrw (Most Recently Written) files
:FzfPreviewProjectMrwFilesRpc
:FzfPreviewProjectMrwFiles
:CocCommand fzf-preview.ProjectMrwFiles

" Grep project files from args word
:FzfPreviewProjectGrepRpc {args}
:FzfPreviewProjectGrep {args}
:CocCommand fzf-preview.ProjectGrep {args}

" Run FzfPreviewProjectGrep with the same arguments as before.
:FzfPreviewProjectGrepRecallRpc
:FzfPreviewProjectGrepRecall
:CocCommand fzf-preview.ProjectGrepRecall

" Select tags from tags file (Required [universal-ctags](https://github.com/universal-ctags/ctags))
:FzfPreviewCtagsRpc
:FzfPreviewCtags
:CocCommand fzf-preview.Ctags

" Select tags from current files (Required [universal-ctags](https://github.com/universal-ctags/ctags))
:FzfPreviewBufferTagsRpc
:FzfPreviewBufferTags
:CocCommand fzf-preview.BufferTags

" Select files from oldfiles
:FzfPreviewOldFilesRpc
:FzfPreviewOldFiles
:CocCommand fzf-preview.OldFiles

" Select mru (Most Recently Used) files
:FzfPreviewMruFilesRpc
:FzfPreviewMruFiles
:CocCommand fzf-preview.MruFiles

" Select mrw (Most Recently Written) files
:FzfPreviewMrwFilesRpc
:FzfPreviewMrwFiles
:CocCommand fzf-preview.MrwFiles

" Select line from QuickFix
:FzfPreviewQuickFixRpc
:FzfPreviewQuickFix
:CocCommand fzf-preview.QuickFix

" Select line from LocationList
:FzfPreviewLocationListRpc
:FzfPreviewLocationList
:CocCommand fzf-preview.LocationList

" Select line from current buffer (Required [bat](https://github.com/sharkdp/bat))
:FzfPreviewLinesRpc
:FzfPreviewLines
:CocCommand fzf-preview.Lines

" Select line from loaded buffer
:FzfPreviewBufferLinesRpc
:FzfPreviewBufferLines
:CocCommand fzf-preview.BufferLines

" Select jumplist item
:FzfPreviewJumpsRpc
:FzfPreviewJumps
:CocCommand fzf-preview.Jumps

" Select changelist item
:FzfPreviewChangesRpc
:FzfPreviewChanges
:CocCommand fzf-preview.Changes

" Select mark
:FzfPreviewMarksRpc
:CocCommand fzf-preview.Marks

" Select files from selected resources (project, git, directory, buffer, project_old, project_mru, project_mrw, old, mru, mrw)
:FzfPreviewFromResourcesRpc
:FzfPreviewFromResources
:CocCommand fzf-preview.FromResources

" Execute and edit command history
:FzfPreviewCommandPaletteRpc
:FzfPreviewCommandPalette
:CocCommand fzf-preview.CommandPalette

# Grep vim help
:FzfPreviewGrepHelpRpc
:FzfPreviewGrepHelp
:CocCommand fzf-preview.GrepHelp

" Interactive git integration. (Required [Fugitive](https://github.com/tpope/vim-fugitive) or [Gina](https://github.com/lambdalisue/gina.vim))
:FzfPreviewGitActionsRpc
:FzfPreviewGitActions
:CocCommand fzf-preview.GitActions

" Select git status listed file. (Required [Fugitive](https://github.com/tpope/vim-fugitive) or [Gina](https://github.com/lambdalisue/gina.vim))
:FzfPreviewGitStatusRpc
:FzfPreviewGitStatus
:CocCommand fzf-preview.GitStatus

" Select references from nvim-lsp
:FzfPreviewNvimLspReferencesRpc
:FzfPreviewNvimLspReferences

" Select diagnostics from nvim-lsp
:FzfPreviewNvimLspDiagnosticsRpc
:FzfPreviewNvimLspDiagnostics

" Select current file diagnostics from nvim-lsp
:FzfPreviewNvimLspCurrentDiagnosticsRpc
:FzfPreviewNvimLspCurrentDiagnostics

" Select definitions from nvim-lsp
:FzfPreviewNvimLspDefinitionRpc
:FzfPreviewNvimLspDefinition

" Select type definitions from nvim-lsp
:FzfPreviewNvimLspTypeDefinitionRpc
:FzfPreviewNvimLspTypeDefinition

" Select implementations from nvim-lsp
:FzfPreviewNvimLspImplementationsRpc
:FzfPreviewNvimLspImplementations

" Select references from vim-lsp
:FzfPreviewVimLspReferencesRpc
:FzfPreviewVimLspReferences

" Select diagnostics from vim-lsp
:FzfPreviewVimLspDiagnosticsRpc
:FzfPreviewVimLspDiagnostics

" Select current file diagnostics from vim-lsp
:FzfPreviewVimLspCurrentDiagnosticsRpc
:FzfPreviewVimLspCurrentDiagnostics

" Select definitions from vim-lsp
:FzfPreviewVimLspDefinitionRpc
:FzfPreviewVimLspDefinition

" Select type definitions from vim-lsp
:FzfPreviewVimLspTypeDefinitionRpc
:FzfPreviewVimLspTypeDefinition

" Select implementations from vim-lsp
:FzfPreviewVimLspImplementationsRpc
:FzfPreviewVimLspImplementations

" Select tags from vista.vim (Required [vista.vim](https://github.com/liuchengxu/vista.vim))
:FzfPreviewVistaCtagsRpc
:FzfPreviewVistaCtags
:CocCommand fzf-preview.VistaCtags

" Select current buffer tags from vista.vim (Required [vista.vim](https://github.com/liuchengxu/vista.vim))
:FzfPreviewVistaBufferCtagsRpc
:FzfPreviewVistaBufferCtags
:CocCommand fzf-preview.VistaBufferCtags

" Select bookmarks (Required [vim-bookmarks](https://github.com/MattesGroeger/vim-bookmarks))
:FzfPreviewBookmarksRpc
:FzfPreviewBookmarks
:CocCommand fzf-preview.Bookmarks

" Select register history (Required [yankround.vim](https://github.com/LeafCage/yankround.vim))
:FzfPreviewYankroundRpc
:FzfPreviewYankround
:CocCommand fzf-preview.Yankround

" Select memolist (Required [glidenote/memolist.vim](https://github.com/glidenote/memolist.vim))
:FzfPreviewMemoListRpc
:FzfPreviewMemoList
:CocCommand fzf-preview.MemoList

" Grep memolist (Required [glidenote/memolist.vim](https://github.com/glidenote/memolist.vim))
:FzfPreviewMemoListGrepRpc
:FzfPreviewMemoListGrep
:CocCommand fzf-preview.MemoListGrep

" Search TodoComments (Required  [folke/todo-comments.nvim](https://github.com/folke/todo-comments.nvim))
:FzfPreviewTodoCommentsRpc
:FzfPreviewTodoComments
:CocCommand fzf-preview.TodoComments

" Open the PR corresponding to the selected line (Required [GitHub cli](https://github.com/cli/cli))
:FzfPreviewBlamePRRpc
:FzfPreviewBlamePR
:CocCommand fzf-preview.BlamePR

" Select references from coc.nvim (only coc extensions)
:CocCommand fzf-preview.CocReferences

" Select diagnostics from coc.nvim (only coc extensions)
:CocCommand fzf-preview.CocDiagnostics

" Select current file diagnostics from coc.nvim (only coc extensions)
:CocCommand fzf-preview.CocCurrentDiagnostics

" Select definitions from coc.nvim (only coc extensions)
:CocCommand fzf-preview.CocDefinition

" Select type definitions from coc.nvim (only coc extensions)
:CocCommand fzf-preview.CocTypeDefinition

" Select implementations from coc.nvim (only coc extensions)
:CocCommand fzf-preview.CocImplementations

" Select outline from coc.nvim (only coc extensions)
:CocCommand fzf-preview.CocOutline

Recommended mappings

Vim script RPC

nmap <Leader>f [fzf-p]
xmap <Leader>f [fzf-p]

nnoremap <silent> [fzf-p]p     :<C-u>FzfPreviewFromResourcesRpc project_mru git<CR>
nnoremap <silent> [fzf-p]gs    :<C-u>FzfPreviewGitStatusRpc<CR>
nnoremap <silent> [fzf-p]ga    :<C-u>FzfPreviewGitActionsRpc<CR>
nnoremap <silent> [fzf-p]b     :<C-u>FzfPreviewBuffersRpc<CR>
nnoremap <silent> [fzf-p]B     :<C-u>FzfPreviewAllBuffersRpc<CR>
nnoremap <silent> [fzf-p]o     :<C-u>FzfPreviewFromResourcesRpc buffer project_mru<CR>
nnoremap <silent> [fzf-p]<C-o> :<C-u>FzfPreviewJumpsRpc<CR>
nnoremap <silent> [fzf-p]g;    :<C-u>FzfPreviewChangesRpc<CR>
nnoremap <silent> [fzf-p]/     :<C-u>FzfPreviewLinesRpc --add-fzf-arg=--no-sort --add-fzf-arg=--query="'"<CR>
nnoremap <silent> [fzf-p]*     :<C-u>FzfPreviewLinesRpc --add-fzf-arg=--no-sort --add-fzf-arg=--query="'<C-r>=expand('<cword>')<CR>"<CR>
nnoremap          [fzf-p]gr    :<C-u>FzfPreviewProjectGrepRpc<Space>
xnoremap          [fzf-p]gr    "sy:FzfPreviewProjectGrepRpc<Space>-F<Space>"<C-r>=substitute(substitute(@s, '\n', '', 'g'), '/', '\\/', 'g')<CR>"
nnoremap <silent> [fzf-p]t     :<C-u>FzfPreviewBufferTagsRpc<CR>
nnoremap <silent> [fzf-p]q     :<C-u>FzfPreviewQuickFixRpc<CR>
nnoremap <silent> [fzf-p]l     :<C-u>FzfPreviewLocationListRpc<CR>

Remote Plugin

nmap <Leader>f [fzf-p]
xmap <Leader>f [fzf-p]

nnoremap <silent> [fzf-p]p     :<C-u>FzfPreviewFromResources project_mru git<CR>
nnoremap <silent> [fzf-p]gs    :<C-u>FzfPreviewGitStatus<CR>
nnoremap <silent> [fzf-p]ga    :<C-u>FzfPreviewGitActions<CR>
nnoremap <silent> [fzf-p]b     :<C-u>FzfPreviewBuffers<CR>
nnoremap <silent> [fzf-p]B     :<C-u>FzfPreviewAllBuffers<CR>
nnoremap <silent> [fzf-p]o     :<C-u>FzfPreviewFromResources buffer project_mru<CR>
nnoremap <silent> [fzf-p]<C-o> :<C-u>FzfPreviewJumps<CR>
nnoremap <silent> [fzf-p]g;    :<C-u>FzfPreviewChanges<CR>
nnoremap <silent> [fzf-p]/     :<C-u>FzfPreviewLines --add-fzf-arg=--no-sort --add-fzf-arg=--query="'"<CR>
nnoremap <silent> [fzf-p]*     :<C-u>FzfPreviewLines --add-fzf-arg=--no-sort --add-fzf-arg=--query="'<C-r>=expand('<cword>')<CR>"<CR>
nnoremap          [fzf-p]gr    :<C-u>FzfPreviewProjectGrep<Space>
xnoremap          [fzf-p]gr    "sy:FzfPreviewProjectGrep<Space>-F<Space>"<C-r>=substitute(substitute(@s, '\n', '', 'g'), '/', '\\/', 'g')<CR>"
nnoremap <silent> [fzf-p]t     :<C-u>FzfPreviewBufferTags<CR>
nnoremap <silent> [fzf-p]q     :<C-u>FzfPreviewQuickFix<CR>
nnoremap <silent> [fzf-p]l     :<C-u>FzfPreviewLocationList<CR>

coc extensions

nmap <Leader>f [fzf-p]
xmap <Leader>f [fzf-p]

nnoremap <silent> [fzf-p]p     :<C-u>CocCommand fzf-preview.FromResources project_mru git<CR>
nnoremap <silent> [fzf-p]gs    :<C-u>CocCommand fzf-preview.GitStatus<CR>
nnoremap <silent> [fzf-p]ga    :<C-u>CocCommand fzf-preview.GitActions<CR>
nnoremap <silent> [fzf-p]b     :<C-u>CocCommand fzf-preview.Buffers<CR>
nnoremap <silent> [fzf-p]B     :<C-u>CocCommand fzf-preview.AllBuffers<CR>
nnoremap <silent> [fzf-p]o     :<C-u>CocCommand fzf-preview.FromResources buffer project_mru<CR>
nnoremap <silent> [fzf-p]<C-o> :<C-u>CocCommand fzf-preview.Jumps<CR>
nnoremap <silent> [fzf-p]g;    :<C-u>CocCommand fzf-preview.Changes<CR>
nnoremap <silent> [fzf-p]/     :<C-u>CocCommand fzf-preview.Lines --add-fzf-arg=--no-sort --add-fzf-arg=--query="'"<CR>
nnoremap <silent> [fzf-p]*     :<C-u>CocCommand fzf-preview.Lines --add-fzf-arg=--no-sort --add-fzf-arg=--query="'<C-r>=expand('<cword>')<CR>"<CR>
nnoremap          [fzf-p]gr    :<C-u>CocCommand fzf-preview.ProjectGrep<Space>
xnoremap          [fzf-p]gr    "sy:CocCommand   fzf-preview.ProjectGrep<Space>-F<Space>"<C-r>=substitute(substitute(@s, '\n', '', 'g'), '/', '\\/', 'g')<CR>"
nnoremap <silent> [fzf-p]t     :<C-u>CocCommand fzf-preview.BufferTags<CR>
nnoremap <silent> [fzf-p]q     :<C-u>CocCommand fzf-preview.QuickFix<CR>
nnoremap <silent> [fzf-p]l     :<C-u>CocCommand fzf-preview.LocationList<CR>

Base Fzf window Keymaps

<C-g>, <Esc>
  Cancel fzf

<C-x>
  Open split

<C-v>
  Open vsplit

<C-t>
  Open tabedit

<C-o>
  Jump to buffer if already open. See :drop.
  If g:fzf_preview_buffers_jump is set to 1 then it will open the buffer in
  current window instead.

<C-q>
  Build QuickFix in open-file processes.
  Execute :bdelete! command from open-buffer and open-bufnr processes.

<C-d>
  Preview page down

<C-u>
  Preview page up

?
  Toggle display of preview screen

Customization

Optional Configuration Tips

  • Increase the size of file history:
" oldfiles uses viminfo, but the default setting is 100
" Change the number by setting it in viminfo with a single quote.
" Ref: viminfo-'
set viminfo='1000
  • Set values for each variable. The default settings are as follows.
" floating window size ratio
let g:fzf_preview_floating_window_rate = 0.9

" fzf window position settings
let g:fzf_preview_direct_window_option = ''

" fzf command default options
let g:fzf_preview_default_fzf_options = { '--reverse': v:true, '--preview-window': 'wrap' }

" Add fzf quit mapping
let g:fzf_preview_quit_map = 1

" jump to the buffers by default, when possible
let g:fzf_preview_buffers_jump = 0

" Commands used for fzf preview.
" The file name selected by fzf becomes {}
let g:fzf_preview_command = 'cat'                               " Not installed bat
" let g:fzf_preview_command = 'bat --color=always --plain {-1}' " Installed bat

" g:fzf_binary_preview_command is executed if this command succeeds, and g:fzf_preview_command is executed if it fails
let g:fzf_preview_if_binary_command = '[[ "$(file --mime {})" =~ binary ]]'

" Commands used for binary file
let g:fzf_binary_preview_command = 'echo "{} is a binary file"'

" Commands used to get the file list from project
let g:fzf_preview_filelist_command = 'git ls-files --exclude-standard'               " Not Installed ripgrep
" let g:fzf_preview_filelist_command = 'rg --files --hidden --follow --no-messages -g \!"* *"' " Installed ripgrep

" Commands used to get the file list from git repository
let g:fzf_preview_git_files_command = 'git ls-files --exclude-standard'

" Commands used to get the file list from current directory
let g:fzf_preview_directory_files_command = 'rg --files --hidden --follow --no-messages -g \!"* *"'

" Commands used to get the git status file list
let g:fzf_preview_git_status_command = 'git -c color.status=always status --short --untracked-files=all'

" Commands used for git status preview.
let g:fzf_preview_git_status_preview_command =  "[[ $(git diff --cached -- {-1}) != \"\" ]] && git diff --cached --color=always -- {-1} || " .
\ "[[ $(git diff -- {-1}) != \"\" ]] && git diff --color=always -- {-1} || " .
\ g:fzf_preview_command

" Commands used for project grep
let g:fzf_preview_grep_cmd = 'rg --line-number --no-heading --color=never --hidden'

" MRU and MRW cache directory
let g:fzf_preview_cache_directory = expand('~/.cache/vim/fzf_preview')

" If this value is not 0, disable mru and mrw
let g:fzf_preview_disable_mru = 0

" Limit of the number of files to be saved by mru
let g:fzf_preview_mru_limit = 1000

" Commands used for current file lines
let g:fzf_preview_lines_command = 'cat -n'                                " Not Installed bat
" let g:fzf_preview_lines_command = 'bat --color=always --plain --number' " Installed bat

" Commands used for preview of the grep result
let g:fzf_preview_grep_preview_cmd = expand('<sfile>:h:h') . '/bin/preview_fzf_grep'

" Cache directory for mru and mrw
let g:fzf_preview_cache_directory = expand('~/.cache/vim/fzf_preview')

" Keyboard shortcuts while fzf preview is active
let g:fzf_preview_preview_key_bindings = ''
" let g:fzf_preview_preview_key_bindings = 'ctrl-d:preview-page-down,ctrl-u:preview-page-up,?:toggle-preview'

" Specify the color of fzf
let g:fzf_preview_fzf_color_option = ''

" Set the processes when selecting an element with fzf
let g:fzf_preview_custom_processes = {}
" For example, set split to ctrl-s
" let g:fzf_preview_custom_processes['open-file'] = fzf_preview#remote#process#get_default_processes('open-file')
" on coc extensions
" let g:fzf_preview_custom_processes['open-file'] = fzf_preview#remote#process#get_default_processes('open-file', 'coc')
" let g:fzf_preview_custom_processes['open-file']['ctrl-s'] = g:fzf_preview_custom_processes['open-file']['ctrl-x']
" call remove(g:fzf_preview_custom_processes['open-file'], 'ctrl-x')

" Use as fzf preview-window option
let g:fzf_preview_fzf_preview_window_option = ''
" let g:fzf_preview_fzf_preview_window_option = 'up:30%'

" Use vim-devicons
let g:fzf_preview_use_dev_icons = 0

" Use fzf history option
let g:fzf_preview_history_dir = false
" let g:fzf_preview_history_dir = '~/.fzf'

" devicons character width
let g:fzf_preview_dev_icon_prefix_string_length = 3

" Devicons can make fzf-preview slow when the number of results is high
" By default icons are disable when number of results is higher that 5000
let g:fzf_preview_dev_icons_limit = 5000

" The theme used in the bat preview
$FZF_PREVIEW_PREVIEW_BAT_THEME = 'OneHalfDark'

Command Options

Commented-out lines are settings for the coc extension.

--processes
" Set process when selecting element with fzf started by this command.
" Value must be a global variable name.
" Variable is dictionary and format is same as g:fzf_preview_custom_processes['open-file'].
"
" Most commands are passed a file path to the process function.
" FzfPreviewAllBuffers will be passed “buffer {bufnr}”
"
" Value example: let g:foo_processes = {
"                \ '':       'FzfPreviewOpenFileEnter',
"                \ 'ctrl-x': get(function('s:foo_function'), 'name'),
"                \ }
"

--add-fzf-arg
" Set the arguments to be passed when executing fzf.
" This value is added to the default options.
" Value must be a string without spaces.

" Example: Exclude filename with FzfPreviewProjectGrep
nnoremap <Leader>g :<C-u>FzfPreviewProjectGrep --add-fzf-arg=--nth=3<Space>
" nnoremap <Leader>g :<C-u>CocCommand fzf-preview.ProjectGrep --add-fzf-arg=--nth=3<Space>


--resume
" Reuse the input that was last used to select the element with fzf.
" Do not need to pass a value for this option.

" Example: Reuse last query for project grep.
nnoremap <Leader>G :<C-u>FzfPreviewProjectGrep . --resume<Space>
" nnoremap <Leader>G :<C-u>CocCommand fzf-preview.ProjectGrep . --resume<Space>

Function

" Get the initial value of the open file processes
" processes_name is 'open-file', 'open-buffer' and 'open-bufnr'.
" plugin_type is 'remote', 'coc' or 'rpc'. Default value is 'remote'
call fzf_preview#remote#process#get_default_processes({processes_name}, {plugin_type})

Release note

Changes history
  • 2023/01/02 version 2.16.0

    • Implement nvim-lsp resources.
  • 2021/12/05 version 2.12.0

    • Implement vim-lsp resources.
  • 2022/08/23 version 2.13.0

    • Implement coc TypeScript go to source definition resource.
  • 2021/12/05 version 2.12.0

    • Implement vim-lsp resources.
  • 2021/10/15 version 2.9.0

    • Implement coc outline resource.
  • 2021/09/10 version 2.7.0

    • Implement vim help resource.
  • 2021/09/08 version 2.6.0

    • Improve project files performance
  • 2021/06/06 version 2.5.0

    • Implement --experimental-fast option.
  • 2021/06/04 version 2.4.0

  • 2021/05/19 version 2.3.0

    • Implement fzf history option.
  • 2021/05/18 version 2.2.0

    • Implement grep recall.
  • 2021/01/16 version 2.0.7

    • Implement coc implementations resource.
  • 2021/01/16 version 2.0.6

  • 2021/01/10 version 2.0.0

    • Release of stable version.
    • Change release from github actions.
    • Update latest npm packages.
  • 2021/01/06 version 0.6.0

    • Update coc.nvim package version to 0.0.80.
  • 2020/12/31 version 0.5.0

    • Implement Vim script RPC
      • Only need Vim and Node
    • Breaking change: The release branch of the Remote Plugin has been changed to release/remote.
  • 2020/11/08 version 0.4.27

    • Add g:fzf_preview_direct_window_option option.
  • 2020/11/07 version 0.4.26

    • Change buffer sort with mru order.
    • Add mru and mrw limit settings.
    • Improve grep preview highlight.
  • 2020/10/30 version 0.4.24

    • Improved grep etc previews to scroll to the top of the file.
  • 2020/10/4 version 0.4.20

    • Implement CommandPalette resource.
  • 2020/10/4 version 0.4.17

    • Implement CocTypeDefinitions resource.
  • 2020/07/30 version 0.4.7

    • Implement git reflog integration.
  • 2020/07/30 version 0.4.6

    • Implement git stash integration.
    • Implement rename git branch.
  • 2020/07/27 version 0.4.1

    • Implement create git branch.
  • 2020/07/27 version 0.4.0

    • Implement interactive git integration. (:FzfPreviewGitActions and :CocCommand fzf-preview.GitActions)
  • 2020/07/24 version 0.3.2

    • Remove g:fzf_preview_filelist_postprocess_command and to colorize the fzf window by default
  • 2020/07/24 version 0.2.1

    • Change g:fzf_preview_default_fzf_options and g:fzf_preview_fzf_preview_window_option default value.
    • Fix export quickfix bug in grep.
  • 2020/07/23 version 0.2.0

    • Improving the internal data structure.
    • Remove FzfPreviewProjectCommandGrep command. (Changes to the data structure have made implementation difficult)
    • Some bug fixes.

Others

  • How to use fish user?
    • Set the set shell and $SHELL.
set shell=/bin/zsh
let $SHELL = "/bin/zsh"
  • Use true color preview in Neovim
    • Set the preview command to COLORTERM=truecolor
augroup fzf_preview
  autocmd!
  autocmd User fzf_preview#rpc#initialized call s:fzf_preview_settings() " fzf_preview#remote#initialized or fzf_preview#coc#initialized
augroup END

function! s:fzf_preview_settings() abort
  let g:fzf_preview_command = 'COLORTERM=truecolor ' . g:fzf_preview_command
  let g:fzf_preview_grep_preview_cmd = 'COLORTERM=truecolor ' . g:fzf_preview_grep_preview_cmd
endfunction
  • FzfPreviewVistaBufferCtags does not work
    • Vista must be initialized. Run the Vista command once or write the following settings.
autocmd VimEnter * call vista#RunForNearestMethodOrFunction()

License

The MIT License (MIT)

fzf-preview.vim's People

Contributors

cirnatdan avatar dependabot[bot] avatar farisachugthai avatar fsouza avatar georgijd-form3 avatar glepnir avatar guillaumewuip avatar heimann avatar ippachi avatar kdheepak avatar kuuote avatar pappasam avatar ripperapid avatar sburris0 avatar sheoak avatar tsuyoshicho avatar yuki-yano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fzf-preview.vim's Issues

Clear input with C-u

Sorry for raising an issue instead of working on a PR.

It would be nice to support control + u to clear the input now that there is -resume option.

<Tab> in the Preview Window

I was wondering about the use of key in the preview window, as shown in a GIF.
Correct me if I'm wrong but there doesn't seem to be any written reference of it's functionality, therefore I think we should probably add a description to the README.

Also, would it be possible to remap it just like the other functions (split, vsplit, etc)?
If this is something that would need to be worked upon, I can definitely take a try!

[bug] FzfPreviewProjectOldFiles not working

I just tried Project old files, and got an error. It turns out there's wrong variable reference in the code. This patch should fix it.

diff --git a/autoload/fzf_preview/resource.vim b/autoload/fzf_preview/resource.vim
index d38935b..9dbbdcd 100644
--- a/autoload/fzf_preview/resource.vim
+++ b/autoload/fzf_preview/resource.vim
@@ -44,7 +44,7 @@ function! fzf_preview#resource#project_oldfiles() abort
   endif
 
   let copyfiles = deepcopy(v:oldfiles, 1)
-  call filter(files, { _, file -> file !=# expand('%:p') })
+  call filter(copyfiles, { _, file -> file !=# expand('%:p') })
   return fzf_preview#converter#convert_for_fzf(s:filter_history_file_to_project_file(copyfiles))
 endfunction
 

Fzf preview appearance

Is there a way to remove the transparency from the fzf-preview window?

Also, I know I can modify "g:fzf_preview_fzf_color_option" to control the color of fzf background. However, is there any way to make the background default to using the terminal color? If I don't specify any color, it seems the preview window will default to black instead of the terminal color.

FzfPreviewProjectFiles and gxargs

I did the above command on my nvim and I got [bat error]: 'gxargs': No such file or directory (os error 2)

Which is weird because:

➜ which xargs
/usr/bin/xargs

Nvim debug

NVIM v0.4.3
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/build/config -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/src -I/usr/local/include -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/deps-build/include -I/usr/local/opt/gettext/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/build/src/nvim/auto -I/tmp/neovim-20191107-85913-1wbgqz6/neovim-0.4.3/build/include
Compiled by [email protected]

I am MacOS Catalina (10.15.3) - MacBook Pro (Retina, 13-inch, Early 2015)

So in the postprocess command, I took out the g in gxargs and then I got:

➜ xargs -d "\n" ls —color
xargs: illegal option -- d
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
             [-L number] [-n number [-x]] [-P maxprocs] [-s size]
             [utility [argument ...]]

colorscheme question

Based on #24 , I set a custom g:fzf_preview_grep_preview_cmd and $BAT_THEME='Monokai Extended' and have a correct color scheme in preview as in below (the right panels in preview).

FzfPreviewProjectGrep

:FzfPreviewProjectGrep -add-fzf-arg=--nth=3 .
image

FzfPreviewProjectFiles

:FzfPreviewProjectFiles
image

However, where do the colors of the left panel in :FzfPreviewLines come from (see below)? How can I change those colors?

FzfPreviewLines

:FzfPreviewLines
image

ProjectGrep unreadable with light themes

When using :FzfPreviewProjectGrep with a light theme the text is barely readable (see screenshot).
Manually editing bin/preview_fzf_grep to use another colorscheme fixes that issue. Maybe a global theme option for using bat would be nice.
Screenshot from 2020-02-07 15-48-49

connot excuse preview_fzf_grep in zsh

when using either FzfPreviewBufferTags or FzfPreviewProjectGrep on the preview window I get an error saying zsh:1: permission denied preview_fzf_grep, the file is excusable with the right permissions

ignore the directory it is pointing to, my config is stowed from there

2020-02-21_10-58_1

2020-02-21_10-58

great work BTW, this adds a lot of things to the initial implementation

question regarding grep

when using ProjectFilesPreview i'm able to open selected files as expected, but when using ProjectGrepPreview hitting enter results in a new buffer with the selected line as the title.

any ideas as to what I have mis-configured?

Ripgrep flag 'w' doesn't work

Hi,

it seems like ripgreps -w/--word-regexp flag doesn't work.

AttributeError: 'NoneType' object has no attribute 'group'

Is this intended or a bug?

Regards

ProjectGrep problems with ":"

Hi,

when trying to search for a string containing a :, you won't get the proper results. See screenshot (i removed the filenames...).

Screenshot_20200221_141738

When searching for touch:select there won't be any results.

Regards

setting fzf_preview_filelist_postprocess_command causes plugin to perform much slower

Hi,

I have a codebase of about 230,000 files. With a setup including bat, ripgrep and no filelist_postprocess command it performs relatively good. Once I execute the FzfPreviewDirectoryFiles command from the root of my project the floating window appears in just under 2 seconds, not ideal but good enough.

I have since decided to add a bit of colour to the filelist by installing exa and changing the filelist_postprocess command to the one you provided. When I execute the same command it then takes ~10 seconds for it to appear, thinking that maybe it is just due to exa being slower to ls I tried using dircolors but that also had a delay of 5 seconds.

Is there any way to speed this up?

ProjectGrep super slow with large codebases

Hi,

using :FzfPreviewProjectGrep is super slow with larger codebases. It literally crashes at some point. Try it with a large codebase...kinda extreme example: https://github.com/torvalds/linux. But you get the point.

Using :FzfPreviewProjectGrep <term> works reasonably fast though, so i assume it's because of the fact it renders every file into the list, which IMO should be avoided anyways. Tbh that usage seems to be better in general... performance-wise.

I think when opening the floating window without a searching term, no sources should be listed and the prompt in the floating window would call the according command afterwards, that way you'd also do stuff like -w <term>.

What do you think? Does it make sense?

Regards

Unexpected error when using any command

I get this error for each FzfPreview commands that I'm trying to use. Just pressing enter hides the message and opens the preview window. Anything I can o to solve that?

image

Is there 'finding lines in all buffers" in addition to `FzfPreviewLines`?

Hi, I'm really enjoying fzf-preview. Thanks for this valuable project!

FzfPreviewLines seems for finding lines in current buffer. Is there a similar command but for finding lines in all loaded buffers?

I found that, in junegunn/fzf.vim, there are

:Lines [QUERY] | Lines in loaded buffers
:BLines [QUERY] | Lines in the current buffer

Restore :FzfPreviewProjectGrep functionality

It looks like this commit changed the behavior of the FzfPreviewProjectGrep command to require an argument.

Before I was able to open the preview interface and immediately begin narrowing down the results by typing. Now I need to enter the search term into the status line first, and then once the preview window appears I need to re-enter the search term to begin refining the search.

Is there a way to restore the original behavior (i.e. the way it worked before 8093128)?

FzfPreviewProjectGrep very slow after migrating from ruby to python

Hey, I just started using this extension over fzf.vim and it has been great so far! Although, I recently upgraded via vim-plug, and noticed that :FzfPreviewProjectGrep was unbearably slow on a decently sized project.

After looking a little futher, I noticed fd8f09d switched the preview_fzf_grep scrip to use python3 instead of ruby. After downgrading to the commit right before that, the latency is back to normal.

I'm not exactly sure why it's slower, but I'll try and dig a little more. Anyways, thanks for the great extension, I'm sure we'll be able to figure this one out.

syntax error on python3.5 (not on python3.6)

First of all, deeply thanks for this great plugin!

I have multiple machines: some of them are still Ubuntu 16.04 with Python 3.5 and the other are Ubuntu 18.04 with Python 3.6, by default. When I do FzfPreviewLines, I got
image

I realized that it may be because of the f'string', which is only for Python 3.6+.
image

Would you consider supporting this plugin compatible to Python 3.5?
Or would you recommend/advise users using python3.6+ for their neovim?

[Feature Request] '--preview-window' Support

Apologies if this is already implemented, I couldn't track it down if it was.

FZF has an option '--preview-window' that lets users customize certain aspects of the preview displayed. This can be seen here.

Could this be exposed as a variable in the plugin?

[Feature request] Sorting

Hi,

i was wondering if there is a way to provide some kind of sorting to the entries?
For example, for buffers, i would like to have an option to sort them descending, where newer buffers would come first.

[Feature request] Improved FzfPreviewOldFiles

Hi,

I completely switched from fzf.vim to this.
I found one small difference between old files here and in fzf.vim. In fzf.vim, beside v:oldfiles, buflisted buffers are also listed. This is neat because in reality, those buffers are really an old file that you visited. Vim doesn't update oldfiles with these, but this is a good workaround for it. Would you consider adding it? Thanks!

[Feature request] Tags

Only thing I'm missing to completely switch from fzf-vim to this is :BTags, which i use to jump to method or anything in a file. Any chance that can be added ?

FzfPreviewProjectGrep issues

Hi,

I found few issues with FzfPreviewProjectGrep:

  1. It requires ruby. It's not noted in the requirements.
  2. It requires bat or ccat (check screenshot)
  3. It requires gsed, which i don't have on Manjaro i3, and can't find it in aur.

screenshot

Support fish shell

I'm a fish shell user, and when I invoke, for instance, FzfPreviewProjectFiles I get:

~      ╭──────────────────────────────────────────────────────────────────────────────╮        
~      │ ProjectFiles>                         ┌────────────────────────────────────┐ │        
~      │   375/375                             │ fish: $(...) is not supported. In  │ │        
~      │ > ./lari/pipelines/env: No such fil.. │ [[ "$(file --mime './lari/pipeline │ │        
~      │   scrapy.cfg                          │     ^                              │ │        
~      │   setup.py                            │ [bat error]: '2)': No such file or │ │        
~      │   filters_script.py                   │                                    │ │ 

nvim is set up to use good old bash for shell: :echo &shell returns /usr/bin/env bash.

Is there something I'm missing or that I can do?

Name mismatch for MRU-functions

In the latest version (b76a1a1) I can't use either FzfPreviewMruFiles or FzfPreviewProjectMruFiles. There seem to be a mismatch in the function names (s:mru_files vs. s:mrufiles etc.)

plugin/fzf_preview.vim

126:command! -nargs=* -complete=customlist,fzf_preview#args#complete_options         FzfPreviewProjectMruFiles :call fzf_preview#runner#fzf_run(fzf_preview#initializer#initialize('s:project_mru_files', {}, <f-args>))

129:command! -nargs=* -complete=customlist,fzf_preview#args#complete_options         FzfPreviewMruFiles        :call fzf_preview#runner#fzf_run(fzf_preview#initializer#initialize('s:mru_files', {}, <f-args>))

autoload/fzf_preview/parameter.vim

49:function! s:project_mrufiles(additional, args) abort
51:  \ 'source': fzf_preview#resource#project_mrufiles(),

63:function! s:mrufiles(additional, args) abort
65:  \ 'source': fzf_preview#resource#mrufiles(),

Terminal closing message

Hi, this is a follow-up bug report on the problem I reported in imxiejie/ThinkVim#93 (comment).
When I run FzfPreviewDirectoryFiles or other preview commands, I see the following message on ESC or Enter.

-- TERMINAL --
Close "term://.//7785:cat '/tmp/nvim0PUsUl/3'|'/home/marco/.cache/vim/dein/repos/github.com/junegunn/fzf/bin/fzf' --multi --reverse --ansi 
--bind=ctrl-d:preview-page-down,ctrl-u:preview-page-up,?:toggle-preview   --expect=ctrl-v,ctrl-x,ctrl-q,ctrl-t --prompt="DirectoryFiles> " 
--preview='[[ "$(file --mime {})" =~ binary ]] && echo "{} is a binary file" || head -100 {-1}'  --no-height > /tmp/nvim0PUsUl/2;#FZF"?    
[Y]es, (N)o, (C)ancel:

Here's a screencast:
Peek 2020-03-02 10-39
Might that be related to this plugin?

Layout options

What are the layout options?

I'm used to fzf.vim with let g:fzf_layout = { 'down': '~20%' }, but I can't seem to replicate that at all. I can't even get it to be on the bottom rather than the top.

This is really awesome though, thanks!

RipGrep greps filename with pattern instead of only content

It seems that :FzfPreviewProjectGrep also greps filenames, and not only the content of the files.

For example, let's say I create an empty repository and add 2 files.

test.html content:

layer

and layer.html content:

bullshit
\*
}

If I do the command manually in a terminal:

➜ rg --line-number --no-heading layer ./
./test.html:1:layer

only the "layer" contained in test.html is returned.

If I use, :FzfPreviewProjectGrep, here is the result:
image

It basically greps the filename. So if some text that I need to find is also in a filename, it will be really hard to find that text in the project, since the results will be heavily polluted.

I think it would make sense if it behave normally, as the version entered in a terminal.

:FzfPreviewBuffers does not show terminal sessions

Expected behavior: should show the open terminal sessions alongside the open buffers.

Current behavior: only files are shown in the buffer list.

This is something that works with fzf.vim that I've become reliant on. Without this feature I'm unable to locate open terminal sessions after the buffer window closes, which happens often when I'm jumping around a lot. So I end up creating a bunch of new sessions instead and lose all of my open REPLs, logs, command history, etc.

It would be great if :FzfPreviewBuffers listed all of the active terminal sessions alongside the open buffers.

Delay displaying project files when using zsh

Hi, first of all, thanks for this amazing work ;)

I'm seeing a slight delay when opening the project files list. It's not anything huge, but it's noticeable (I'd say ~0.5s).

I've tried using both the FzfPreviewProjectFiles (which strangely also includes files under .git dir, but this is another issue) and FzfPreviewGitFiles, and I see the delay with both commands. I've also tried running the command in small projects (less than 100 files), and the delay is there, so it's not something related to the number of items, I'd guess.

I then tried disabling the highlighting in the preview pane by using head -n 100 as the preview command, and the delay is still there.

So, I would have thought the issue is related to drawing the popup window, but the FzfPreviewBuffers and FzfPreviewProjectGrep commands don't have the delay, so I'm kinda lost.

Got any clue about what could be going on? I'm on neovim latest HEAD. Let me know if I can help anyhow.

[EDIT] Huh, forgot to add: I've ripgrep installed, obviously.

Buffers preview is not working

Thanks for the plugin.

Is there some config I'm missing? When I try to execute FzfPreviewBuffers, the error bellow happens:

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.