Closed pseudoparenchymatous closed 1 year ago
"dynamic rendering" is already implemented, but in a different way, acting more like tabs in a browser. unique buffer names is achievable. this is a recipe.
local get_bufs = function()
return vim.tbl_filter(function(bufnr)
return vim.api.nvim_buf_get_option(bufnr, "buflisted")
end, vim.api.nvim_list_bufs())
end
vim.api.nvim_create_autocmd({ "VimEnter", "UIEnter", "BufAdd", "BufDelete" }, {
callback = function(args)
local counts = {}
local dupes = {}
local names = vim.tbl_map(function(bufnr)
return vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufnr), ":t")
end, get_bufs())
for _, name in ipairs(names) do
counts[name] = (counts[name] or 0) + 1
end
for name, count in pairs(counts) do
if count > 1 then
dupes[name] = true
end
end
require'heirline'.tabline.dupes = dupes
end,
})
-- Modify the tabline component responsible for rendering the filename.
-- See the cookbook for the whole setup
local TablineFileName = {
provider = function(self)
local filename = vim.fn.fnamemodify(self.filename, ":t")
if self.dupes and self.dupes[filename] then
filename = vim.fn.fnamemodify(self.filename, ":h:t") .. "/" .. filename
end
filename = filename == "" and "[No Name]" or filename
return filename
end,
hl = function(self)
return { bold = self.is_active or self.is_visible, italic = true }
end,
}
Any recipes to achieve something like these?
https://github.com/willothy/nvim-cokeline#unique-buffer-names https://github.com/willothy/nvim-cokeline#dynamic-rendering