telescope-frecency.nvim
telescope-frecency.nvim copied to clipboard
Using `<Tab>` instead of `<C-n>` does not work
When I open frecency with :Telescope frecency, advancing to the next item with <Tab> or to the previous item with <S-Tab> does not work; only <C-n> and <C-p> work.
I am used to pressing <Tab> in Telescope windows so I am not sure why this does not work. Also I saw these lines in frecency.lua which indicate that pressing <Tab> should work:
vim.api.nvim_buf_set_keymap(
state.picker.prompt_bufnr,
"i",
"<Tab>",
"pumvisible() ? '<C-n>' : '<C-x><C-u>'",
{ expr = true, noremap = true }
)
vim.api.nvim_buf_set_keymap(
state.picker.prompt_bufnr,
"i",
"<S-Tab>",
"pumvisible() ? '<C-p>' : ''",
{ expr = true, noremap = true }
)
also having problems with this, ill post here if i find a solution
ditched the whole plugin and started using harpoon instead
I also noticed this. trying to overwrite the mappings to allow for tab like this also does not work:
frecency = {
mappings = {
i = {
["<Tab>"] = "move_selection_worse",
["<S-Tab>"] = "move_selection_better",
},
},
},
Yes, this is a spec by this code on current build.
https://github.com/nvim-telescope/telescope-frecency.nvim/blob/4bdd9bafc7ac2c6fed03e92efac1e6b4632eda28/lua/frecency/picker.lua#L252-L253
I think it is good if these <Tab>, <S-Tab> are customizable. 🤔
@chrisgrieser Yeah, there is something going on with key binds in frecency. My default key binds are not passed through like other telescope-extensions. I use this function to multiselect files and open them all. Works with other extensions like live_grep with args. I even added the mappings under frecency extension. No luck on either method for key mapping with frecency, but works with live_grep_args
local picker = require("telescope.actions.state").get_current_picker(prompt_bufnr)
local multi = picker:get_multi_selection()
if not vim.tbl_isempty(multi) then
require("telescope.actions").close(prompt_bufnr)
for _, j in pairs(multi) do
if j.path ~= nil then
vim.cmd(string.format("%s %s", "edit", j.path))
end
end
else
require("telescope.actions").select_default(prompt_bufnr)
end
end
telescope.setup({
...
mappings = {
n = {
["<CR>"] = select_one_or_multi,
}
}
})
extensions = {
live_grep_args = {},
frecency = {
mappings = {
n = {
["<CR>"] = select_one_or_multi,
["<c-c>"] = require("telescope.actions").close,
},
}
}
}
Hot fix:
~/.local/share/nvim/lazy/telescope-frecency.nvim/lua/frecency/picker.lua:267
function Picker:set_prompt_options(bufnr)
vim.bo[bufnr].completefunc = "v:lua.require'telescope'.extensions.frecency.complete"
-- vim.keymap.set("i", "<Tab>", "pumvisible() ? '<C-n>' : '<C-x><C-u>'", { buffer = bufnr, expr = true })
-- vim.keymap.set("i", "<S-Tab>", "pumvisible() ? '<C-p>' : ''", { buffer = bufnr, expr = true })
end
@teocns If you have hotfix, please do a PR? 🙏
That way it gets fixed for everyone, the rest of us can use your fork until the fix is merged.
Just pushed a fork with the fix.
@chrisgrieser a PR with upstream may not be reasonable since the hotfix removes autocompletion bindings completely. Might consider to open a PR implementing keymaps configuration via .setup()