feat(telescope): added <a-c> mapping for telescope pickers to switch to cwd instead of root

This commit is contained in:
Folke Lemaitre
2023-05-18 09:46:40 +02:00
parent 78354a1e5e
commit c737f2b6c2

View File

@ -105,6 +105,20 @@ function M.telescope(builtin, opts)
builtin = "find_files"
end
end
if opts.cwd and opts.cwd ~= vim.loop.cwd() then
opts.attach_mappings = function(_, map)
map("i", "<a-c>", function()
local action_state = require("telescope.actions.state")
local line = action_state.get_current_line()
M.telescope(
params.builtin,
vim.tbl_deep_extend("force", {}, params.opts or {}, { cwd = false, default_text = line })
)()
end)
return true
end
end
require("telescope.builtin")[builtin](opts)
end
end