From ef79528ae4c060cb3125a38a5a1aa485dab641de Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 6 Jun 2024 18:05:09 +0200 Subject: [PATCH] feat(dropbar): add dropbar for vscode like breadcumbs --- lua/lazyvim/plugins/editor.lua | 2 + lua/lazyvim/plugins/extras/editor/dropbar.lua | 56 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/editor/dropbar.lua diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index b434ded1..3dc5159b 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -72,6 +72,8 @@ return { }, window = { mappings = { + ["l"] = "open", + ["h"] = "close_node", [""] = "none", ["Y"] = { function(state) diff --git a/lua/lazyvim/plugins/extras/editor/dropbar.lua b/lua/lazyvim/plugins/extras/editor/dropbar.lua new file mode 100644 index 00000000..eded8966 --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/dropbar.lua @@ -0,0 +1,56 @@ +return { + { + "Bekaboo/dropbar.nvim", + event = "LazyFile", + dependencies = { + "nvim-telescope/telescope-fzf-native.nvim", + }, + keys = { + { + "D", + function() + require("dropbar.api").pick() + end, + desc = "Winbar pick", + }, + }, + opts = function() + local menu_utils = require("dropbar.utils.menu") + + -- Closes all the windows in the current dropbar. + local function close() + local menu = menu_utils.get_current() + while menu and menu.prev_menu do + menu = menu.prev_menu + end + if menu then + menu:close() + end + end + + return { + menu = { + preview = false, + keymaps = { + -- Navigate back to the parent menu. + ["h"] = "q", + -- Expands the entry if possible. + ["l"] = function() + local menu = menu_utils.get_current() + if not menu then + return + end + local row = vim.api.nvim_win_get_cursor(menu.win)[1] + local component = menu.entries[row]:first_clickable() + if component then + menu:click_on(component, nil, 1, "l") + end + end, + ["q"] = close, + [""] = close, + }, + }, + } + end, + }, +}