new provider: tags_live_grep

main
bhagwan 2 years ago
parent af6d6c3785
commit 9094065d79

@ -200,6 +200,7 @@ vim.api.nvim_set_keymap('n', '<c-P>',
| `spell_suggest` | spelling suggestions |
| `tags` | project tags |
| `tags_grep` | grep project tags |
| `tags_live_grep` | live grep project tags |
| `btags` | buffer tags |
| `filetypes` | neovim filetypes |
| `packadd` | :packadd <package> |
@ -620,6 +621,9 @@ require'fzf-lua'.setup {
file_icons = true,
git_icons = true,
color_icons = true,
-- 'tags_live_grep' options, `rg` prioritizes over `grep`
rg_opts = "--no-heading --color=always --smart-case",
grep_opts = "--color=auto --perl-regexp",
-- actions inherit from 'actions.files'
},
btags = {

@ -233,6 +233,7 @@ MISC *fzf-lua-misc*
| `spell_suggest` | spelling suggestions |
| `tags` | project tags |
| `tags_grep` | grep project tags |
| `tags_live_grep` | live grep project tags |
| `btags` | buffer tags |
| `filetypes` | neovim filetypes |
| `packadd` | :packadd <package> |
@ -662,6 +663,9 @@ Consult the list below for available settings:
file_icons = true,
git_icons = true,
color_icons = true,
-- 'tags_live_grep' options, `rg` prioritizes over `grep`
rg_opts = "--no-heading --color=always --smart-case",
grep_opts = "--color=auto --perl-regexp",
-- actions inherit from 'actions.files'
},
btags = {

@ -377,6 +377,8 @@ M.globals.tags = {
previewer = { _ctor = previewers.builtin.tags },
prompt = 'Tags> ',
ctags_file = "tags",
rg_opts = "--no-heading --color=always --smart-case",
grep_opts = "--color=auto --perl-regexp",
multiprocess = true,
file_icons = true and M._has_devicons,
git_icons = true,

@ -112,6 +112,7 @@ M.colorschemes = require'fzf-lua.providers.colorschemes'.colorschemes
M.tags = require'fzf-lua.providers.tags'.tags
M.btags = require'fzf-lua.providers.tags'.btags
M.tags_grep = require'fzf-lua.providers.tags'.tags_grep
M.tags_live_grep = require'fzf-lua.providers.tags'.tags_live_grep
M.tags_old = require'fzf-lua.providers.tags'.tags_old
M.btags_old = require'fzf-lua.providers.tags'.btags_old
M.jumps = require'fzf-lua.providers.nvim'.jumps

@ -193,7 +193,11 @@ end
-- multi threaded (multi-process actually) version
M.live_grep_mt = function(opts)
opts = config.normalize_opts(opts, config.globals.grep)
-- do not normalize when called from 'tags_live_grep'
if not opts or not opts._normalized then
opts = config.normalize_opts(opts, config.globals.grep)
end
if not opts then return end
local no_esc = false

@ -167,7 +167,7 @@ end
local function get_tags_cmd(opts)
local query = nil
local cmd = "grep"
if vim.fn.executable("rg") == 2 then
if vim.fn.executable("rg") == 1 then
cmd = "rg"
end
if opts.search and #opts.search>0 then
@ -200,13 +200,20 @@ local function tags(opts)
return
end
opts._curr_file = opts._curr_file and
path.relative(opts._curr_file, opts.cwd or vim.loop.cwd())
opts.cmd = opts.cmd or get_tags_cmd(opts)
opts._fn_transform = make_entry.tag -- multiprocess=false
opts._fn_transform_str = [[return require("make_entry").tag]] -- multiprocess=true
-- prevents 'file|git_icons=false' from overriding processing
opts.requires_processing = true
if opts.lgrep then
opts.prompt = '*' .. opts.prompt
opts.filename = opts._ctags_file
return require'fzf-lua.providers.grep'.live_grep_mt(opts)
end
opts._curr_file = opts._curr_file and
path.relative(opts._curr_file, opts.cwd or vim.loop.cwd())
opts.cmd = opts.cmd or get_tags_cmd(opts)
local contents = core.mt_cmd_wrapper(opts)
opts = core.set_header(opts, 2)
opts = core.set_fzf_field_index(opts)
@ -240,4 +247,12 @@ M.tags_grep = function(opts)
return M.tags(opts)
end
M.tags_live_grep = function(opts)
opts = config.normalize_opts(opts, config.globals.tags)
if not opts then return end
opts.lgrep = true
opts.__FNCREF__ = utils.__FNCREF__()
return tags(opts)
end
return M

Loading…
Cancel
Save