• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ibhagwan/fzf-lua: Improved fzf.vim written in lua

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

ibhagwan/fzf-lua

开源软件地址(OpenSource Url):

https://github.com/ibhagwan/fzf-lua

开源编程语言(OpenSource Language):

Lua 99.5%

开源软件介绍(OpenSource Introduction):

fzf ❤️ lua

Neovim version

InstallationUsageCommandsCustomizationWiki

Demo

fzf changed my command life, it can change yours too, if you allow it.

Rationale

What more can be said about fzf? It is the single most impactful tool for my command line workflow, once I started using fzf I couldn’t see myself living without it.

To understand fzf properly I highly recommended fzf screencast by @samoshkin

This is my take on the original fzf.vim, written in lua for neovim 0.5, it builds on the elegant nvim-fzf as an async interface to create a performant and lightweight fzf client for neovim that rivals any of the new shiny fuzzy finders for neovim.

Why Fzf-Lua

... and not telescope or any other vim/neovim household name?

As @junegunn himself put it, “because you can and you love fzf”.

If you’re happy with your current setup there is absolutely no reason to switch.

That said, without taking anything away from the greatness of other plugins I found it more efficient having a uniform experience between my shell and my nvim. In addition fzf has been a rock for me since I started using it and hadn’t failed me once, it never hangs and can handle almost anything you throw at it. That, and colorful file icons and git indicators!.

Dependencies

fzf version > 0.27 is recommended but it's still possible to use fzf version > 0.25 by setting fzf_opts = { ['--border'] = false }, see Customization.

Optional dependencies

  • fd - better find utility
  • rg - better grep utility
  • bat - syntax highlighted previews when using fzf's native previewer
  • delta - syntax highlighted git pager for git status previews
  • viu - terminal image previews (needs to be configured via previewer.builtin.extensions)
  • ueberzug - X11 image previews (needs to be configured via previewer.builtin.extensions)
  • nvim-dap - for Debug Adapter Protocol (DAP) support

Installation

Using vim-plug

Plug 'ibhagwan/fzf-lua', {'branch': 'main'}
" optional for icon support
Plug 'kyazdani42/nvim-web-devicons'

Using packer.nvim

use { 'ibhagwan/fzf-lua',
  -- optional for icon support
  requires = { 'kyazdani42/nvim-web-devicons' }
}

Note: if you already have fzf installed you do not need to install fzf or fzf.vim, however if you do not have it installed, you only need fzf which can be installed with (fzf.vim is not a requirement nor conflict):

Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }

or with packer.nvim:

use = { 'junegunn/fzf', run = './install --bin', }

Usage

Fzf-lua aims to be as plug and play as possible with sane defaults, you can run any fzf-lua command like this:

:lua require('fzf-lua').files()
-- or using the `FzfLua` vim command:
:FzfLua files

or with arguments:

:lua require('fzf-lua').files({ cwd = '~/.config' })
-- or using the `FzfLua` vim command:
:FzfLua files cwd=~/.config

which can be easily mapped to:

nnoremap <c-P> <cmd>lua require('fzf-lua').files()<CR>

or if using init.lua:

vim.api.nvim_set_keymap('n', '<c-P>',
    "<cmd>lua require('fzf-lua').files()<CR>",
    { noremap = true, silent = true })

Commands

Buffers and Files

Command List
buffers open buffers
files find or fd on a path
oldfiles opened files history
quickfix quickfix list
loclist location list
lines open buffers lines
blines current buffer lines
tabs open tabs
args argument list

Search

