feat: hide filename extension for buffers component (#629)
This commit is contained in:
parent
bb8dd4c1c5
commit
c9a974d912
|
@ -434,6 +434,7 @@ sections = {
|
||||||
{
|
{
|
||||||
'buffers',
|
'buffers',
|
||||||
show_filename_only = true, -- Shows shortened relative path when set to false.
|
show_filename_only = true, -- Shows shortened relative path when set to false.
|
||||||
|
hide_filename_extension = false, -- Hide filename extension when set to true.
|
||||||
show_modified_status = true, -- Shows indicator when the buffer is modified.
|
show_modified_status = true, -- Shows indicator when the buffer is modified.
|
||||||
|
|
||||||
mode = 0, -- 0: Shows buffer name
|
mode = 0, -- 0: Shows buffer name
|
||||||
|
|
|
@ -132,8 +132,17 @@ function Buffer:name()
|
||||||
elseif self.file == '' then
|
elseif self.file == '' then
|
||||||
return '[No Name]'
|
return '[No Name]'
|
||||||
end
|
end
|
||||||
return self.options.show_filename_only and vim.fn.fnamemodify(self.file, ':t')
|
|
||||||
or vim.fn.pathshorten(vim.fn.fnamemodify(self.file, ':p:.'))
|
local name
|
||||||
|
if self.options.show_filename_only then
|
||||||
|
name = vim.fn.fnamemodify(self.file, ':t')
|
||||||
|
else
|
||||||
|
name = vim.fn.pathshorten(vim.fn.fnamemodify(self.file, ':p:.'))
|
||||||
|
end
|
||||||
|
if self.options.hide_filename_extension then
|
||||||
|
name = vim.fn.fnamemodify(name, ':r')
|
||||||
|
end
|
||||||
|
return name
|
||||||
end
|
end
|
||||||
|
|
||||||
---adds spaces to left and right
|
---adds spaces to left and right
|
||||||
|
|
|
@ -7,6 +7,7 @@ local highlight = require('lualine.highlight')
|
||||||
|
|
||||||
local default_options = {
|
local default_options = {
|
||||||
show_filename_only = true,
|
show_filename_only = true,
|
||||||
|
hide_filename_extension = false,
|
||||||
show_modified_status = true,
|
show_modified_status = true,
|
||||||
mode = 0,
|
mode = 0,
|
||||||
max_length = 0,
|
max_length = 0,
|
||||||
|
|
Loading…
Reference in New Issue