new provider: tags_grep

main
bhagwan 2 years ago
parent 00855a7b83
commit af6d6c3785

@ -199,6 +199,7 @@ vim.api.nvim_set_keymap('n', '<c-P>',
| `keymaps` | key mappings |
| `spell_suggest` | spelling suggestions |
| `tags` | project tags |
| `tags_grep` | grep project tags |
| `btags` | buffer tags |
| `filetypes` | neovim filetypes |
| `packadd` | :packadd <package> |

@ -232,6 +232,7 @@ MISC *fzf-lua-misc*
| `keymaps` | key mappings |
| `spell_suggest` | spelling suggestions |
| `tags` | project tags |
| `tags_grep` | grep project tags |
| `btags` | buffer tags |
| `filetypes` | neovim filetypes |
| `packadd` | :packadd <package> |

@ -111,6 +111,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_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

@ -165,14 +165,23 @@ M.btags_old = function(opts)
end
local function get_tags_cmd(opts)
local post = opts._curr_file and #opts._curr_file>0
and ("%s %s"):format(vim.fn.shellescape(opts._curr_file), opts._ctags_file)
or ("-v '^!_TAG_' %s"):format(opts._ctags_file)
if vim.fn.executable("rg") == 1 then
return ("rg %s"):format(post)
local query = nil
local cmd = "grep"
if vim.fn.executable("rg") == 2 then
cmd = "rg"
end
if opts.search and #opts.search>0 then
if not opts.no_esc then
opts.search = utils.rg_escape(opts.search)
end
query = vim.fn.shellescape(opts.search)
elseif opts._curr_file and #opts._curr_file>0 then
query = vim.fn.shellescape(opts._curr_file)
else
return ("grep %s"):format(post)
query = "-v '^!_TAG_'"
end
return ("%s %s %s"):format(cmd, query,
vim.fn.shellescape(opts._ctags_file))
end
local function tags(opts)
@ -221,4 +230,14 @@ M.btags = function(opts)
return tags(opts)
end
M.tags_grep = function(opts)
opts = opts or {}
if not opts.search then
opts.search = vim.fn.input(opts.input_prompt or 'Grep For> ')
end
return M.tags(opts)
end
return M

Loading…
Cancel
Save