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',
|
'buffers',
|
||||||
show_filename_only = true, -- shows shortened relative path when false
|
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
|
max_length = vim.o.columns * 2 / 3, -- maximum width of buffers component
|
||||||
-- can also be a function that returns value of max_length dynamicaly
|
-- can also be a function that returns value of max_length dynamicaly
|
||||||
filetype_names = {
|
filetype_names = {
|
||||||
|
|
|
@ -410,7 +410,10 @@ will be.
|
||||||
{
|
{
|
||||||
'buffers',
|
'buffers',
|
||||||
show_filename_only = true, -- shows shortened relative path when false
|
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
|
max_length = vim.o.columns * 2 / 3, -- maximum width of buffers component
|
||||||
-- can also be a function that returns value of max_length dynamicaly
|
-- can also be a function that returns value of max_length dynamicaly
|
||||||
filetype_names = {
|
filetype_names = {
|
||||||
|
|
|
@ -48,10 +48,17 @@ end
|
||||||
---@return string
|
---@return string
|
||||||
function Buffer:render()
|
function Buffer:render()
|
||||||
local name
|
local name
|
||||||
|
|
||||||
if self.ellipse then -- show elipsis
|
if self.ellipse then -- show elipsis
|
||||||
name = '...'
|
name = '...'
|
||||||
else
|
else
|
||||||
|
if self.options.mode == 0 then
|
||||||
name = string.format(' %s%s%s ', self.icon, self:name(), self.modified_icon)
|
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
|
end
|
||||||
self.len = vim.fn.strchars(name)
|
self.len = vim.fn.strchars(name)
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ local highlight = require 'lualine.highlight'
|
||||||
local default_options = {
|
local default_options = {
|
||||||
show_filename_only = true,
|
show_filename_only = true,
|
||||||
show_modified_status = true,
|
show_modified_status = true,
|
||||||
|
mode = 0,
|
||||||
max_length = 0,
|
max_length = 0,
|
||||||
filetype_names = {
|
filetype_names = {
|
||||||
TelescopePrompt = 'Telescope',
|
TelescopePrompt = 'Telescope',
|
||||||
|
|
Loading…
Reference in New Issue