diff --git a/README.md b/README.md index 6b66567..8c1233b 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,8 @@ vim.api.nvim_set_keymap('n', '', | `grep_cWORD` | search WORD under cursor | | `grep_visual` | search visual selection | | `grep_project` | search all project lines (fzf.vim's `:Rg`) | -| `grep_curbuf` | live grep current buffer | +| `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 | diff --git a/doc/fzf-lua.txt b/doc/fzf-lua.txt index 18afb28..c381fba 100644 --- a/doc/fzf-lua.txt +++ b/doc/fzf-lua.txt @@ -174,7 +174,8 @@ SEARCH *fzf-lua-search* | `grep_cWORD` | search WORD under cursor | | `grep_visual` | search visual selection | | `grep_project` | search all project lines (fzf.vim's `:Rg`) | -| `grep_curbuf` | live grep current buffer | +| `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 | diff --git a/lua/fzf-lua/init.lua b/lua/fzf-lua/init.lua index 6915f4b..1a72e39 100644 --- a/lua/fzf-lua/init.lua +++ b/lua/fzf-lua/init.lua @@ -96,6 +96,7 @@ M.grep_cword = require'fzf-lua.providers.grep'.grep_cword M.grep_cWORD = require'fzf-lua.providers.grep'.grep_cWORD M.grep_visual = require'fzf-lua.providers.grep'.grep_visual M.grep_curbuf = require'fzf-lua.providers.grep'.grep_curbuf +M.lgrep_curbuf = require'fzf-lua.providers.grep'.lgrep_curbuf M.grep_project = require'fzf-lua.providers.grep'.grep_project M.git_files = require'fzf-lua.providers.git'.files M.git_status = require'fzf-lua.providers.git'.status diff --git a/lua/fzf-lua/providers/grep.lua b/lua/fzf-lua/providers/grep.lua index 0ecd208..fa673b0 100644 --- a/lua/fzf-lua/providers/grep.lua +++ b/lua/fzf-lua/providers/grep.lua @@ -352,11 +352,22 @@ M.grep_curbuf = function(opts) opts.filename = vim.api.nvim_buf_get_name(0) if #opts.filename > 0 then opts.filename = path.relative(opts.filename, vim.loop.cwd()) - return M.live_grep(opts) + if opts.lgrep then + return M.live_grep(opts) + else + opts.search = '' + return M.grep(opts) + end else utils.info("Rg current buffer requires actual file on disk") return end end +M.lgrep_curbuf = function(opts) + if not opts then opts = {} end + opts.lgrep = true + return M.grep_curbuf(opts) +end + return M