feat(buffers): option to show buffer index (#433)

* feature(buffers): option to show buffer indices
This commit is contained in:
Ilya Malyavin 2021-11-13 14:44:35 +01:00 committed by GitHub
parent df46c1e70a
commit d2f5d6c8aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 3 deletions

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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)

View File

@ -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',