fix: improve grep command handling with egrepify support
This commit is contained in:
+22
-7
@@ -1707,6 +1707,14 @@ function M.pick(cmd, provider, options)
|
|||||||
-- Default the command to "files" if not provided
|
-- Default the command to "files" if not provided
|
||||||
cmd = cmd or 'files'
|
cmd = cmd or 'files'
|
||||||
|
|
||||||
|
-- Helper function to check if a picker command exists for a given provider
|
||||||
|
local function has_picker(provide, commd)
|
||||||
|
local success, picker = pcall(function()
|
||||||
|
return require(provide)[commd]
|
||||||
|
end)
|
||||||
|
return success and type(picker) == 'function'
|
||||||
|
end
|
||||||
|
|
||||||
-- Determine the provider if one is not selected
|
-- Determine the provider if one is not selected
|
||||||
-- (defaults to fzf-lua if available, else telescope)
|
-- (defaults to fzf-lua if available, else telescope)
|
||||||
-- Will use vim.g.lazyvim_picker if defined
|
-- Will use vim.g.lazyvim_picker if defined
|
||||||
@@ -1725,7 +1733,9 @@ function M.pick(cmd, provider, options)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Handle special commands
|
-- ━━━━━━━━━━━━━━━━━━━━━━━ Handle special commands ━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
|
|
||||||
|
-- Config files
|
||||||
if cmd == 'config_files' then
|
if cmd == 'config_files' then
|
||||||
cmd = 'files'
|
cmd = 'files'
|
||||||
options = { cwd = vim.fn.stdpath('config') }
|
options = { cwd = vim.fn.stdpath('config') }
|
||||||
@@ -1734,12 +1744,17 @@ function M.pick(cmd, provider, options)
|
|||||||
cmd = 'find_files'
|
cmd = 'find_files'
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Helper function to check if a picker command exists for a given provider
|
-- Grepping
|
||||||
local function has_picker(provide, commd)
|
if cmd == 'grep' then
|
||||||
local success, picker = pcall(function()
|
if provider == 'telescope' then
|
||||||
return require(provide)[commd]
|
local telescope = require('telescope')
|
||||||
end)
|
if pcall(telescope.extensions.egrepify.egrepify, {}) then
|
||||||
return success and type(picker) == 'function'
|
cmd = 'egrepify'
|
||||||
|
telescope.extensions.egrepify.egrepify({})
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
cmd = 'live_grep'
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Ensure options is always a table (to avoid errors if nil is passed)
|
-- Ensure options is always a table (to avoid errors if nil is passed)
|
||||||
|
|||||||
@@ -182,6 +182,12 @@ local P = { -- Define Telescope Plugins Specs
|
|||||||
{ 'nvim-telescope/telescope-fzy-native.nvim' },
|
{ 'nvim-telescope/telescope-fzy-native.nvim' },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{ -- Telescope Egrepify
|
||||||
|
'fdschmidt93/telescope-egrepify.nvim',
|
||||||
|
lazy = false,
|
||||||
|
opts = {},
|
||||||
|
dependencies = { 'nvim-telescope/telescope.nvim', 'nvim-lua/plenary.nvim' },
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if require('data.func').check_global_var('use_telescope', false, true) then
|
if require('data.func').check_global_var('use_telescope', false, true) then
|
||||||
|
|||||||
Reference in New Issue
Block a user