diff --git a/autoload/bufferline.vim b/autoload/bufferline.vim index b63d7e49..6e29d554 100644 --- a/autoload/bufferline.vim +++ b/autoload/bufferline.vim @@ -11,11 +11,11 @@ endfunc "======================== function! bufferline#update(...) - call luaeval("require'barbar.render'.update(_A)", get(a:, 1, v:null)) + call luaeval("require'barbar.ui.render'.update(_A)", get(a:, 1, v:null)) endfu function! bufferline#update_async(...) - call timer_start(get(a:, 2, 1), {-> luaeval("require'barbar.render'.update(_A)", get(a:, 1, v:null))}) + call timer_start(get(a:, 2, 1), {-> luaeval("require'barbar.ui.render'.update(_A)", get(a:, 1, v:null))}) endfu function! bufferline#render(update_names) abort @@ -43,7 +43,7 @@ function! bufferline#order_by_window_number() endfunc function! bufferline#close(abuf) - call luaeval("require'barbar.render'.close_buffer_animated(_A)", a:abuf) + call luaeval("require'barbar.ui.render'.close_buffer_animated(_A)", a:abuf) endfunc function! bufferline#close_direct(abuf) diff --git a/lua/barbar.lua b/lua/barbar.lua index 4cf04d80..ec02e263 100644 --- a/lua/barbar.lua +++ b/lua/barbar.lua @@ -10,7 +10,7 @@ local api = require'barbar.api' local bbye = require'barbar.bbye' local events = require'barbar.events' local notify = require'barbar.utils'.notify -local render = require'barbar.render' +local render = require'barbar.ui.render' local state = require'barbar.state' local utils = require'barbar.utils' diff --git a/lua/barbar/api.lua b/lua/barbar/api.lua index 01ecf36a..baf6d046 100644 --- a/lua/barbar/api.lua +++ b/lua/barbar/api.lua @@ -21,8 +21,8 @@ local bbye = require'barbar.bbye' local Buffer = require'barbar.buffer' local config = require'barbar.config' local JumpMode = require'barbar.jump_mode' -local Layout = require'barbar.layout' -local render = require'barbar.render' +local Layout = require'barbar.ui.layout' +local render = require'barbar.ui.render' local state = require'barbar.state' local utils = require'barbar.utils' diff --git a/lua/barbar/events.lua b/lua/barbar/events.lua index 9adab195..608edb20 100644 --- a/lua/barbar/events.lua +++ b/lua/barbar/events.lua @@ -26,7 +26,7 @@ local bbye = require'barbar.bbye' local config = require'barbar.config' local highlight = require'barbar.highlight' local JumpMode = require'barbar.jump_mode' -local render = require'barbar.render' +local render = require'barbar.ui.render' local state = require'barbar.state' local utils = require'barbar.utils' @@ -48,7 +48,7 @@ function events.augroups(clear) end return create_augroup('barbar_misc', {clear = clear}), - create_augroup('barbar_render', {clear = clear}) + create_augroup('barbar.ui.render', {clear = clear}) end --- What to do when clicking a buffer close button diff --git a/lua/barbar/layout.lua b/lua/barbar/ui/layout.lua similarity index 93% rename from lua/barbar/layout.lua rename to lua/barbar/ui/layout.lua index 7d908e2f..10253123 100644 --- a/lua/barbar/layout.lua +++ b/lua/barbar/ui/layout.lua @@ -26,17 +26,17 @@ local SLASH_LEN = #'/' --- The length of one space (`#' '`) local SPACE_LEN = #' ' ---- @class barbar.layout.data +--- @class barbar.ui.layout.data --- @field total_width integer the total width of the tabline, equals to &columns ---- @field left barbar.layout.data.side left offset data ---- @field right barbar.layout.data.side right offset data ---- @field buffers barbar.layout.data.buffers buffer data ---- @field tabpages barbar.layout.data.tabpages tabpage data +--- @field left barbar.ui.layout.data.side left offset data +--- @field right barbar.ui.layout.data.side right offset data +--- @field buffers barbar.ui.layout.data.buffers buffer data +--- @field tabpages barbar.ui.layout.data.tabpages tabpage data ---- @class barbar.layout.data.side +--- @class barbar.ui.layout.data.side --- @field width integer the amount of space allocated ---- @class barbar.layout.data.buffers +--- @class barbar.ui.layout.data.buffers --- @field width integer the amount of space allocated to the buffers --- @field pinned_width integer the amount of space used by pinned buffers --- @field unpinned_width integer the amount of space used by pinned buffers @@ -46,16 +46,16 @@ local SPACE_LEN = #' ' --- @field base_widths integer[] the minimum amount of space taken up by each buffer --- @field scroll_max integer the maximum position which can be scrolled to ---- @class barbar.layout.data.tabpages +--- @class barbar.ui.layout.data.tabpages --- @field width integer the amount of space allocated to the tabpage indicator ---- @class barbar.Layout +--- @class barbar.ui.layout --- @field buffers integer[] different from `state.buffers` in that the `hide` option is respected. Only updated when calling `calculate_buffers_width`. local Layout = { buffers = {} } --- Calculate the current layout of the bufferline. ---- @return barbar.layout.data +--- @return barbar.ui.layout.data function Layout.calculate() local total_width = get_option('columns') diff --git a/lua/barbar/groups.lua b/lua/barbar/ui/nodes.lua similarity index 66% rename from lua/barbar/groups.lua rename to lua/barbar/ui/nodes.lua index ba0be85a..cc707af5 100644 --- a/lua/barbar/groups.lua +++ b/lua/barbar/ui/nodes.lua @@ -1,34 +1,34 @@ -- --- groups.lua +-- nodes.lua -- local table_insert = table.insert local strcharpart = vim.fn.strcharpart --- @type function local strwidth = vim.api.nvim_strwidth --- @type function -local utils = require'barbar.utils' +--- @class barbar.ui.Nodes +--- @see barbar.ui.node +--- Operations on `node`s. +local Nodes = {} ---- @class barbar.groups -local m = {} - ---- Sums the width of the groups ---- @param groups barbar.render.group[] +--- Sums the width of the nodes +--- @param nodes barbar.ui.node[] --- @return integer -function m.width(groups) +function Nodes.width(nodes) local result = 0 - for _, group in ipairs(groups) do + for _, group in ipairs(nodes) do result = result + strwidth(group.text) end return result end ---- Concatenates some `groups` into a valid tabline string. ---- @param groups barbar.render.group[] +--- Concatenates some `nodes` into a valid tabline string. +--- @param nodes barbar.ui.node[] --- @return string -function m.to_string(groups) +function Nodes.to_string(nodes) local result = '' - for _, group in ipairs(groups) do + for _, group in ipairs(nodes) do -- NOTE: We have to escape the text in case it contains '%', which is a special character to the -- tabline. -- To escape '%', we make it '%%'. It just so happens that '%' is also a special character @@ -39,49 +39,46 @@ function m.to_string(groups) return result end ---- Concatenates some `groups` into a raw string. +--- Concatenates some `nodes` into a raw string. +--- @param nodes barbar.ui.node[] --- For debugging purposes. ---- @param groups barbar.render.group[] --- @return string ---- @diagnostic disable-next-line:unused-function,unused-local -function m.to_raw_string(groups) +function Nodes.to_raw_string(nodes) local result = '' - for _, group in ipairs(groups) do + for _, group in ipairs(nodes) do result = result .. group.text end return result end ---- Insert `other` into `groups` at the `position`. ---- @param groups barbar.render.group[] +--- Insert `other` into `nodes` at the `position`. +--- @param nodes barbar.ui.node[] --- @param position integer ---- @param group barbar.render.group ---- @return barbar.render.group[] with_insertions -function m.insert(groups, position, group) - return m.insert_many(groups, position, { group }) +--- @return barbar.ui.node[] with_insertions +function Nodes.insert(nodes, position, group) + return Nodes.insert_many(nodes, position, { group }) end ---- Insert `others` into `groups` at the `position`. ---- @param groups barbar.render.group[] +--- Insert `others` into `nodes` at the `position`. +--- @param nodes barbar.ui.node[] --- @param position integer ---- @param others barbar.render.group[] ---- @return barbar.render.group[] with_insertions -function m.insert_many(groups, position, others) - +--- @param others barbar.ui.node[] +--- @return barbar.ui.node[] with_insertions +function Nodes.insert_many(nodes, position, others) if position < 0 then - local others_width = m.width(others) + local others_width = Nodes.width(others) local others_end = position + others_width if others_end < 0 then - return groups + return nodes end local available_width = others_end position = 0 - others = m.slice_left(others, available_width) + others = Nodes.slice_left(others, available_width) end @@ -90,8 +87,8 @@ function m.insert_many(groups, position, others) local new_groups = {} local i = 1 - while i <= #groups do - local group = groups[i] + while i <= #nodes do + local group = nodes[i] local group_width = strwidth(group.text) -- While we haven't found the position... @@ -112,7 +109,7 @@ function m.insert_many(groups, position, others) }) end - -- Add new other groups + -- Add new other nodes local others_width = 0 for _, other in ipairs(others) do local other_width = strwidth(other.text) @@ -122,10 +119,10 @@ function m.insert_many(groups, position, others) local end_position = position + others_width - -- Then, resume adding previous groups + -- Then, resume adding previous nodes -- table.insert(new_groups, 'then') - while i <= #groups do - local previous_group = groups[i] + while i <= #nodes do + local previous_group = nodes[i] local previous_group_width = strwidth(previous_group.text) local previous_group_start_position = current_position local previous_group_end_position = current_position + previous_group_width @@ -153,16 +150,15 @@ function m.insert_many(groups, position, others) return new_groups end ---- Select from `groups` while fitting within the provided `width`, discarding all indices larger than the last index that fits. ---- @param groups barbar.render.group[] +--- Select from `nodes` while fitting within the provided `width`, discarding all indices larger than the last index that fits. --- @param width integer ---- @return barbar.render.group[] -function m.slice_right(groups, width) +--- @return barbar.ui.node[] sliced +function Nodes.slice_right(nodes, width) local accumulated_width = 0 local new_groups = {} - for _, group in ipairs(groups) do + for _, group in ipairs(nodes) do local text_width = strwidth(group.text) accumulated_width = accumulated_width + text_width @@ -178,16 +174,17 @@ function m.slice_right(groups, width) return new_groups end ---- Select from `groups` in reverse while fitting within the provided `width`, discarding all indices less than the last index that fits. ---- @param groups barbar.render.group[] +--- Select from `nodes` in reverse while fitting within the provided `width`, discarding all indices less than the last index that fits. +--- @param nodes barbar.ui.node[] --- @param width integer ---- @return barbar.render.group[] -function m.slice_left(groups, width) +--- @return barbar.ui.node[] sliced +function Nodes.slice_left(nodes, width) local accumulated_width = 0 local new_groups = {} - for _, group in ipairs(utils.list_reverse(groups)) do + for i = #nodes, 1, -1 do + local group = nodes[i] --- @type barbar.ui.node (it cannot be `nil`) local text_width = strwidth(group.text) accumulated_width = accumulated_width + text_width @@ -204,4 +201,4 @@ function m.slice_left(groups, width) return new_groups end -return m +return Nodes diff --git a/lua/barbar/render.lua b/lua/barbar/ui/render.lua similarity index 83% rename from lua/barbar/render.lua rename to lua/barbar/ui/render.lua index 323a0da5..1ba7658b 100644 --- a/lua/barbar/render.lua +++ b/lua/barbar/ui/render.lua @@ -13,6 +13,7 @@ local defer_fn = vim.defer_fn local get_current_buf = vim.api.nvim_get_current_buf --- @type function local get_option = vim.api.nvim_get_option --- @type function local has = vim.fn.has --- @type function +local list_extend = vim.list_extend local list_tabpages = vim.api.nvim_list_tabpages --- @type function local list_wins = vim.api.nvim_list_wins --- @type function local set_current_win = vim.api.nvim_set_current_win --- @type function @@ -29,10 +30,10 @@ local animate = require'barbar.animate' local Buffer = require'barbar.buffer' local config = require'barbar.config' -- local fs = require'barbar.fs' -- For debugging purposes -local groups = require'barbar.groups' +local Nodes = require('barbar.ui.nodes') local icons = require'barbar.icons' local JumpMode = require'barbar.jump_mode' -local Layout = require'barbar.layout' +local Layout = require'barbar.ui.layout' local state = require'barbar.state' local utils = require'barbar.utils' @@ -47,7 +48,7 @@ local function wrap_hl(group) return '%#' .. group .. '#' end ---- @class barbar.render.animation +--- @class barbar.ui.render.animation --- @field OPEN_DELAY integer --- @field OPEN_DURATION integer --- @field CLOSE_DURATION integer @@ -59,22 +60,12 @@ local ANIMATION = { SCROLL_DURATION = 200, } ---- @class barbar.render.group ---- @field hl string the highlight group to use ---- @field text string the content being rendered - ---- @class barbar.render.group_clump ---- @field activity barbar.buffer.activity ---- @field groups barbar.render.group[] ---- @field position integer ---- @field width integer - ---- @class barbar.render.scroll +--- @class barbar.ui.render.scroll --- @field current integer the place where the bufferline is currently scrolled to --- @field target integer the place where the bufferline is scrolled/wants to scroll to. local scroll = { current = 0, target = 0 } ---- @class barbar.render +--- @class barbar.ui.render local render = {} --- An incremental animation for `close_buffer_animated`. @@ -136,7 +127,7 @@ end --- Opens a buffer with animation. --- @param bufnr integer ---- @param layout barbar.layout.data +--- @param layout barbar.ui.layout.data --- @return nil local function open_buffer_start_animation(layout, bufnr) local buffer_data = state.get_buffer_data(bufnr) @@ -268,9 +259,6 @@ function render.get_updated_buffers(update_names) return state.buffers end ---- @deprecated use `state.restore_buffers` instead -render.restore_buffers = state.restore_buffers - --- Open the window which contained the buffer which was clicked on. --- @return integer current_bufnr function render.set_current_win_listed_buffer() @@ -351,19 +339,19 @@ function render.set_tabline(s) end --- Compute the buffer hl-groups ---- @param layout barbar.layout.data +--- @param layout barbar.ui.layout.data --- @param bufnrs integer[] --- @param refocus? boolean ---- @return barbar.render.group_clump[] pinned_groups, barbar.render.group_clump[] clumps -local function get_bufferline_group_clumps(layout, bufnrs, refocus) +--- @return barbar.ui.container[] pinned_groups, barbar.ui.container[] clumps +local function get_bufferline_containers(layout, bufnrs, refocus) local click_enabled = has('tablineat') and config.options.clickable local accumulated_pinned_width = 0 --- the width of pinned buffers accumulated while iterating local accumulated_unpinned_width = 0 --- the width of buffers accumulated while iterating local current_buffer_index = nil --- @type nil|integer local done = false --- if all of the visible buffers have been clumped - local group_clumps = {} --- @type barbar.render.group_clump[] - local pinned_group_clumps = {} --- @type barbar.render.group_clump[] + local containers = {} --- @type barbar.ui.container[] + local pinned_containers = {} --- @type barbar.ui.container[] local pinned_pad_text = (' '):rep(config.options.minimum_padding) local unpinned_pad_text = (' '):rep(layout.buffers.padding) @@ -383,13 +371,13 @@ local function get_bufferline_group_clumps(layout, bufnrs, refocus) buffer_data.computed_width = Layout.calculate_width(layout.buffers.base_widths[i], layout.buffers.padding) end - local group_clump_width = buffer_data.width or buffer_data.computed_width + local container_width = buffer_data.width or buffer_data.computed_width if activity == Buffer.activities.Current and refocus ~= false then current_buffer_index = i local start = accumulated_unpinned_width - local end_ = accumulated_unpinned_width + group_clump_width + local end_ = accumulated_unpinned_width + container_width if scroll.target > start then render.set_scroll(start) @@ -401,9 +389,9 @@ local function get_bufferline_group_clumps(layout, bufnrs, refocus) local scroll_current = min(scroll.current, layout.buffers.scroll_max) if pinned then - accumulated_pinned_width = accumulated_pinned_width + group_clump_width + accumulated_pinned_width = accumulated_pinned_width + container_width else - accumulated_unpinned_width = accumulated_unpinned_width + group_clump_width + accumulated_unpinned_width = accumulated_unpinned_width + container_width if accumulated_unpinned_width < scroll_current then goto continue -- HACK: there is no `continue` keyword @@ -423,11 +411,11 @@ local function get_bufferline_group_clumps(layout, bufnrs, refocus) local clickable = click_enabled and ('%' .. bufnr .. '@barbar#events#main_click_handler@') or '' --- The name of the buffer - --- @type barbar.render.group + --- @type barbar.ui.node local name = {hl = clickable .. buffer_hl, text = icons_option.filename and buffer_name or ''} --- The buffer index - --- @type barbar.render.group + --- @type barbar.ui.node local buffer_index = { hl = '', text = '' } if icons_option.buffer_index then buffer_index.hl = wrap_hl('Buffer' .. activity_name .. 'Index') @@ -435,7 +423,7 @@ local function get_bufferline_group_clumps(layout, bufnrs, refocus) end --- The buffer number - --- @type barbar.render.group + --- @type barbar.ui.node local buffer_number = { hl = '', text = '' } if icons_option.buffer_number then buffer_number.hl = wrap_hl('Buffer' .. activity_name .. 'Number') @@ -443,7 +431,7 @@ local function get_bufferline_group_clumps(layout, bufnrs, refocus) end --- The close icon - --- @type barbar.render.group + --- @type barbar.ui.container local button = {hl = buffer_hl, text = ''} local button_icon = icons_option.button @@ -456,11 +444,11 @@ local function get_bufferline_group_clumps(layout, bufnrs, refocus) end --- The jump letter - --- @type barbar.render.group + --- @type barbar.ui.node local jump_letter = { hl = '', text = '' } --- The devicon - --- @type barbar.render.group + --- @type barbar.ui.node local icon = { hl = clickable, text = '' } if state.is_picking_buffer then @@ -494,34 +482,33 @@ local function get_bufferline_group_clumps(layout, bufnrs, refocus) local hl_sign = wrap_hl('Buffer' .. activity_name .. 'Sign') - --- @type barbar.render.group + --- @type barbar.ui.node local left_separator = { hl = clickable .. hl_sign, text = icons_option.separator.left } - --- @type barbar.render.group - local padding = { hl = buffer_hl, text = pinned and pinned_pad_text or unpinned_pad_text } + --- @type barbar.ui.node + local padding = { hl = hl_sign, text = pinned and pinned_pad_text or unpinned_pad_text } - local group_clump = { --- @type barbar.render.group_clump + local container = { --- @type barbar.ui.container activity = activity, - groups = { left_separator, padding, buffer_index, buffer_number, icon, jump_letter, name }, + nodes = { left_separator, padding, buffer_index, buffer_number, icon, jump_letter, name }, --- @diagnostic disable-next-line:assign-type-mismatch it is assigned just earlier position = buffer_data.position or buffer_data.computed_position, --- @diagnostic disable-next-line:assign-type-mismatch it is assigned just earlier - width = group_clump_width, + width = container_width, } Buffer.for_each_counted_enabled_diagnostic(bufnr, icons_option.diagnostics, function(count, idx, option) - table_insert(group_clump.groups, { + table_insert(container.nodes, { hl = wrap_hl('Buffer' .. activity_name .. severity[idx]), text = ' ' .. option.icon .. count, }) end) - --- @type barbar.render.group + --- @type barbar.ui.node local right_separator = { hl = left_separator.hl, text = icons_option.separator.right } - vim.list_extend(group_clump.groups, { padding, button, right_separator }) - - table_insert(pinned and pinned_group_clumps or group_clumps, group_clump) + list_extend(container.nodes, { padding, button, right_separator }) + table_insert(pinned and pinned_containers or containers, container) if done then break @@ -530,7 +517,7 @@ local function get_bufferline_group_clumps(layout, bufnrs, refocus) ::continue:: end - return pinned_group_clumps, group_clumps + return pinned_containers, containers end local HL = { @@ -546,7 +533,7 @@ local HL = { --- @return nil|string syntax local function generate_tabline(bufnrs, refocus) local layout = Layout.calculate() - local pinned_group_clumps, group_clumps = get_bufferline_group_clumps(layout, bufnrs, refocus) + local pinned_containers, containers = get_bufferline_containers(layout, bufnrs, refocus) -- Create actual tabline string local result = '' @@ -560,17 +547,17 @@ local function generate_tabline(bufnrs, refocus) local content_max_width = state.offset.left.width - 2 offset_groups = - groups.insert_many( + Nodes.insert_many( offset_groups, 1, - groups.slice_right(content, content_max_width)) + Nodes.slice_right(content, content_max_width)) - result = result .. groups.to_string(offset_groups) + result = result .. Nodes.to_string(offset_groups) end -- Buffer tabs do - --- @type barbar.render.group[] + --- @type barbar.ui.container local content = { { hl = HL.FILL, @@ -579,70 +566,70 @@ local function generate_tabline(bufnrs, refocus) } do - local current_group_clump = nil - for _, group_clump in ipairs(group_clumps) do + local current_container = nil + for _, container in ipairs(containers) do -- We insert the current buffer after the others so it's always on top - if group_clump.activity ~= Buffer.activities.Current then - content = groups.insert_many( + if container.activity ~= Buffer.activities.Current then + content = Nodes.insert_many( content, - group_clump.position - scroll.current, - group_clump.groups) + container.position - scroll.current, + container.nodes) else - current_group_clump = group_clump + current_container = container end end - if current_group_clump ~= nil then - local group_clump = current_group_clump - content = groups.insert_many( + if current_container ~= nil then + local container = current_container + content = Nodes.insert_many( content, - group_clump.position - scroll.current, - group_clump.groups) + container.position - scroll.current, + container.nodes) end end do local inactive_separator = config.options.icons.inactive.separator.left - if #group_clumps > 0 and layout.buffers.unpinned_width + strwidth(inactive_separator) <= layout.buffers.unpinned_allocated_width and inactive_separator ~= nil then - content = groups.insert( + if #containers > 0 and layout.buffers.unpinned_width + strwidth(inactive_separator) <= layout.buffers.unpinned_allocated_width and inactive_separator ~= nil then + content = Nodes.insert( content, layout.buffers.used_width, { text = inactive_separator, hl = HL.SIGN_INACTIVE }) end end - if #pinned_group_clumps > 0 then - local current_group_clump = nil - for _, group_clump in ipairs(pinned_group_clumps) do - if group_clump.activity ~= Buffer.activities.Current then - content = groups.insert_many(content, group_clump.position, group_clump.groups) + if #pinned_containers > 0 then + local current_container = nil + for _, container in ipairs(pinned_containers) do + if container.activity ~= Buffer.activities.Current then + content = Nodes.insert_many(content, container.position, container.nodes) else - current_group_clump = group_clump + current_container = container end end - if current_group_clump ~= nil then - local group_clump = current_group_clump - content = groups.insert_many(content, group_clump.position, group_clump.groups) + if current_container ~= nil then + local container = current_container + content = Nodes.insert_many(content, container.position, container.nodes) end end local filler = { { hl = HL.FILL, text = (' '):rep(layout.buffers.width) } } - content = groups.insert_many(filler, 0, content) - content = groups.slice_right(content, layout.buffers.width) + content = Nodes.insert_many(filler, 0, content) + content = Nodes.slice_right(content, layout.buffers.width) local has_left_scroll = scroll.current > 0 if has_left_scroll then - content = groups.insert(content, layout.buffers.pinned_width, + content = Nodes.insert(content, layout.buffers.pinned_width, { hl = HL.SCROLL_ARROW, text = config.options.icons.scroll.left }) end local has_right_scroll = layout.buffers.used_width - scroll.current > layout.buffers.width if has_right_scroll then - content = groups.insert(content, layout.buffers.width - 1, + content = Nodes.insert(content, layout.buffers.width - 1, { hl = HL.SCROLL_ARROW, text = config.options.icons.scroll.right }) end -- Render bufferline string - result = result .. groups.to_string(content) + result = result .. Nodes.to_string(content) -- Prevent the expansion of the last click group if config.options.clickable then @@ -656,7 +643,7 @@ local function generate_tabline(bufnrs, refocus) local content = { { hl = HL.TABPAGES, text = ' ' .. tabpagenr() .. '/' .. tabpagenr('$') .. ' ', }, } - result = result .. groups.to_string(content) + result = result .. Nodes.to_string(content) end end @@ -669,12 +656,12 @@ local function generate_tabline(bufnrs, refocus) local content_max_width = state.offset.right.width - 2 offset_groups = - groups.insert_many( + Nodes.insert_many( offset_groups, 1, - groups.slice_right(content, content_max_width)) + Nodes.slice_right(content, content_max_width)) - result = result .. groups.to_string(offset_groups) + result = result .. Nodes.to_string(offset_groups) end -- NOTE: For development or debugging purposes, the following code can be used: diff --git a/lua/barbar/ui/types.lua b/lua/barbar/ui/types.lua new file mode 100644 index 00000000..bf88e3a3 --- /dev/null +++ b/lua/barbar/ui/types.lua @@ -0,0 +1,11 @@ +--- @meta + +--- @class barbar.ui.node +--- @field hl string the highlight group to use +--- @field text string the content being rendered + +--- @class barbar.ui.container +--- @field activity barbar.buffer.activity +--- @field nodes barbar.ui.node[] +--- @field position integer +--- @field width integer diff --git a/lua/bufferline/layout.lua b/lua/bufferline/layout.lua index d6b853bc..5926ef18 100644 --- a/lua/bufferline/layout.lua +++ b/lua/bufferline/layout.lua @@ -1 +1 @@ -return require'barbar.layout' +return require'barbar.ui.layout' diff --git a/lua/bufferline/render.lua b/lua/bufferline/render.lua index 941ec589..dcdb3a69 100644 --- a/lua/bufferline/render.lua +++ b/lua/bufferline/render.lua @@ -1 +1,6 @@ -return require'barbar.render' +local render = require('barbar.ui.render') + +--- @deprecated use `state.restore_buffers` instead +render.restore_buffers = require('barbar.state').restore_buffers + +return render