Dropbar.nvim
IDE-like breadcrumbs, out of the box
Install / Use
/learn @Bekaboo/Dropbar.nvimREADME
Introduction
A polished, IDE-like, highly-customizable winbar for Neovim with drop-down menus and multiple backends.
For more information see :h dropbar.
Features
https://github.com/Bekaboo/dropbar.nvim/assets/76579810/e8c1ac26-0321-4762-9975-b20fc3098c5a
- Opening drop-down menus or go to definition with a single mouse click
- Pick mode for quickly selecting a component in the winbar with shortcuts
- Automatically truncating long components
- Better truncation when winbar is still too long after shortening all components
- Multiple backends that support fall-backs
dropbar.nvimcomes with five builtin sources:- lsp: gets symbols from language servers using nvim's builtin LSP framework
- markdown: a custom incremental parser that gets symbol information about markdown headings
- path: gets current file path
- treesitter: gets symbols from treesitter parsers using nvim's builtin treesitter integration
- terminal: easily switch terminal buffers using the dropdown menu To make a new source yourself, see making a new source. For source fall-backs support, see bar options.
- Zero config & Zero dependency
dropbar.nvimdoes not require nvim-lspconfig, nvim-treesitter or any third-party UI libraries to work. As long as the language server or the treesitter parser is installed, it should work just fine. Optionally, you can install telescope-fzf-native to add fuzzy search support to dropbar menus. - Drop-down menu components and winbar symbols that response to
mouse/cursor hovering:
- This features requires
:h mousemoveeventto be enabled.
- This features requires
- Preview symbols in their source windows when hovering over them in the
drop-down menu
- Reorient the source window on previewing or after jumping to a symbol
- Add scrollbar to the menu when the symbol list is too long
Requirements
- Neovim >= 0.11.0
- Optional
- nvim-web-devicons, if you want to see icons for different filetypes
- telescope-fzf-native, if you want fuzzy search support
- Working language server installation for the lsp source to work
- Working treesitter parser installation for the treesitter source to work
Installation
-
Using lazy.nvim
require('lazy').setup({ { 'Bekaboo/dropbar.nvim', -- optional, but required for fuzzy finder support dependencies = { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' }, config = function() local dropbar_api = require('dropbar.api') vim.keymap.set('n', '<Leader>;', dropbar_api.pick, { desc = 'Pick symbols in winbar' }) vim.keymap.set('n', '[;', dropbar_api.goto_context_start, { desc = 'Go to start of current context' }) vim.keymap.set('n', '];', dropbar_api.select_next_context, { desc = 'Select next context' }) end } }) -
Using packer.nvim
require('packer').startup(function(use) use({ 'Bekaboo/dropbar.nvim', requires = { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }, config = function () local dropbar_api = require('dropbar.api') vim.keymap.set('n', '<Leader>;', dropbar_api.pick, { desc = 'Pick symbols in winbar' }) vim.keymap.set('n', '[;', dropbar_api.goto_context_start, { desc = 'Go to start of current context' }) vim.keymap.set('n', '];', dropbar_api.select_next_context, { desc = 'Select next context' }) end }) end) -
Using native package manager
mkdir -p ~/.local/share/nvim/site/pack/packages/ git clone https://github.com/Bekaboo/dropbar.nvim ~/.local/share/nvim/site/pack/packages/start/dropbar.nvimLazy-loading is unneeded as it is already done in plugin/dropbar.lua.
Usage
- Basics
- Moves the cursor around and see the winbar reflects your current context
- Mouse support
- Click on a component in the winbar to open a drop-down menu of its siblings
- Click on an entry in the drop-down menu to go to its location
- Click on the indicator in the drop-down menu to open a sub-menu of its children
- Pick mode
- Use
require('dropbar.api').pick()to enter interactive pick mode orrequire('dropbar.api').pick(<idx>)to directly select a component atidx. - Inside interactive pick mode, press the corresponding pivot shown before each component to select it
- Use
- Fuzzy finder
- Use
dropbar_menu_t:fuzzy_find_open()to interactively filter, select and preview entries using fzf <Esc>: exit fzf mode<Up>/<Down>: move the cursor in fzf mode<CR>: call the on_click callback of the symbol under the cursor
- Use
- Default keymaps in drop-down menu
<LeftMouse>: call theon_clickcallback of the symbol at the mouse click<CR>: find the first clickable symbol in the current drop-down menu entry and call itson_clickcallbacki: enter fzf mode from the menuq/<Esc>: close current menu- To disable, remap or add new keymaps in the drop-down menu, see menu options
Usage with vim.ui.select
Dropbar can be used as a drop-in replacement for Neovim's builtin vim.ui.select menu.
To enable this functionality, simply replace vim.ui.select with dropbar.utils.menu.select:
vim.ui.select = require('dropbar.utils.menu').select
Configuration
Options
For all available options and their default values, see lua/dropbar/configs.lua.
Below are the detailed explanation of the options.
Bar
These options live under opts.bar and are used to control the behavior of the
winbar:
opts.bar.enable:boolean|fun(buf: integer?, win: integer?, info: table?): boolean- Controls whether to attach dropbar to the current buffer and window
- If a function is provided, it will be called with the current bufnr and winid and should return a boolean
- Default:
function(buf, win, _) buf = vim._resolve_bufnr(buf) if not vim.api.nvim_buf_is_valid(buf) or not vim.api.nvim_win_is_valid(win) then return false end if not vim.api.nvim_buf_is_valid(buf) or not vim.api.nvim_win_is_valid(win) or vim.fn.win_gettype(win) ~= '' or vim.wo[win].winbar ~= '' or vim.bo[buf].ft == 'help' then return false end local stat = vim.uv.fs_stat(vim.api.nvim_buf_get_name(buf)) if stat and stat.size > 1024 * 1024 then return false end return vim.bo[buf].ft == 'markdown' or pcall(vim.treesitter.get_parser, buf) or not vim.tbl_isempty(vim.lsp.get_clients({ bufnr = buf, method = 'textDocument/documentSymbol', })) end,
opts.bar.attach_events:string[]- Controls when to evaluate the
enable()function and attach the plugin to corresponding buffer or window - Default:
{ 'TermOpen', 'BufEnter', 'BufWinEnter', 'BufWritePost', 'FileType', 'LspAttach', }
- Controls when to evaluate the
opts.bar.update_debounce:number- Wait for a short time before updating the winbar, if another update
request is received within this time, the previous request will be
cancelled, this improves the performance when the user is holding
down a key (e.g.
'j') to scroll the window - If you encounter performance issues when scrolling the window, try
setting this option to a number slightly larger than
1000 / key_repeat_rate - Default:
32
- Wait for a short time before updating the winbar, if another update
request is received within this time, the previous request will be
cancelled, this improves the performance when the user is holding
down a key (e.g.
opts.bar.update_events.win:string[]- List of events that should trigger an update on the dropbar attached to a single window
- Default:
{ 'CursorMoved', 'WinEnter', 'WinResized', }
opts.bar.update_events.buf:string[]- List of events that should trigger an update on all dropbars attached to a buffer
- Default:
{ 'BufModifiedSet', 'FileChangedShellPost', 'TextChanged', 'ModeChanged', }
opts.bar.update_events.global: `s
