-
Notifications
You must be signed in to change notification settings - Fork 24
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
[Question]: Is there a way to get bar_idx
of currently opened bar?
#160
Comments
Try using |
@sahinakkaya After picking a symbol in a bar, you are inside a menu, not a bar, and that's why |
Thanks both, I know about Consider I have chosen an H2 header with |
@sahinakkaya Suppose |
@Bekaboo thanks for pointing me in the right direction. I finally managed to make it work as I want. Screen.Recording.2024-05-19.at.14.11.41.movlocal open_item_and_close_menu = function()
local utils = require('dropbar.utils')
local menu = utils.menu.get_current()
if not menu then
return
end
local cursor = vim.api.nvim_win_get_cursor(menu.win)
local entry = menu.entries[cursor[1]]
-- stolen from https://github.com/Bekaboo/dropbar.nvim/issues/66
local component = entry:first_clickable(entry.padding.left + entry.components[1]:bytewidth())
if component then
menu:click_on(component, nil, 1, 'l')
end
end
keymaps = {
['h'] = function()
local utils = require('dropbar.utils')
local menu = utils.menu.get_current()
if not menu then
return
end
if menu.prev_menu then
menu:close()
else
local bar = require('dropbar.utils.bar').get({ win = menu.prev_win })
local barComponents = bar.components[1]._.bar.components
for _, component in ipairs(barComponents) do
if component.menu then
local idx = component._.bar_idx
menu:close()
require('dropbar.api').pick(idx - 1)
end
end
end
end,
['l'] = function()
local utils = require('dropbar.utils')
local menu = utils.menu.get_current()
if not menu then
return
end
local cursor = vim.api.nvim_win_get_cursor(menu.win)
local component = menu.entries[cursor[1]]:first_clickable(cursor[2])
if component then
menu:click_on(component, nil, 1, 'l')
end
end,
['<CR>'] = open_item_and_close_menu,
['o'] = open_item_and_close_menu,
} |
Description
I want to get the bar index of currently opened bar.
Let's say I've executed
:lua require('dropbar.api').pick(3)
, it will open bar 3 if it is available. Now, inside this bar, when I press some key, I want to get its id which is 3. Is there a way to get that information?I want to open previous bar by pressing
h
, that's why I need the current bar number.I've tried
but it prints
nil
The text was updated successfully, but these errors were encountered: