-
-
Notifications
You must be signed in to change notification settings - Fork 826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide description for additional mappings #2981
Comments
we kinda already support this but i think not consistently, or there is some bug. e.g. it doesnt work for can you provide the additional mappings that you've added? because i think there should never be a |
Came here to comment the same issue. Here's a not-so-minimal example pickers.new(
opts,
{
prompt_title = "Session Viewer",
finder = finders.new_table(
{
results = vim.tbl_flatten(sessions),
entry_maker = function(entry)
-- ... More stuff here ...
return result
end,
}
),
sorter = telescope_config.file_sorter(opts),
attach_mappings = function(prompt_buffer, map)
map(
"n",
"n",
function() _USE_NICE_NAMES = not _USE_NICE_NAMES end,
-- NOTE: `desc` is currently unsupported by telescope.nvim
-- Reference: https://github.com/nvim-telescope/telescope.nvim/issues/2981
--
{desc = "Toggle [n]ice names or full path displays."}
)
map(
"i",
"<CR>",
function()
actions.close(prompt_buffer)
local selection = state.get_selected_entry()
-- Schedule buffers cleanup to avoid callback issues and source the session
vim.schedule(
function()
local path = selection.value
configuration.DATA.run_pre_switch_hook(path)
vim.cmd.wall()
vim.cmd[[%bwipeout]]
vim.cmd.source(path)
configuration.DATA.run_post_switch_hook(path)
end
)
end,
-- NOTE: `desc` is currently unsupported by telescope.nvim
-- Reference: https://github.com/nvim-telescope/telescope.nvim/issues/2981
--
{desc = "Select a session to load."}
)
return true
end,
}):find() When you press |
I'm having the same problem, and it looks like the problem is related to here: telescope.nvim/lua/telescope/builtin/init.lua Lines 555 to 564 in f12b15e
Once I changed it to the following code it worked fine: if pconf.mappings then
defaults.attach_mappings = function(_, map)
for mode, tbl in pairs(pconf.mappings) do
for key, action in pairs(tbl) do
- map(mode, key, action)
+ map(mode, key, action, action.opts)
end
end
return true
end
end Is this the expected behavior? @Conni2461 P.S. Some quirks (very subjective) make me prefer placing configurations during initialization rather than at runtime. So until this issue is truly “resolved”, I use the following code as a workaround.... Autocmd.new_augroup('telescope').on('WinEnter', function(args)
local bufnr = args.buf
libP.async.run(function()
libP.async.util.scheduler()
if not Plgs.is_loaded('telescope.nvim') then
return
end
if not this.api.is_prompt_buf(bufnr) then
return
end
local picker = this.api.get_current_picker(bufnr)
if not picker then
return
end
Keymap.register(e_mode.NORMAL, '<C-CR>', Tools.wrap_f(this.api.delete_entries, state.bufnr), { buffer = state.bufnr, desc = 'TELESCOPE: delete entries.' })
end)
end) |
This appears to be fixed on the master branch. Probably here #2892 (which should probably backported to the 0.1.x branch). My minimal config: local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
{
"nvim-telescope/telescope.nvim",
-- dir = "~/projects/telescope.nvim",
-- tag = "0.1.7",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
local FOO = true
require("telescope").setup({
defaults = {
mappings = {
n = {
["<C-i>"] = {
function()
FOO = not FOO
end,
type = "action",
opts = { desc = "<C-i> noop" },
},
},
},
},
pickers = {
find_files = {
attach_mappings = function(_, map)
map("n", "<C-j>", function()
FOO = not FOO
end, { desc = "<C-j> noop" })
return true
end,
},
},
})
end,
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
}) |
Unless I'm corrected, I'll consider this closed. |
Is your feature request related to a problem? Please describe.
When adding
mappings
in the configuration of apicker
, there does not seem to be a way for providing a description that would be rendered bywhich_key
.Describe the solution you'd like
Ideally, a description could be provided under
desc
in theopts
of the mapping, to mimick the standard way.Additional context
Without a description,
which_key
shows as a description some gibberish like_13_
.The text was updated successfully, but these errors were encountered: