Closed al-ce closed 11 months ago
Looks good to me. I'll test it on my setup.
Did you decide to make the current buffer hidden by default after all?
Did you decide to make the current buffer hidden by default after all?
Sorry I left that comment hanging! I think I'm on the same page with what you were saying, that we should not hide the current buffer (right?). Currently the defaults are
sort_mru = true,
sort_lastused = true,
selection_strategy = "row",
so the current buffer should be in the first result, selector/cursor should be on the second result which is the previously used buffer, and the rest are sorted by most recently used (if I've implemented the options correctly)
Did you decide to make the current buffer hidden by default after all?
Sorry I left that comment hanging! I think I'm on the same page with what you were saying, that we should not hide the current buffer (right?). Currently the defaults are
sort_mru = true, sort_lastused = true, selection_strategy = "row",
so the current buffer should be in the first result, selector/cursor should be on the second result which is the previously used buffer, and the rest are sorted by most recently used (if I've implemented the options correctly)
huh, weird, I think I have the current buffer hidden can you check? my setup function is empy, so I should be getting all default behaviours
can you check? my setup function is empy, so I should be getting all default behaviours
I'm guilty of creating a million branches here, are you using the default_opts
branch on my fork instead of the picker_opts
branch from the last PR? (sorry I did that, I changed the merge message of the last PR and had a merge conflict so I created this new one) Otherwise I'll debug
can you check? my setup function is empy, so I should be getting all default behaviours
I'm guilty of creating a million branches here, are you using the
default_opts
branch on my fork instead of thepicker_opts
branch from the last PR? (sorry I did that, I changed the merge message of the last PR and had a merge conflict so I created this new one) Otherwise I'll debug
Yeah, I'm using this branch
{
'al-ce/hbac.nvim',
config = function()
require("hbac").setup()
end,
branch = "default_opts"
},
Does passing opts to the setup call or to the telescope function call change the behavior or does it throw any errors? Like
{
'al-ce/hbac.nvim',
config = function()
require("hbac").setup(
{
telescope = {
sort_lastused = true,
},
}
)
vim.keymap.set("n", ",ht", function()
require("hbac").telescope({
sort_mru = true,
mappings = {
i = {
["<cr>"] = telescope_actions.select_drop,
},
},
})
end)
end,
branch = "default_opts"
}
Just confirming whether it's just the default behavior or if any opts are registering
Does passing opts to the setup call or to the telescope function call change the behavior or does it throw any errors? Like
{ 'al-ce/hbac.nvim', config = function() require("hbac").setup( { telescope = { sort_lastused = true, }, } ) vim.keymap.set("n", ",ht", function() require("hbac").telescope({ sort_mru = true, mappings = { i = { ["<cr>"] = telescope_actions.select_drop, }, }, }) end) end, branch = "default_opts" }
Just confirming whether it's just the default behavior or if any opts are registering
For me, even if I paste this configuration, the current buffer is hidden.
Sorry for lack of updates, I've been traveling to visit family and I've been trying to figure this out in some downtime. I've tried a few different setups and I'm getting the behavior I'm expecting so I think it might be some mistake I made when I merged the last PR into this branch or I'm making some bad assumption about my machine. Sorry for the hold up and I'll keep trying, hope all is well
Sorry! I just realized I was passing my own opts 🤦🏻
vim.keymap.set("n", "<leader>b", function()
local default_opts = {
show_all_buffers = true,
sort_mru = true,
sort_lastused = true,
ignore_current_buffer = true,
cwd_only = false,
cwd = nil,
}
require("hbac").telescope(default_opts)
I changed it to this and it works as expected
vim.keymap.set("n", "<leader>b", ":Hbac telescope<CR>", ns)
I changed it to this and it works as expected
Ok that's good! I integrated your suggestions above and made a small refactor in the config module to not repeat the lines that assign the mappings, since they're the same for both. Is this ok?
local action_mappings = {
["<M-c>"] = actions.close_unpinned,
["<M-x>"] = actions.delete_buffer,
["<M-a>"] = actions.pin_all,
["<M-u>"] = actions.unpin_all,
["<M-y>"] = actions.toggle_pin,
}
local defaults = {
telescope = {
mappings = {
n = action_mappings,
i = action_mappings,
}
-- etc
}
Looks good and works for me.
Hey, I'm back home from my travels. I'm good with the PR as it is if you're happy with it and ready to merge it, I think we've addressed the open issues it references. Will you do the merge into main when you're ready? I didn't want to push the new mapping config structure without knowing your procedures for announcements or versioning. Thanks again for the collaboration!
BREAKING CHANGES: In this PR we would restructure the
mappings
table in in the setup configuration to follow Telescope's structure (["key"] = function
) for action mappings.All actions are named functions so they'll have names in the Telescope 'which key' popup.
Changes:
Hbac telescope
command as well as a call tohbac.telescope()
. Any opts added to the user's setup call or passed to the function call deep-extend into the config defaultsrequire
calls are moved around inhbac.command.actions
,hbac.command.subcommands
, andhbac.utils
to prevent circular dependencies with the mappings in the setup configuration for the Telescope pickerattach_mappings
module is renamed toactions
. It holds the definitions for the named functions that refresh the pickerattach_mappings
function definition is moved tohbac.telescope
and can accept anopts
table so that the user can pass their ownmappings
configuration as they would to a builtin Telescope pickerordinal
value for the results. This ignores the absolute filepath above a project root for a cleaner fuzzy search (e.g. typinghu
won't show/home/user/projectroot/main.c
as a result)Example user config (extends default in
hbac.config
):example keymap for picker (extends user config):
Addresses #11 and builds on #9 and #12 (partially addressed by f041ebabcd27aaadaebaccc9390edb56d06af731)