Home

Awesome

<h1 align='center'> dropbar.nvim </h1> <p align='center'> <b>IDE-like breadcrumbs, out of the box</b> </p> <p align='center'> <img src=https://github.com/Bekaboo/dropbar.nvim/assets/76579810/28db72ab-d75c-46fe-8a9d-1f06b4440de9 width=500> </p> <p align='center'> A polished, IDE-like, highly-customizable winbar for Neovim <br> with drop-down menu support and multiple backends </p> <div align='center'>

docs luarocks

</div> <!--toc:start--> <!--toc:end-->

Features and TODOs

https://github.com/Bekaboo/dropbar.nvim/assets/76579810/e8c1ac26-0321-4762-9975-b20fc3098c5a

Requirements

Installation

Usage

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

<details> <summary> A full list of all available options and their default values: </summary>
---@class dropbar_configs_t
M.opts = {
  general = {
    ---@type boolean|fun(buf: integer, win: integer, info: table?): boolean
    enable = function(buf, win, _)
      return vim.fn.win_gettype(win) == ''
        and vim.wo[win].winbar == ''
        and vim.bo[buf].bt == ''
        and (
          vim.bo[buf].ft == 'markdown'
          or (
            buf
              and vim.api.nvim_buf_is_valid(buf)
              and (pcall(vim.treesitter.get_parser, buf, vim.bo[buf].ft))
              and true
            or false
          )
        )
    end,
    attach_events = {
      'OptionSet',
      'BufWinEnter',
      'BufWritePost',
    },
    -- 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, default to 0 ms
    -- If you encounter performance issues when scrolling the window, try
    -- setting this option to a number slightly larger than
    -- 1000 / key_repeat_rate
    update_interval = 0,
    update_events = {
      win = {
        'CursorMoved',
        'CursorMovedI',
        'WinEnter',
        'WinResized',
      },
      buf = {
        'BufModifiedSet',
        'FileChangedShellPost',
        'TextChanged',
        'TextChangedI',
      },
      global = {
        'DirChanged',
        'VimResized',
      },
    },
  },
  icons = {
    enable = true,
    kinds = {
      use_devicons = true,
      symbols = {
        Array = '󰅪 ',
        Boolean = ' ',
        BreakStatement = '󰙧 ',
        Call = '󰃷 ',
        CaseStatement = '󱃙 ',
        Class = ' ',
        Color = '󰏘 ',
        Constant = '󰏿 ',
        Constructor = ' ',
        ContinueStatement = '→ ',
        Copilot = ' ',
        Declaration = '󰙠 ',
        Delete = '󰩺 ',
        DoStatement = '󰑖 ',
        Enum = ' ',
        EnumMember = ' ',
        Event = ' ',
        Field = ' ',
        File = '󰈔 ',
        Folder = '󰉋 ',
        ForStatement = '󰑖 ',
        Function = '󰊕 ',
        H1Marker = '󰉫 ', -- Used by markdown treesitter parser
        H2Marker = '󰉬 ',
        H3Marker = '󰉭 ',
        H4Marker = '󰉮 ',
        H5Marker = '󰉯 ',
        H6Marker = '󰉰 ',
        Identifier = '󰀫 ',
        IfStatement = '󰇉 ',
        Interface = ' ',
        Keyword = '󰌋 ',
        List = '󰅪 ',
        Log = '󰦪 ',
        Lsp = ' ',
        Macro = '󰁌 ',
        MarkdownH1 = '󰉫 ', -- Used by builtin markdown source
        MarkdownH2 = '󰉬 ',
        MarkdownH3 = '󰉭 ',
        MarkdownH4 = '󰉮 ',
        MarkdownH5 = '󰉯 ',
        MarkdownH6 = '󰉰 ',
        Method = '󰆧 ',
        Module = '󰏗 ',
        Namespace = '󰅩 ',
        Null = '󰢤 ',
        Number = '󰎠 ',
        Object = '󰅩 ',
        Operator = '󰆕 ',
        Package = '󰆦 ',
        Pair = '󰅪 ',
        Property = ' ',
        Reference = '󰦾 ',
        Regex = ' ',
        Repeat = '󰑖 ',
        Scope = '󰅩 ',
        Snippet = '󰩫 ',
        Specifier = '󰦪 ',
        Statement = '󰅩 ',
        String = '󰉾 ',
        Struct = ' ',
        SwitchStatement = '󰺟 ',
        Terminal = ' ',
        Text = ' ',
        Type = ' ',
        TypeParameter = '󰆩 ',
        Unit = ' ',
        Value = '󰎠 ',
        Variable = '󰀫 ',
        WhileStatement = '󰑖 ',
      },
    },
    ui = {
      bar = {
        separator = ' ',
        extends = '…',
      },
      menu = {
        separator = ' ',
        indicator = ' ',
      },
    },
  },
  symbol = {
    preview = {
      ---Reorient the preview window on previewing a new symbol
      ---@param _ integer source window id, ignored
      ---@param range {start: {line: integer}, end: {line: integer}} 0-indexed
      reorient = function(_, range)
        local invisible = range['end'].line - vim.fn.line('w$') + 1
        if invisible > 0 then
          local view = vim.fn.winsaveview() --[[@as vim.fn.winrestview.dict]]
          view.topline = math.min(
            view.topline + invisible,
            math.max(1, range.start.line - vim.wo.scrolloff + 1)
          )
          vim.fn.winrestview(view)
        end
      end,
    },
    jump = {
      ---@param win integer source window id
      ---@param range {start: {line: integer}, end: {line: integer}} 0-indexed
      reorient = function(win, range)
        local view = vim.fn.winsaveview()
        local win_height = vim.api.nvim_win_get_height(win)
        local topline = range.start.line - math.floor(win_height / 4)
        if
          topline > view.topline
          and topline + win_height < vim.fn.line('$')
        then
          view.topline = topline
          vim.fn.winrestview(view)
        end
      end,
    },
  },
  bar = {
    hover = true,
    ---@type dropbar_source_t[]|fun(buf: integer, win: integer): dropbar_source_t[]
    sources = function(buf, _)
      local sources = require('dropbar.sources')
      if vim.bo[buf].ft == 'markdown' then
        return {
          sources.path,
          sources.markdown,
        }
      end
      if vim.bo[buf].buftype == 'terminal' then
        return {
          sources.terminal,
        }
      end
      return {
        sources.path,
        utils.source.fallback({
          sources.lsp,
          sources.treesitter,
        }),
      }
    end,
    padding = {
      left = 1,
      right = 1,
    },
    pick = {
      pivots = 'abcdefghijklmnopqrstuvwxyz',
    },
    truncate = true,
  },
  menu = {
    -- When on, preview the symbol under the cursor on CursorMoved
    preview = true,
    -- When on, automatically set the cursor to the closest previous/next
    -- clickable component in the direction of cursor movement on CursorMoved
    quick_navigation = true,
    entry = {
      padding = {
        left = 1,
        right = 1,
      },
    },
    -- Menu scrollbar options
    scrollbar = {
      enable = true,
      -- The background / gutter of the scrollbar
      -- When false, only the scrollbar thumb is shown.
      background = true
    },
    ---@type table<string, string|function|table<string, string|function>>
  keymaps = {
    ['q'] = '<C-w>q',
    ['<Esc>'] = '<C-w>q',
    ['<LeftMouse>'] = function()
      local menu = utils.menu.get_current()
      if not menu then
        return
      end
      local mouse = vim.fn.getmousepos()
      local clicked_menu = utils.menu.get({ win = mouse.winid })
      -- If clicked on a menu, invoke the corresponding click action,
      -- else close all menus and set the cursor to the clicked window
      if clicked_menu then
        clicked_menu:click_at({ mouse.line, mouse.column - 1 }, nil, 1, 'l')
        return
      end
      utils.menu.exec('close')
      utils.bar.exec('update_current_context_hl')
      if vim.api.nvim_win_is_valid(mouse.winid) then
        vim.api.nvim_set_current_win(mouse.winid)
      end
    end,
    ['<CR>'] = function()
      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,
    ['<MouseMove>'] = function()
      local menu = utils.menu.get_current()
      if not menu then
        return
      end
      local mouse = vim.fn.getmousepos()
      utils.menu.update_hover_hl(mouse)
      if M.opts.menu.preview then
        utils.menu.update_preview(mouse)
      end
    end,
    ['i'] = function()
      local menu = utils.menu.get_current()
      if not menu then
        return
      end
      menu:fuzzy_find_open()
    end,
  },
    ---@alias dropbar_menu_win_config_opts_t any|fun(menu: dropbar_menu_t):any
    ---@type table<string, dropbar_menu_win_config_opts_t>
    ---@see vim.api.nvim_open_win
    win_configs = {
      border = 'none',
      style = 'minimal',
      row = function(menu)
        return menu.prev_menu
            and menu.prev_menu.clicked_at
            and menu.prev_menu.clicked_at[1] - vim.fn.line('w0')
          or 0
      end,
      ---@param menu dropbar_menu_t
      col = function(menu)
        if menu.prev_menu then
          return menu.prev_menu._win_configs.width
            + (
              menu.prev_menu.scrollbar
                and menu.prev_menu.scrollbar.background
                and 1
              or 0
            )
        end
        local mouse = vim.fn.getmousepos()
        local bar = utils.bar.get({ win = menu.prev_win })
        if not bar then
          return mouse.wincol
        end
        local _, range = bar:get_component_at(math.max(0, mouse.wincol - 1))
        return range and range.start or mouse.wincol
      end,
      relative = 'win',
      win = function(menu)
        return menu.prev_menu and menu.prev_menu.win
          or vim.fn.getmousepos().winid
      end,
      height = function(menu)
        return math.max(
          1,
          math.min(
            #menu.entries,
            vim.go.pumheight ~= 0 and vim.go.pumheight
              or math.ceil(vim.go.lines / 4)
          )
        )
      end,
      width = function(menu)
        local min_width = vim.go.pumwidth ~= 0 and vim.go.pumwidth or 8
        if vim.tbl_isempty(menu.entries) then
          return min_width
        end
        return math.max(
          min_width,
          math.max(unpack(vim.tbl_map(function(entry)
            return entry:displaywidth()
          end, menu.entries)))
        )
      end,
      zindex = function(menu)
        if menu.prev_menu then
          if menu.prev_menu.scrollbar and menu.prev_menu.scrollbar.thumb then
            return vim.api.nvim_win_get_config(menu.prev_menu.scrollbar.thumb).zindex
          end
          return vim.api.nvim_win_get_config(menu.prev_win).zindex
        end
      end,
    },
  },
  fzf = {
    ---@type table<string, string | fun()>
    keymaps = {
      ['<LeftMouse>'] = function()
        ---@type dropbar_menu_t
        local menu = utils.menu.get_current()
        if not menu then
          return
        end
        local mouse = vim.fn.getmousepos()
        if not mouse then
          return
        end
        if mouse.winid ~= menu.win then
          local default_func = M.opts.menu.keymaps['<LeftMouse>']
          if type(default_func) == 'function' then
            default_func()
          end
          menu:fuzzy_find_close()
          return
        elseif mouse.winrow > vim.api.nvim_buf_line_count(menu.buf) then
          return
        end
        vim.api.nvim_win_set_cursor(menu.win, { mouse.line, mouse.column - 1 })
        menu:fuzzy_find_click_on_entry(function(entry)
          return entry:get_component_at(mouse.column - 1, true)
        end)
      end,
      ['<MouseMove>'] = function()
        ---@type dropbar_menu_t
        local menu = utils.menu.get_current()
        if not menu then
          return
        end
        local mouse = vim.fn.getmousepos()
        if not mouse then
          return
        end
        -- If mouse is not in the menu window or on the border, end preview
        -- and clear hover highlights
        if
          mouse.winid ~= menu.win
          or mouse.line <= 0
          or mouse.column <= 0
          or mouse.winrow > (#menu.entries + 1)
        then
          -- Find the root menu
          while menu and menu.prev_menu do
            menu = menu.prev_menu
          end
          if menu then
            menu:finish_preview(true)
            menu:update_hover_hl()
          end
          return
        end
        if M.opts.menu.preview then
          menu:preview_symbol_at({ mouse.line, mouse.column - 1 }, true)
        end
        menu:update_hover_hl({ mouse.line, mouse.column - 1 })
      end,
      ['<Up>'] = api.fuzzy_find_prev,
      ['<Down>'] = api.fuzzy_find_next,
      ['<C-k>'] = api.fuzzy_find_prev,
      ['<C-j>'] = api.fuzzy_find_next,
      ['<C-p>'] = api.fuzzy_find_prev,
      ['<C-n>'] = api.fuzzy_find_next,
      ['<CR>'] = api.fuzzy_find_click,
      ['<S-Enter>'] = function()
        api.fuzzy_find_click(-1)
      end,
    },
    win_configs = {
      relative = 'win',
      anchor = 'NW',
      height = 1,
      win = function(menu)
        return menu.win
      end,
      width = function(menu)
        local function border_width(border)
          if type(border) == 'string' then
            if border == 'none' or border == 'shadow' then
              return 0
            end
            return 2 -- left and right border
          end

          local left, right = 1, 1
          if
            (#border == 1 and border[1] == '')
            or (#border == 4 and border[4] == '')
            or (#border == 8 and border[8] == '')
          then
            left = 0
          end
          if
            (#border == 1 and border[1] == '')
            or (#border == 4 and border[4] == '')
            or (#border == 8 and border[4] == '')
          then
            right = 0
          end
          return left + right
        end
        local menu_width = menu._win_configs.width
          + border_width(menu._win_configs.border)
        local self_width = menu._win_configs.width
        local self_border = border_width(
          (
            M.opts.fzf.win_configs
            and M.eval(M.opts.fzf.win_configs.border, menu)
          )
            or (menu.fzf_win_configs and M.eval(
              menu.fzf_win_configs.border,
              menu
            ))
            or menu._win_configs.border
        )

        if self_width + self_border > menu_width then
          return self_width - self_border
        else
          return menu_width - self_border
        end
      end,
      row = function(menu)
        local menu_border = menu._win_configs.border
        if
          type(menu_border) == 'string'
          and menu_border ~= 'shadow'
          and menu_border ~= 'none'
        then
          return menu._win_configs.height + 1
        elseif menu_border == 'none' then
          return menu._win_configs.height
        end
        local len_menu_border = #menu_border
        if
          len_menu_border == 1 and menu_border[1] ~= ''
          or (len_menu_border == 2 or len_menu_border == 4) and menu_border[2] ~= ''
          or len_menu_border == 8 and menu_border[8] ~= ''
        then
          return menu._win_configs.height + 1
        else
          return menu._win_configs.height
        end
      end,
      col = function(menu)
        local menu_border = menu._win_configs.border
        if
          type(menu_border) == 'string'
          and menu_border ~= 'shadow'
          and menu_border ~= 'none'
        then
          return -1
        end
        if
          type(menu_border) == 'table' and menu_border[#menu_border] ~= ''
        then
          return -1
        end
        return 0
      end,
    },
    prompt = '%#htmlTag# ',
    char_pattern = '[%w%p]',
    retain_inner_spaces = true,
    fuzzy_find_on_click = true,
  },
  sources = {
    path = {
      ---@type string|fun(buf: integer, win: integer): string
      relative_to = function(_, win)
        -- Workaround for Vim:E5002: Cannot find window number
        local ok, cwd = pcall(vim.fn.getcwd, win)
        return ok and cwd or vim.fn.getcwd()
      end,
      ---Can be used to filter out files or directories
      ---based on their name
      ---@type fun(name: string): boolean
      filter = function(_)
        return true
      end,
      ---Last symbol from path source when current buf is modified
      ---@param sym dropbar_symbol_t
      ---@return dropbar_symbol_t
      modified = function(sym)
        return sym
      end,
      ---@type boolean|fun(path: string): boolean?|nil
      preview = function(path)
        local stat = vim.uv.fs_stat(path)
        if not stat or stat.type ~= 'file' then
          return false
        end
        if stat.size > 524288 then
          vim.notify(
            string.format(
              '[dropbar.nvim] file "%s" too large to preview',
              path
            ),
            vim.log.levels.WARN
          )
          return false
        end
        return true
      end,
    },
    treesitter = {
      -- Lua pattern used to extract a short name from the node text
      name_pattern = '[#~%*%w%._%->!@:]+%s*'
        .. string.rep('[#~%*%w%._%->!@:]*', 3, '%s*'),
      -- The order matters! The first match is used as the type
      -- of the treesitter symbol and used to show the icon
      -- Types listed below must have corresponding icons
      -- in the `icons.kinds.symbols` table for the icon to be shown
      valid_types = {
        'array',
        'boolean',
        'break_statement',
        'call',
        'case_statement',
        'class',
        'constant',
        'constructor',
        'continue_statement',
        'delete',
        'do_statement',
        'enum',
        'enum_member',
        'event',
        'for_statement',
        'function',
        'h1_marker',
        'h2_marker',
        'h3_marker',
        'h4_marker',
        'h5_marker',
        'h6_marker',
        'if_statement',
        'interface',
        'keyword',
        'list',
        'macro',
        'method',
        'module',
        'namespace',
        'null',
        'number',
        'operator',
        'package',
        'pair',
        'property',
        'reference',
        'repeat',
        'scope',
        'specifier',
        'string',
        'struct',
        'switch_statement',
        'type',
        'type_parameter',
        'unit',
        'value',
        'variable',
        'while_statement',
        'declaration',
        'field',
        'identifier',
        'object',
        'statement',
        'text',
      },
    },
    lsp = {
      request = {
        -- Times to retry a request before giving up
        ttl_init = 60,
        interval = 1000, -- in ms
      },
    },
    markdown = {
      parse = {
        -- Number of lines to update when cursor moves out of the parsed range
        look_ahead = 200,
      },
    },
    terminal = {
      ---@type string|fun(buf: integer): string
      icon = function(buf)
        local icon = M.opts.icons.kinds.symbols.Terminal
        if M.opts.icons.kinds.use_devicons then
          icon = require('nvim-web-devicons').get_icon_by_filetype(
            vim.bo[buf].filetype
          ) or icon
        end
        return icon
      end,
      ---@type string|fun(buf: integer): string
      name = vim.api.nvim_buf_get_name,
      ---@type boolean
      ---Show the current terminal buffer in the menu
      show_current = true,
    },
  },
}
</details>

General

These options live under opts.general and are used to configure the general behavior of the plugin:

Icons

These options live under opts.icons and are used to configure the icons used by the plugin:

Symbol

These options live under opts.symbol and are used to control the behavior of the symbols:

Bar

These options live under opts.bar and are used to control the behavior of the winbar:

Menu

These options live under opts.menu and are used to control the behavior of the menu:

Fzf

These options live under opts.fzf and are used to control the behavior and appearance of the fuzzy finder interface.

Sources

These options live under opts.sources and are used to control the behavior of each sources.

Path
Treesitter
LSP
Markdown
Terminal

Thanks @willothy for implementing this.

API

dropbar.nvim exposes a few functions in lua/dropbar/api.lua that can be used to interact with the winbar or the drop-down menu:

Utility Functions

Here are some utility functions that can be handy when writing your customize your config:

Bar Utility Functions

Defined in lua/dropbar/utils/bar.lua.

Menu Utility Functions

Defined in lua/dropbar/utils/menu.lua.

Highlighting

dropbar.nvim defines the following highlight groups that, override them in your colorscheme to change the appearance of the drop-down menu, the names should be self-explanatory:

<details> <summary>Highlight groups</summary>
Highlight groupAttributes
DropBarCurrentContext{ link = 'Visual' }
DropBarFzfMatch{ link = 'TelescopeMatching' }
DropBarHover{ link = 'Visual' }
DropBarIconCurrentContext{ link = 'Visual' }
DropBarIconKindArray{ link = 'Array' }
DropBarIconKindBoolean{ link = 'Boolean' }
DropBarIconKindBreakStatement{ link = 'Error' }
DropBarIconKindCall{ link = 'Function' }
DropBarIconKindCaseStatement{ link = 'Conditional' }
DropBarIconKindClass{ link = 'CmpItemKindClass' }
DropBarIconKindConstant{ link = 'Constant' }
DropBarIconKindConstructor{ link = 'CmpItemKindConstructor' }
DropBarIconKindContinueStatement{ link = 'Repeat' }
DropBarIconKindDeclaration{ link = 'CmpItemKindSnippet' }
DropBarIconKindDelete{ link = 'Error' }
DropBarIconKindDoStatement{ link = 'Repeat' }
DropBarIconKindElseStatement{ link = 'Conditional' }
DropBarIconKindEnum{ link = 'CmpItemKindEnum' }
DropBarIconKindEnumMember{ link = 'CmpItemKindEnumMember' }
DropBarIconKindEvent{ link = 'CmpItemKindEvent' }
DropBarIconKindField{ link = 'CmpItemKindField' }
DropBarIconKindFile{ link = 'NormalFloat' }
DropBarIconKindFolder{ link = 'Directory' }
DropBarIconKindForStatement{ link = 'Repeat' }
DropBarIconKindFunction{ link = 'Function' }
DropBarIconKindH1Marker{ link = 'markdownH1' }
DropBarIconKindH2Marker{ link = 'markdownH2' }
DropBarIconKindH3Marker{ link = 'markdownH3' }
DropBarIconKindH4Marker{ link = 'markdownH4' }
DropBarIconKindH5Marker{ link = 'markdownH5' }
DropBarIconKindH6Marker{ link = 'markdownH6' }
DropBarIconKindIdentifier{ link = 'CmpItemKindVariable' }
DropBarIconKindIfStatement{ link = 'Conditional' }
DropBarIconKindInterface{ link = 'CmpItemKindInterface' }
DropBarIconKindKeyword{ link = 'Keyword' }
DropBarIconKindList{ link = 'SpecialChar' }
DropBarIconKindMacro{ link = 'Macro' }
DropBarIconKindMarkdownH1{ link = 'markdownH1' }
DropBarIconKindMarkdownH2{ link = 'markdownH2' }
DropBarIconKindMarkdownH3{ link = 'markdownH3' }
DropBarIconKindMarkdownH4{ link = 'markdownH4' }
DropBarIconKindMarkdownH5{ link = 'markdownH5' }
DropBarIconKindMarkdownH6{ link = 'markdownH6' }
DropBarIconKindMethod{ link = 'CmpItemKindMethod' }
DropBarIconKindModule{ link = 'CmpItemKindModule' }
DropBarIconKindNamespace{ link = 'NameSpace' }
DropBarIconKindNull{ link = 'Constant' }
DropBarIconKindNumber{ link = 'Number' }
DropBarIconKindObject{ link = 'Statement' }
DropBarIconKindOperator{ link = 'Operator' }
DropBarIconKindPackage{ link = 'CmpItemKindModule' }
DropBarIconKindPair{ link = 'String' }
DropBarIconKindProperty{ link = 'CmpItemKindProperty' }
DropBarIconKindReference{ link = 'CmpItemKindReference' }
DropBarIconKindRepeat{ link = 'Repeat' }
DropBarIconKindScope{ link = 'NameSpace' }
DropBarIconKindSpecifier{ link = 'Specifier' }
DropBarIconKindStatement{ link = 'Statement' }
DropBarIconKindString{ link = 'String' }
DropBarIconKindStruct{ link = 'CmpItemKindStruct' }
DropBarIconKindSwitchStatement{ link = 'Conditional' }
DropBarIconKindTerminal{ link = 'Number' }
DropBarIconKindType{ link = 'CmpItemKindClass' }
DropBarIconKindTypeParameter{ link = 'CmpItemKindTypeParameter' }
DropBarIconKindUnit{ link = 'CmpItemKindUnit' }
DropBarIconKindValue{ link = 'Number' }
DropBarIconKindVariable{ link = 'CmpItemKindVariable' }
DropBarIconKindWhileStatement{ link = 'Repeat' }
DropBarIconUIIndicator{ link = 'SpecialChar' }
DropBarIconUIPickPivot{ link = 'Error' }
DropBarIconUISeparator{ link = 'SpecialChar' }
DropBarIconUISeparatorMenu{ link = 'DropBarIconUISeparator' }
DropBarMenuCurrentContext{ link = 'PmenuSel' }
DropBarMenuFloatBorder{ link = 'FloatBorder' }
DropBarMenuHoverEntry{ link = 'Visual' }
DropBarMenuHoverIcon{ reverse = true }
DropBarMenuHoverSymbol{ bold = true }
DropBarMenuNormalFloat{ link = 'NormalFloat' }
DropBarMenuSbar{ link = 'PmenuSbar' }
DropBarMenuThumb{ link = 'PmenuThumb' }
DropBarPreview{ link = 'Visual' }
DropBarKindArrayundefined
DropBarKindBooleanundefined
DropBarKindBreakStatementundefined
DropBarKindCallundefined
DropBarKindCaseStatementundefined
DropBarKindClassundefined
DropBarKindConstantundefined
DropBarKindConstructorundefined
DropBarKindContinueStatementundefined
DropBarKindDeclarationundefined
DropBarKindDeleteundefined
DropBarKindDoStatementundefined
DropBarKindElseStatementundefined
DropBarKindEnumundefined
DropBarKindEnumMemberundefined
DropBarKindEventundefined
DropBarKindFieldundefined
DropBarKindFileundefined
DropBarKindFolderundefined
DropBarKindForStatementundefined
DropBarKindFunctionundefined
DropBarKindH1Markerundefined
DropBarKindH2Markerundefined
DropBarKindH3Markerundefined
DropBarKindH4Markerundefined
DropBarKindH5Markerundefined
DropBarKindH6Markerundefined
DropBarKindIdentifierundefined
DropBarKindIfStatementundefined
DropBarKindInterfaceundefined
DropBarKindKeywordundefined
DropBarKindListundefined
DropBarKindMacroundefined
DropBarKindMarkdownH1undefined
DropBarKindMarkdownH2undefined
DropBarKindMarkdownH3undefined
DropBarKindMarkdownH4undefined
DropBarKindMarkdownH5undefined
DropBarKindMarkdownH6undefined
DropBarKindMethodundefined
DropBarKindModuleundefined
DropBarKindNamespaceundefined
DropBarKindNullundefined
DropBarKindNumberundefined
DropBarKindObjectundefined
DropBarKindOperatorundefined
DropBarKindPackageundefined
DropBarKindPropertyundefined
DropBarKindReferenceundefined
DropBarKindRepeatundefined
DropBarKindScopeundefined
DropBarKindSpecifierundefined
DropBarKindStatementundefined
DropBarKindStringundefined
DropBarKindStructundefined
DropBarKindSwitchStatementundefined
DropBarKindTerminalundefined
DropBarKindTypeundefined
DropBarKindTypeParameterundefined
DropBarKindUnitundefined
DropBarKindValueundefined
DropBarKindVariableundefined
DropBarKindWhileStatementundefined
</details>

Developers

Architecture

                                              ┌──────────────────┐
                                              │winbar at win 1000│ {k}th symbol clicked
                                              │ contaning buf 1  ├──────────────────────┐
                                              └───────┬─▲────────┘                      │
                                                      ▼ │                               │
                                          _G.dropbar.get_dropbar_str()                  │
                                                      │ ▲                               │
    ┌──────────────┐                           ┌──────▼─┴──────┐                        │
    │sources       │                           │_G.dropbar.bars│                        │
    │ ┌───┐        │                           └──────┬─▲──────┘                        │
    │ │lsp│        │                       ┌───────┬──▼─┴──┬───────┐                    │
    │ └───┘        │                     ┌─▼─┐   ┌─┴─┐   ┌─┴─┐    ...                   │
    │ ┌──────────┐ │                     │[1]│   │[2]│   │[3]│                          │
    │ │treesitter│ │                     └─┬─┘   └─┬─┘   └─┬─┘                          │
    │ └──────────┘ │                       │      ...     ...                           │
    │  ...         │                       └──┬─▲─────────────┬──────┐                  │
    └─────┬─▲──────┘                        ┌─▼─┴──┐       ┌──┴───┐ ...                 │
          │ │                               │[1000]│       │[1015]│                     │
          │ │                               └─┬─▲──┘       └──────┘                     │
          │ │                    __tostring() │ │ return string cache                   │
          │ │                             ┌───▼─┴───┐                    ┌──────────────▼──────────────┐
          │ │                             │dropbar_t├────────────────────▶     _G.dropbar.callbacks    │
          │ │    On update events         └───┬─▲───┘  register symbol   └──────────────┬──────────────┘
          │ │ get_symbols(1, 1000, <cursor>)  │ │    on_click() callbacks               │
          │ └─────────────────────────────────┘ │                       ┌──────────┬────▼─────┬─────────┐
          └─────────────────────────────────────┘                   ┌───▼────┐ ┌───┴────┐ ┌───┴────┐   ...
      each source returns dropbar_symbol_t[]                        │['buf1']│ │['buf2']│ │['buf3']│
     dropbar_t adds symbols as its components                       └───┬────┘ └───┬────┘ └───┬────┘
          dropbar_t flushes string cache                                │         ...        ...
                                                                        └────────┬───────────────┬─────────┐
                                                                           ┌─────▼─────┐   ┌─────┴─────┐  ...
                                                                           │['win1000']│   │['win1015']│
                                                                           └─────┬─────┘   └─────┬─────┘
                                                                                 │              ...
                                                                  ┌─────────┬────▼────┬─────────┐
                                                              ┌───┴───┐    ...   ┌────┴────┐   ...
                                                              │['fn1']│          │['fn{k}']│
                                                              └───────┘          └────┬────┘
                                                                                      ▼
                                                      invoke _G.dropbar.bars[1][1000].components[k]:on_click()
                                                                                      │
                                                                                      ▼
                                                                     open drop-down menu, goto symbol, etc

Classes

dropbar_t

Declared and defined in lua/dropbar/bar.lua.


dropbar_t is a class that represents a winbar.

It gets symbols<sub>dropbar_symbol_t[]</sub> from sources<sub>dropbar_source_t</sub> and renders them to a string. It is also responsible for registering on_click callbacks of each symbol in the global table _G.dropbar.callbacks so that nvim knows which function to call when a symbol is clicked.

dropbar_t has the following fields:

FieldTypeDescription
bufintegerthe buffer the dropbar is attached to
winintegerthe window the dropbar is attached to
sourcesdropbar_source_t[]sources<sub>dropbar_source_t[]</sub> that provide symbols to the dropbar
separatordropbar_symbol_tseparator<sub>dropbar_symbol_t</sub> between symbols
padding{left: integer, right: integer}padding to use between the winbar and the window border
extendsdropbar_symbol_tsymbol<sub>dropbar_symbol_t</sub> to use when a symbol is truncated
componentsdropbar_symbol_t[]symbols<sub>dropbar_symbol_t[]</sub> to render
string_cachestringstring cache of the dropbar
in_pick_modeboolean?whether the dropbar is in pick mode
symbol_on_hoverdropbar_symbol_tThe previous symbol<sub>dropbar_symbol_t[]</sub> under mouse hovering in the dropbar
last_update_request_timefloat?timestamp of the last update request in ms, see :h uv.now()

dropbar_t has the following methods:

MethodDescription
dropbar_t:new(opts: dropbar_opts_t): dropbar_tconstructor of dropbar_t
dropbar_t:del()destructor of dropbar_t
dropbar_t:displaywidth(): integerreturns the display width of the dropbar
dropbar_t:truncate()truncates the dropbar if it exceeds the display width <br> *side effect: changes dropbar components<sub>dropbar_symbol_t[]
dropbar_t:cat(plain: boolean?): stringconcatenates the dropbar components into a string with substrings for highlights and click support if plain is not set; else returns a plain string without substrings for highlights and click support
dropbar_t:redraw()redraws the dropbar
dropbar_t:update()update dropbar components<sub>dropbar_symbol_t[]</sub> and redraw the dropbar afterwards
dropbar_t:pick_mode_wrap(fn: fun(...): T?, ...): T?executes fn with parameters ... in pick mode
dropbar_t:pick(idx: integer?)pick a component from dropbar in interactive pick mode if idx is not given; else pick the idxth component directly
dropbar_t:update_current_context_hl(bar_idx: integer)Update the current context highlight hl-DropBarCurrentContext and hl-DropBarIconCurrentContext assuming the bar_idx th symbol is clicked in the winbar
dropbar_t:update_hover_hl(col: integer?)Highlight the symbol at col as if the mouse is hovering on it
dropbar_t:__tostring(): stringmeta method to convert dropbar_t to its string representation

dropbar_symbol_t

Declared and defined in lua/dropbar/bar.lua.


dropbar_symbol_t is a class that represents a symbol in a dropbar. It is the basic element of dropbar_t and dropbar_menu_entry_t.

dropbar_symbol_t has the following fields:

FieldTypeDescription
namestringname of the symbol
iconstringicon of the symbol
name_hlstring?highlight of the name of the symbol
icon_hlstring?highlight of the icon of the symbol
wininteger?the source window the symbol is shown in
bufinteger?the source buffer the symbol is defined in
viewtable?The original view of the source window, created by winsaveview(), used to restore the view after previewing the symbol
bardropbar_t?the dropbar<sub>dropbar_t</sub> the symbol belongs to, if the symbol is shown inside a winbar
menudropbar_menu_t?menu<sub>dropbar_menu_t</sub> associated with the symbol, if the symbol is shown inside a winbar
entrydropbar_menu_entry_t?the dropbar menu entry<sub>dropbar_menu_entry_t</sub> the symbol belongs to, if the symbol is shown inside a menu
childrendropbar_symbol_t[]?children of the symbol (e.g. a children of a function symbol can be local variables inside the function)
siblingsdropbar_symbol_t[]?siblings of the symbol (e.g. a sibling of a symbol that represents a level 4 markdown heading can be other headings with level 4)
bar_idxinteger?index of the symbol in the dropbar<sub>dropbar_t</sub>
entry_idxinteger?index of the symbol in the menu entry<sub>dropbar_menu_entry_t</sub>
sibling_idxinteger?index of the symbol in the siblings
range{start: {line: integer, character: integer}, end: {line: integer, character: integer}}range of the symbol in the source window
on_clickfun(this: dropbar_symbol_t, min_width: integer?, n_clicks: integer?, button: string?, modifiers: string?)|false?callback to invoke when the symbol is clicked, force disable on_click when the value if set to false
callback_idxinteger?idx of the on_click callback in _G.dropbar.callbacks[buf][win], use this to index callback function because bar_idx could change after truncate
optsdropbar_symbol_opts_t?options passed to winbar_symbol_t:new() when the symbols is created
datatable?any extra data associated with the symbol

dropbar_symbol_t has the following methods:

MethodDescription
dropbar_symbol_t:new(opts: dropbar_symbol_t?): dropbar_symbol_tconstructor of dropbar_symbol_t
dropbar_symbol_t:del()destructor of dropbar_symbol_t
dropbar_symbol_t:merge(opts: dropbar_symbol_t)create a new dropbar_symbol_t by merging opts into the current dropbar_symbol_t
dropbar_symbol_t:cat(plain: boolean?): stringconcatenates the symbol into a string with substrings for highlights and click support if plain is not set; else returns a plain string without substrings for highlights and click support
dropbar_symbol_t:displaywidth(): integerreturns the display width of the symbol
dropbar_symbol_t:bytewidth(): integerreturns the byte width of the symbol
dropbar_symbol_t:jump()jump to the start of the range of the dropbar symbol
dropbar_symbol_t:preview(orig_view: table?)preview the symbol in the source window, use orig_view as the original view of the source window (to restore win view after preview ends)
dropbar_symbol_t:preview_restore_hl()clear the preview highlights in the source window
dropbar_symbol_t:preview_restore_view()restore the view in the source window after previewing the symbol
dropbar_symbol_t:swap_field(field: string, new_val: any)temporarily change the content of a dropbar symbol
dropbar_symbol_t:restore()restore the original value of the fields of a dropbar symbol changed in dropbar_symbol_t:swap_field()

dropbar_menu_t

Declared and defined in lua/dropbar/menu.lua.


dropbar_menu_t is a class that represents a drop-down menu.

dropbar_menu_t has the following fields:

FieldTypeDescription
bufintegerbuffer number of the menu
winintegerwindow id of the menu
is_openedboolean?whether the menu is currently opened
entriesdropbar_menu_entry_t[]entries in the menu
win_configstablewindow configuration, value can be a function, see menu configuration options
_win_configstable?evaluated window configuration
cursorinteger[]?initial cursor position
prev_wininteger?previous window, assigned when calling new() or automatically determined in open()
prev_bufinteger?previous buffer, assigned when calling new() or automatically determined in open()
sub_menudropbar_menu_t?submenu, assigned when calling new() or automatically determined when a new menu opens
prev_menudropbar_menu_t?previous menu, assigned when calling new() or automatically determined in open()
clicked_atinteger[]?last position where the menu was clicked, 1,0-indexed
prev_cursorinteger[]?previous cursor position in the menu
symbol_previeweddropbar_symbol_t?symbol begin previewed in the menu

dropbar_menu_t has the following methods:

MethodDescription
dropbar_menu_t:new(opts: dropbar_menu_t?): dropbar_menu_tconstructor of dropbar_menu_t
dropbar_menu_t:del()destructor of dropbar_menu_t
dropbar_menu_t:eval_win_configs()evaluate window configurations dropbar_menu_t.win_configs and store the result in dropbar_menu_t._win_configs
dropbar_menu_t:get_component_at(pos: integer[], look_ahead: boolean?): dropbar_symbol_t?, { start: integer, end: integer }?get the component<sub>dropbar_symbol_t</sub> at position pos and its range it occupies in the entry it belongs to
dropbar_menu_t:click_at(pos: integer[], min_width: integer?, n_clicks: integer?, button: string?, modifiers: string?)simulate a click at pos in the menu
dropbar_menu_t:click_on(symbol: dropbar_symbol_t, min_width: integer?, n_clicks: integer?, button: string?, modifiers: string?)simulate a click at the component symbol<sub>dropbar_symbol_t</sub> of the menu
dropbar_menu_t:update_hover_hl(pos: integer[])update the hover highlights (DropBarMenuHover*) assuming the cursor/mouse is hovering at pos in the menu
dropbar_menu_t:update_current_context_hl(linenr: integer?)update the current context highlight (hl-DropBarMenuCurrentContext) assuming the cursor is at line linenr in the menu
dropbar_menu_t:make_buf()create the menu buffer from the entries<sub>dropbar_menu_entry_t, must be called after self:eval_win_configs()
dropbar_menu_t:make_win()open the menu window with self._win_configs and set menu options, must be called after self:make_buf()
dropbar_menu_t:override(opts: dropbar_menu_t?)override menu options
dropbar_menu_t:preview_symbol_at(pos: integer[], look_ahead: boolean?)preview the component<sub>dropbar_symbol_t</sub> at position pos in the menu
dropbar_menu_t:finish_preview(restore_view: boolean?)finish previewing the symbol, always clear the preview highlights in the source buffer, restore the original view of the source window if restore_view is true or nil
dropbar_menu_t:quick_navigation(new_cursor: integer[])nagivate the cursor to the neartest clickable component on the current menu entry in the direction of cursor movement
dropbar_menu_t:open(opts: dropbar_menu_t?)open the menu with options opts
dropbar_menu_t:close(restore_view: boolean?)close the menu
dropbar_menu_t:toggle(opts: dropbar_menu_t?)toggle the menu
dropbar_menu_t:fuzzy_find_restore_entries()restore menu buffer and entries in their original order before modified by fuzzy search
dropbar_menu_t:fuzzy_find_close()stop fuzzy finding and clean up allocated memory
dropbar_menu_t:fuzzy_find_click_on_entry(component: number|fun(dropbar_menu_entry_t):dropbar_symbol_t)click on the currently selected fuzzy menu entry, choosing the component to click according to component
dropbar_menu_t:fuzzy_find_open(opts: table?)open the fuzzy search menu, overriding fzf configuration with opts argument
dropbar_menu_t:fuzzy_find_navigate(direction: 'up'|'down'|integer)navigate to the nth previous/next entry while fuzzy finding

dropbar_menu_entry_t

Declared and defined in lua/dropbar/menu.lua.


dropbar_menu_entry_t is a class that represents an entry (row) in a drop-down menu. A dropbar_menu_t instance is made up of multiple dropbar_menu_entry_t instances while a dropbar_menu_entry_t instance can contain multiple dropbar_symbol_t instances.

dropbar_menu_entry_t has the following fields:

FieldTypeDescription
separatordropbar_symbol_tseparator to use in the entry
padding{left: integer, right: integer}padding to use between the menu entry and the menu border
componentsdropbar_symbol_t[]components<sub>dropbar_symbol_t[]</sub> in the entry
virt_textstring[][]?list of virtual text chunks to display below the entry
menudropbar_menu_t?the menu the entry belongs to
idxinteger?the index of the entry in the menu

dropbar_menu_entry_t has the following methods:

MethodDescription
dropbar_menu_entry_t:new(opts: dropbar_menu_entry_t?): dropbar_menu_entry_tconstructor of dropbar_menu_entry_t
dropbar_menu_entry_t:del()destructor of dropbar_menu_entry_t
dropbar_menu_entry_t:cat(): string, dropbar_menu_hl_info_tconcatenate the components into a string, returns the string and highlight info<sub>dropbar_menu_hl_info_t
dropbar_menu_entry_t:displaywidth(): integercalculate the display width of the entry
dropbar_menu_entry_t:bytewidth(): integercalculate the byte width of the entry
dropbar_menu_entry_t:first_clickable(offset: integer?): dropbar_symbol_t?, { start: integer, end: integer }?get the first clickable component<sub>dropbar_symbol_t</sub> and its range in the dropbar menu entry starting from offset, which defaults to 0
dropbar_menu_entry_t:get_component_at(col: integer, look_ahead: boolean?): dropbar_symbol_t?, { start: integer, end: integer }?get the component<sub>dropbar_symbol_t</sub> at column position col and the range it occupies in the menu entry
dropbar_menu_entry_t:prev_clickable(col: integer): dropbar_symbol_t?, { start: integer, end: integer }?get the previous clickable component<sub>dropbar_symbol_t</sub> and its range in the dropbar menu entry given current column position col
dropbar_menu_entry_t:next_clickable(col: integer): dropbar_symbol_t?, { start: integer, end: integer }?get the next clickable component<sub>dropbar_symbol_t</sub> and its range in the dropbar menu entry given current column position col

dropbar_menu_hl_info_t

Declared and defined in lua/dropbar/menu.lua.


dropbar_menu_hl_info_t is a class that represents a highlight range in a single line of a drop-down menu.

dropbar_menu_hl_info_t has the following fields:

FieldTypeDescription
startintegerstart column of the higlighted range
endintegerend column of the higlighted range
hlgroupstringhighlight group to use for the range
nsinteger?namespace to use for the range, nil if using default namespace

dropbar_source_t

Declared in lua/dropbar/sources/init.lua.


dropbar_source_t is a class that represents a source of a drop-down menu.

dropbar_source_t has the following field:

FieldTypeDescription
get_symbolsfunction(buf: integer, win: integer, cursor: integer[]): dropbar_symbol_t[]returns the symbols<sub>dropbar_symbol_t[]</sub> to show in the winbar given buffer number buf and cursor position cursor

dropbar_select_opts_t

Declared in lua/dropbar/utils/menu.lua.


dropbar_select_opts_t is a class that represents the options passed to utils.menu.select (vim.ui.select with some extensions).

dropbar_select_opts_t has the following fields:

FieldTypeDescription
promptstring?determines what will be shown at the top of the select menu.
format_itemfun(item: any): string, string[][]?formats the list items for display in the menu, and optionally formats virtual text chunks to be shown below the item.
previewfun(self: dropbar_symbol_t, item: any, idx: integer)previews the list item under the cursor.
preview_closefun(self: dropbar_symbol_t, item: any, idx: integer)closes the preview when the menu is closed.

Making a New Source

A dropbar_source_t instance is just a table with get_symbols field set to a function that returns an array of dropbar_symbol_t instances given the buffer number, the window id, and the cursor position.

We have seen a simple example of a custom source in the default config of opts.bar.sources where the second source is set to a combination of lsp/treesitter/markdown sources using the utils.source.fallback() factory function, which simply returns a table containing a get_symbols() function where each source passed to utils.source.fallback() is queried and the first non-empty result get from the sources is returned as the result of the combined source.

Here is another example of a custom source that will always return two symbols saying 'Hello' and 'dropbar' with highlights 'hl-Keyword' and 'hl-Title' and a smiling face shown in 'hl-WarningMsg' at the start of the first symbol; clicking on the first symbol will show a notification message saying 'Have you smiled today?', followed by the smiling face icon used in the in dropbar symbol:

local bar = require('dropbar.bar')
local custom_source = {
  get_symbols = function(_, _, _)
    return {
      bar.dropbar_symbol_t:new({
        icon = ' ',
        icon_hl = 'WarningMsg',
        name = 'Hello',
        name_hl = 'Keyword',
        on_click = function(self)
          vim.notify('Have you smiled today? ' .. self.icon)
        end,
      }),
      bar.dropbar_symbol_t:new({
        name = 'dropbar',
        name_hl = 'Title',
      }),
    }
  end,
}

Add this source to opts.bar.sources table to see it in action:

require('dropbar').setup({
  bar = {
    sources = {
      custom_source,
    },
  },
})

Making a Source With Drop-Down Menus

The following example shows how to make a source that returns two symbols with the first symbol having a drop-down menu with a single entry saying 'World':

local bar = require('dropbar.bar')
local menu = require('dropbar.menu')
local custom_source = {
  get_symbols = function(_, _, _)
    return {
      bar.dropbar_symbol_t:new({
        icon = ' ',
        icon_hl = 'WarningMsg',
        name = 'Hello',
        name_hl = 'Keyword',
        on_click = function(self)
          self.menu = menu.dropbar_menu_t:new({
            entries = {
              menu.dropbar_menu_entry_t:new({
                components = {
                  bar.dropbar_symbol_t:new({
                    icon = ' ',
                    icon_hl = 'WarningMsg',
                    name = 'World',
                    name_hl = 'Keyword',
                    on_click = function(sym)
                      vim.notify('Have you smiled today? ' .. sym.icon)
                    end,
                  }),
                },
              }),
            },
          })
          self.menu:toggle()
        end,
      }),
      bar.dropbar_symbol_t:new({
        name = 'dropbar',
        icon = ' ',
        name_hl = 'Special',
        icon_hl = 'Error',
      }),
    }
  end,
}

Default on_click() Callback

dropbar_symbol_t:new() defines a default on_click() callback if non is provided.

The default on_click() callback will look for these fields in the symbol instance and create a drop-down menu accordingly on click, for more information about these fields see dropbar_symbol_t.

For creating the drop-down menu:

For jumping to the symbol or previewing it:

The following example shows a source that utilizes the default on_click() callback:

local bar = require('dropbar.bar')
local custom_source = {
  get_symbols = function(buf, win, _)
    return {
      bar.dropbar_symbol_t:new({
        name = 'Section 1',
        name_hl = 'Keyword',
        siblings = {
          bar.dropbar_symbol_t:new({
            name = 'Section 2',
            name_hl = 'WarningMsg',
          }),
          bar.dropbar_symbol_t:new({
            name = 'Section 3',
            name_hl = 'Error',
          }),
          bar.dropbar_symbol_t:new({
            name = 'Section 4',
            name_hl = 'String',
            children = {
              bar.dropbar_symbol_t:new({
                buf = buf,
                win = win,
                name = 'Section 4.1',
                name_hl = 'String',
                -- Will jump to line 3, col 4 (0-indexed) when clicked in the
                -- menu
                range = {
                  start = { line = 3, character = 4 },
                  ['end'] = { line = 5, character = 6 },
                }
              }),
            },
          }),
        },
      }),
    }
  end,
}

To see this source in action add it to opts.bar.sources table:

require('dropbar').setup({
  bar = {
    sources = {
      custom_source,
    },
  },
})

Lazy-Loading Expensive Fields

If the symbol fields siblings or children are expensive to compute, you can use meta-tables to lazy-load them, so that they are only computed when a menu is opened:

local bar = require('dropbar.bar')
local custom_source = {
  get_symbols = function(_, _, _)
    return {
      bar.dropbar_symbol_t:new(setmetatable({
        name = 'Section 1',
        name_hl = 'Keyword',
      }, {
        __index = function(self, key)
          if key == 'siblings' then
            self[siblings] = -- [[ compute siblings ]]
            return self[siblings]
          end
          if key == 'children' then
            self[children] = -- [[ compute children ]]
            return self[children]
          end
          -- ...
        end,
      })),
    }
  end,
}

To see concrete examples of lazy-loading see lua/dropbar/sources.

Practical Examples

Highlight File Name Using Custom Highlight Group DropBarFileName
local dropbar = require('dropbar')
local sources = require('dropbar.source')
local utils = require('dropbar.sources')

vim.api.nvim_set_hl(0, 'DropBarFileName', { fg = '#FFFFFF', italic = true })

local custom_path = {
  get_symbols = function(buff, win, cursor)
    local symbols = sources.path.get_symbols(buff, win, cursor)
    symbols[#symbols].name_hl = 'DropBarFileName'
    if vim.bo[buff].modified then
      symbols[#symbols].name = symbols[#symbols].name .. ' [+]'
      symbols[#symbols].name_hl = 'DiffAdded'
    end
    return symbols
  end,
}

dropbar.setup({
  bar = {
    sources = function(buf, _)
      if vim.bo[buf].ft == 'markdown' then
        return {
          custom_path,
          sources.markdown,
        }
      end
      if vim.bo[buf].buftype == 'terminal' then
        return {
          sources.terminal,
        }
      end
      return {
        custom_path,
        utils.source.fallback {
          sources.lsp,
          sources.treesitter,
        },
      }
    end,
  },
})

Similar Projects