Skip to content

Commit

Permalink
fix(menu): fix default keymaps in menu
Browse files Browse the repository at this point in the history
  • Loading branch information
bekaboo committed Jun 9, 2023
1 parent e136c7f commit 1072eff
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 52 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ https://github.com/Bekaboo/dropbar.nvim/assets/76579810/e8c1ac26-0321-4762-9975-
end
return
end
menu:click_at({ mouse.line, mouse.column }, nil, 1, 'l')
menu:click_at({ mouse.line, mouse.column - 1 }, nil, 1, 'l')
end,
['<CR>'] = function()
local menu = require('dropbar.api').get_current_dropbar_menu()
Expand Down Expand Up @@ -387,7 +387,7 @@ https://github.com/Bekaboo/dropbar.nvim/assets/76579810/e8c1ac26-0321-4762-9975-
return
end
if M.opts.menu.preview then
menu:preview_symbol_at({ mouse.line, mouse.column })
menu:preview_symbol_at({ mouse.line, mouse.column - 1 })
end
menu:update_hover_hl({ mouse.line, mouse.column - 1 })
end,
Expand Down Expand Up @@ -793,7 +793,7 @@ menu:
end
return
end
menu:click_at({ mouse.line, mouse.column }, nil, 1, 'l')
menu:click_at({ mouse.line, mouse.column - 1 }, nil, 1, 'l')
end,
['<CR>'] = function()
local menu = require('dropbar.api').get_current_dropbar_menu()
Expand Down Expand Up @@ -823,7 +823,7 @@ menu:
return
end
if M.opts.menu.preview then
menu:preview_symbol_at({ mouse.line, mouse.column })
menu:preview_symbol_at({ mouse.line, mouse.column - 1 })
end
menu:update_hover_hl({ mouse.line, mouse.column - 1 })
end,
Expand Down
92 changes: 46 additions & 46 deletions doc/dropbar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -400,59 +400,59 @@ the menu:
mode in the menu buffer, or use `<key> = table<mode, function|string>`
to map a key in specific modes.
- Default: >lua
{
['<LeftMouse>'] = function()
local api = require('dropbar.api')
local menu = api.get_current_dropbar_menu()
if not menu then
return
end
local mouse = vim.fn.getmousepos()
if mouse.winid ~= menu.win then
local prev_menu = api.get_dropbar_menu(mouse.winid)
if prev_menu and prev_menu.sub_menu then
prev_menu.sub_menu:close()
end
if vim.api.nvim_win_is_valid(mouse.winid) then
vim.api.nvim_set_current_win(mouse.winid)
end
return
end
menu:click_at({ mouse.line, mouse.column }, nil, 1, 'l')
end,
['<CR>'] = function()
local menu = require('dropbar.api').get_current_dropbar_menu()
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,
{
['<LeftMouse>'] = function()
local api = require('dropbar.api')
local menu = api.get_current_dropbar_menu()
if not menu then
return
end
local mouse = vim.fn.getmousepos()
if mouse.winid ~= menu.win then
local prev_menu = api.get_dropbar_menu(mouse.winid)
if prev_menu and prev_menu.sub_menu then
prev_menu.sub_menu:close()
end
if vim.api.nvim_win_is_valid(mouse.winid) then
vim.api.nvim_set_current_win(mouse.winid)
end
return
end
menu:click_at({ mouse.line, mouse.column - 1 }, nil, 1, 'l')
end,
['<CR>'] = function()
local menu = require('dropbar.api').get_current_dropbar_menu()
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,
['<MouseMove>'] = function()
local menu = require('dropbar.api').get_current_dropbar_menu()
if not menu then
return
end
local mouse = vim.fn.getmousepos()
if mouse.winid ~= menu.win then
-- Find the root menu
while menu and menu.prev_menu do
menu = menu.prev_menu
end
if menu then
menu:finish_preview(true)
end
return
end
if M.opts.menu.preview then
menu:preview_symbol_at({ mouse.line, mouse.column })
end
menu:update_hover_hl({ mouse.line, mouse.column - 1 })
end,
},
-- Find the root menu
while menu and menu.prev_menu do
menu = menu.prev_menu
end
if menu then
menu:finish_preview(true)
end
return
end
if M.opts.menu.preview then
menu:preview_symbol_at({ mouse.line, mouse.column - 1 })
end
menu:update_hover_hl({ mouse.line, mouse.column - 1 })
end,
}
<
- `opts.menu.win_configs`: `table<string, dropbar_menu_win_config_opts_t>`
- Window configurations for the menu, see `:h nvim_open_win()`
Expand Down
4 changes: 2 additions & 2 deletions lua/dropbar/configs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ M.opts = {
end
return
end
menu:click_at({ mouse.line, mouse.column }, nil, 1, 'l')
menu:click_at({ mouse.line, mouse.column - 1 }, nil, 1, 'l')
end,
['<CR>'] = function()
local menu = require('dropbar.api').get_current_dropbar_menu()
Expand Down Expand Up @@ -218,7 +218,7 @@ M.opts = {
return
end
if M.opts.menu.preview then
menu:preview_symbol_at({ mouse.line, mouse.column })
menu:preview_symbol_at({ mouse.line, mouse.column - 1 })
end
menu:update_hover_hl({ mouse.line, mouse.column - 1 })
end,
Expand Down

0 comments on commit 1072eff

Please sign in to comment.