fix(telescope): anonymous keymap (#1879)

* fix(telescope): anonymous keymap

* fix(telescope): add desc

* fix(telescope): function name

* fix(telescope): update description

* fix(telescope): diagnostic disable
This commit is contained in:
André Freitas 2024-03-07 10:49:50 +00:00 committed by GitHub
parent ddbba85408
commit 36ae4213b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -36,16 +36,18 @@ function M.telescope(builtin, opts)
end
end
if opts.cwd and opts.cwd ~= vim.loop.cwd() then
local function open_cwd_dir()
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
---@diagnostic disable-next-line: inject-field
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)
-- opts.desc is overridden by telescope, until it's changed there is this fix
map("i", "<a-c>", open_cwd_dir, { desc = "Open cwd directory" })
return true
end
end