diff --git a/README.md b/README.md
index 682b8d80..b2117847 100644
--- a/README.md
+++ b/README.md
@@ -1973,6 +1973,7 @@ multiple `dropbar_menu_entry_t` instances while a
| `separator` | [`dropbar_symbol_t`](#dropbar_symbol_t) | separator to use in the entry |
| `padding` | `{left: integer, right: integer}` | padding to use between the menu entry and the menu border |
| `components` | [`dropbar_symbol_t[]`](#dropbar_symbol_t) | components[`dropbar_symbol_t[]`](#dropbar_symbol_t) in the entry |
+| `virt_text` | `string[][]?` | list of virtual text chunks to display below the entry |
| `menu` | [`dropbar_menu_t?`](#dropbar_menu_t) | the menu the entry belongs to |
| `idx` | `integer?` | the index of the entry in the menu |
diff --git a/doc/dropbar.txt b/doc/dropbar.txt
index 7b42fe32..f9dcd27e 100644
--- a/doc/dropbar.txt
+++ b/doc/dropbar.txt
@@ -1832,21 +1832,21 @@ contain multiple `dropbar_symbol_t` instances.
`dropbar_menu_entry_t` has the following fields:
-dropbar_menu_t.separator *dropbar_menu_t.separator*
+dropbar_menu_entry_t.separator *dropbar_menu_t.separator*
Separator to use in the entry
Type ~
`dropbar_symbol_t`
-dropbar_menu_t.padding *dropbar_menu_t.padding*
+dropbar_menu_entry_t.padding *dropbar_menu_t.padding*
Padding to use between the menu entry and the menu border
Type ~
{ left: integer, right: integer }
-dropbar_menu_t.components *dropbar_menu_t.components*
+dropbar_menu_entry_t.components *dropbar_menu_t.components*
Symbols got from sources |dropbar-developers-classes-dropbar_source_t|
in the entry
@@ -1854,14 +1854,22 @@ dropbar_menu_t.components *dropbar_menu_t.components*
Type ~
`dropbar_symbol_t`[]
-dropbar_menu_t.menu *dropbar_menu_t.menu*
+dropbar_menu_entry_t.virt_text *dropbar_menu_t.virt_text*
+
+ Symbols got from sources |dropbar-developers-classes-dropbar_source_t|
+ in the entry
+
+ Type ~
+ `string`[][]?
+
+dropbar_menu_entry_t.menu *dropbar_menu_t.menu*
The menu the entry belongs to
Type ~
`dropbar_menu_t`?
-dropbar_menu_t.idx *dropbar_menu_t.idx*
+dropbar_menu_entry_t.idx *dropbar_menu_t.idx*
The index of the entry in the menu
diff --git a/lua/dropbar/menu.lua b/lua/dropbar/menu.lua
index 6e27a032..4da1b0d2 100644
--- a/lua/dropbar/menu.lua
+++ b/lua/dropbar/menu.lua
@@ -17,6 +17,7 @@ _G.dropbar.menus = {}
---@field separator dropbar_symbol_t
---@field padding {left: integer, right: integer}
---@field components dropbar_symbol_t[]
+---@field virt_text string[][]?
---@field menu dropbar_menu_t? the menu the entry belongs to
---@field idx integer? the index of the entry in the menu
local dropbar_menu_entry_t = {}
@@ -26,6 +27,7 @@ dropbar_menu_entry_t.__index = dropbar_menu_entry_t
---@field separator dropbar_symbol_t?
---@field padding {left: integer, right: integer}?
---@field components dropbar_symbol_t[]?
+---@field virt_text string[][]?
---@field menu dropbar_menu_t? the menu the entry belongs to
---@field idx integer? the index of the entry in the menu
@@ -398,8 +400,9 @@ end
---highlights to the buffer
function dropbar_menu_t:fill_buf()
local lines = {} ---@type string[]
+ local extmarks = {} ---@type table
local hl_info = {} ---@type dropbar_menu_hl_info_t[][]
- for _, entry in ipairs(self.entries) do
+ for i, entry in ipairs(self.entries) do
local line, entry_hl_info = entry:cat()
-- Pad lines with spaces to the width of the window
-- This is to make sure hl-DropBarMenuCurrentContext colors
@@ -413,9 +416,29 @@ function dropbar_menu_t:fill_buf()
)
)
table.insert(hl_info, entry_hl_info)
+ if entry.virt_text then
+ table.insert(extmarks, i, entry.virt_text)
+ end
end
vim.api.nvim_buf_set_lines(self.buf, 0, -1, false, lines)
self:add_hl(hl_info)
+
+ local extmark_ns = vim.api.nvim_create_namespace('DropBarExtmarks')
+ vim.api.nvim_buf_clear_namespace(self.buf, extmark_ns, 0, -1)
+
+ for i, virt_text in pairs(extmarks) do
+ if type(i) == 'number' then
+ vim.api.nvim_buf_set_extmark(
+ self.buf,
+ extmark_ns,
+ i - 1, -- 0-indexed
+ 0,
+ {
+ virt_lines = { virt_text },
+ }
+ )
+ end
+ end
end
---Make a buffer for the menu and set buffer-local keymaps