Command List
grep search for a pattern with grep or rg
grep_last run search again with the last pattern
grep_cword search word under cursor
grep_cWORD search WORD under cursor
grep_visual search visual selection
grep_project search all project lines (fzf.vim's :Rg)
grep_curbuf search current buffer lines
lgrep_curbuf live grep current buffer
live_grep live grep current project
live_grep_resume live grep continue last search
live_grep_glob live_grep with rg --glob support
live_grep_native performant version of live_grep

Tags

Command List
tags search project tags
btags search buffer tags
tags_grep grep project tags
tags_grep_cword tags_grep word under cursor
tags_grep_cWORD tags_grep WORD under cursor
tags_grep_visual tags_grep visual selection
tags_live_grep live grep project tags

Git

Command List
git_files git ls-files
git_status git status
git_commits git commit log (project)
git_bcommits git commit log (buffer)
git_branches git branches
git_stash git stash

LSP/Diagnostics

Command List
lsp_references References
lsp_definitions Definitions
lsp_declarations Declarations
lsp_typedefs Type Definitions
lsp_implementations Implementations
lsp_document_symbols Document Symbols
lsp_workspace_symbols Workspace Symbols
lsp_live_workspace_symbols Workspace Symbols (live query)
lsp_code_actions Code Actions
lsp_incoming_calls Incoming Calls
lsp_outgoing_calls Outgoing Calls
diagnostics_document Document Diagnostics
diagnostics_workspace Workspace Diagnostics
lsp_document_diagnostics alias to diagnostics_document
lsp_workspace_diagnostics alias to diagnostics_workspace

Misc

Command List
resume resume last command/query
builtin fzf-lua builtin commands
help_tags help tags
man_pages man pages
colorschemes color schemes
highlights highlight groups
commands neovim commands
command_history command history
search_history search history
marks :marks
jumps :jumps
changes :changes
registers :registers
tagstack :tags
keymaps key mappings
filetypes filetypes
menus menus
spell_suggest spelling suggestions
packadd :packadd

Neovim API

:help vim.ui.select for more info

Command List
register_ui_select register fzf-lua as the UI interface for vim.ui.select
deregister_ui_select de-register fzf-lua with vim.ui.select

nvim-dap

Requires nvim-dap

Command List
dap_commands list,run nvim-dap builtin commands
dap_configurations list,run debug configurations
dap_breakpoints list,delete breakpoints
dap_variables active session variables
dap_frames active session jump to frame

Customization

ADVANCED CUSTOMIZATION : to create your own fzf-lua commands see Wiki/ADVANCED

Customization can be achieved by calling the setup() function (optional) or individually sending parameters to a builtin command, A few examples below:

Different fzf layout:

:lua require('fzf-lua').files({ fzf_opts = {['--layout'] = 'reverse-list'} })

Using files with a different command and working directory:

:lua require'fzf-lua'.files({ prompt="LS> ", cmd = "ls", cwd="~/<folder>" })

Using live_grep with git grep:

:lua require'fzf-lua'.live_grep({ cmd = "git grep --line-number --column --color=always" })

colorschemes with non-default window size:

:lua require'fzf-lua'.colorschemes({ winopts = { height=0.33, width=0.33 } })

Use setup() If you wish for a setting to persist and not have to send it using the call arguments, e.g:

require('fzf-lua').setup{
  winopts = {
    ...
  }
}

Can also be called from a .vim file:

lua << EOF
require('fzf-lua').setup{
  ...
}
EOF

Default Options

Below is a list of most (still, not all default settings), please also consult the issues if there's something you need and you can't find as there have been many obscure requests which have been fulfilled and are yet to be documented. If you're still having issues and/or questions do not hesitate to open an issue and I'll be more than happy to help.

CLICK HERE TO EXPLORE THE DEFAULT OPTIONS
local actions = require "fzf-lua.actions"
require'fzf-lua'.setup {
  -- fzf_bin         = 'sk',            -- use skim instead of fzf?
                                        -- https://github.com/lotabout/skim
  global_resume      = true,            -- enable global `resume`?
                                        -- can also be sent individually:
                                        -- `<any_function>.({ gl ... })`
  global_resume_query = true,           -- include typed query in `resume`?
  winopts = {
    -- split         = "belowright new",-- open in a split instead?
                                        -- "belowright new"  : split below
                                        -- "aboveleft new"   : split above
                                        -- "belowright vnew" : split right
                                        -- "aboveleft vnew   : split left
    -- Only valid when 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
actboy168/lua-debug: Lua Debug Adapter for Visual Studio Code发布时间:2022-08-16
下一篇:
rxi/log.lua: A tiny logging module for Lua发布时间:2022-08-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap