Skip to content
This repository was archived by the owner on Aug 18, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ use {
show_tabs_always = false, -- this shows tabs only when there are more than one tab or if the first tab is named
show_devicons = true, -- this shows devicons in buffer section
show_bufnr = false, -- this appends [bufnr] to buffer section,
bufnr_style = { '⁰', '¹', '²', '³', '⁴', '⁵', '⁶', '⁷', '⁸', '⁹' }, -- this change the [bufnr] style
bufnr_direction = true, -- set true to put buffer number at title's left
show_filename_only = false, -- shows base filename only instead of relative path in filename
modified_icon = "+ ", -- change the default modified icon
modified_italic = false, -- set to true by default; this determines whether the filename turns italic if modified
Expand Down
58 changes: 52 additions & 6 deletions lua/tabline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,31 @@ function Buffer:name()
return vim.fn.pathshorten(vim.fn.fnamemodify(self.file, ":p:."))
end

local function nrmap(nr, map)
local tmp = nr
local ret = ''
while ( tmp ~= 0 )
do
local mapval = map[tmp%10+1]
if mapval then
ret = map[tmp%10+1] .. ret
else
ret = tmp%10 .. ret
end
tmp = math.floor(tmp/10)
end
return ret
end

function Buffer:bufnr_render(bufnr)
local style = M.options.bufnr_style
if style then
return nrmap(bufnr, style)
else
return "[" .. bufnr .. "] "
end
end

function Buffer:render()
local line = self:hl()
.. "%"
Expand All @@ -368,13 +393,22 @@ function Buffer:render()
.. " "
.. self.icon
end
line = line
.. " "
.. self.name
.. " "
.. self.modified_icon
if M.options.show_bufnr then
line = line .. "[" .. self.bufnr .. "] "
if M.options.bufnr_direction then
line = line
.. " "
.. self:bufnr_render(self.bufnr)
.. self.name
.. " "
.. self.modified_icon
else
line = line
.. " "
.. self.name
.. " "
.. self.modified_icon
.. self:bufnr_render(self.bufnr)
end
end
line = line .. "%T" .. self:separator()
return line
Expand Down Expand Up @@ -891,6 +925,18 @@ function M.setup(opts)
M.options.show_bufnr = vim.g.tabline_show_bufnr
end

if opts.options.bufnr_style ~= nil then
M.options.bufnr_style = opts.options.bufnr_style
else
M.options.bufnr_style = vim.g.tabline_bufnr_style
end

if opts.options.bufnr_direction ~= nil then
M.options.bufnr_direction = opts.options.bufnr_direction
else
M.options.bufnr_direction = vim.g.tabline_bufnr_direction
end

if opts.options.show_devicons ~= nil then
M.options.show_devicons = opts.options.show_devicons
else
Expand Down