feat(buffers): option to show buffer index (#433)
* feature(buffers): option to show buffer indices
This commit is contained in:
parent
df46c1e70a
commit
d2f5d6c8aa
|
@ -421,7 +421,10 @@ sections = {
|
|||
{
|
||||
'buffers',
|
||||
show_filename_only = true, -- shows shortened relative path when false
|
||||
show_modified_status = true -- shows indicator then bufder is modified
|
||||
show_modified_status = true -- shows indicator then buffer is modified
|
||||
mode = 0, -- 0 shows buffer name
|
||||
-- 1 buffer index (bufnr)
|
||||
-- 2 shows buffer name + buffer index (bufnr)
|
||||
max_length = vim.o.columns * 2 / 3, -- maximum width of buffers component
|
||||
-- can also be a function that returns value of max_length dynamicaly
|
||||
filetype_names = {
|
||||
|
|
|
@ -410,7 +410,10 @@ will be.
|
|||
{
|
||||
'buffers',
|
||||
show_filename_only = true, -- shows shortened relative path when false
|
||||
show_modified_status = true -- shows indicator then bufder is modified
|
||||
show_modified_status = true -- shows indicator then buffer is modified
|
||||
mode = 0, -- 0 shows buffer name
|
||||
-- 1 buffer index (bufnr)
|
||||
-- 2 shows buffer name + buffer index (bufnr)
|
||||
max_length = vim.o.columns * 2 / 3, -- maximum width of buffers component
|
||||
-- can also be a function that returns value of max_length dynamicaly
|
||||
filetype_names = {
|
||||
|
|
|
@ -48,10 +48,17 @@ end
|
|||
---@return string
|
||||
function Buffer:render()
|
||||
local name
|
||||
|
||||
if self.ellipse then -- show elipsis
|
||||
name = '...'
|
||||
else
|
||||
name = string.format(' %s%s%s ', self.icon, self:name(), self.modified_icon)
|
||||
if self.options.mode == 0 then
|
||||
name = string.format(' %s%s%s ', self.icon, self:name(), self.modified_icon)
|
||||
elseif self.options.mode == 1 then
|
||||
name = string.format(' %s %s%s ', self.bufnr, self.icon, self.modified_icon)
|
||||
else
|
||||
name = string.format(' %s %s%s%s ', self.bufnr, self.icon, self:name(), self.modified_icon)
|
||||
end
|
||||
end
|
||||
self.len = vim.fn.strchars(name)
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ local highlight = require 'lualine.highlight'
|
|||
local default_options = {
|
||||
show_filename_only = true,
|
||||
show_modified_status = true,
|
||||
mode = 0,
|
||||
max_length = 0,
|
||||
filetype_names = {
|
||||
TelescopePrompt = 'Telescope',
|
||||
|
|
Loading…
Reference in New Issue