diff --git a/README.md b/README.md index 9db0d87e..6cefab7c 100644 --- a/README.md +++ b/README.md @@ -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, [''] = function() local menu = require('dropbar.api').get_current_dropbar_menu() @@ -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, @@ -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, [''] = function() local menu = require('dropbar.api').get_current_dropbar_menu() @@ -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, diff --git a/doc/dropbar.txt b/doc/dropbar.txt index 3fdd32dd..47f97c6d 100644 --- a/doc/dropbar.txt +++ b/doc/dropbar.txt @@ -400,37 +400,37 @@ the menu: mode in the menu buffer, or use ` = table` to map a key in specific modes. - Default: >lua - { - [''] = 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, - [''] = 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, + { + [''] = 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, + [''] = 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, [''] = function() local menu = require('dropbar.api').get_current_dropbar_menu() if not menu then @@ -438,21 +438,21 @@ the menu: 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` - Window configurations for the menu, see `:h nvim_open_win()` diff --git a/lua/dropbar/configs.lua b/lua/dropbar/configs.lua index 4eec45cc..12911b59 100644 --- a/lua/dropbar/configs.lua +++ b/lua/dropbar/configs.lua @@ -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, [''] = function() local menu = require('dropbar.api').get_current_dropbar_menu() @@ -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,