diff --git a/README.md b/README.md index 86cfe67..a08f5fc 100644 --- a/README.md +++ b/README.md @@ -483,6 +483,23 @@ sections = { } ``` +#### fileformat component options + +```lua +sections = { + lualine_a = { + { + 'fileformat', + symbols = { + unix = '', -- e712 + dos = '', -- e70f + mac = '', -- e711 + } + } + } +} +``` + #### filename component options ```lua diff --git a/lua/lualine/components/fileformat.lua b/lua/lualine/components/fileformat.lua index 8ca764a..7e5011d 100644 --- a/lua/lualine/components/fileformat.lua +++ b/lua/lualine/components/fileformat.lua @@ -3,18 +3,28 @@ local M = require('lualine.component'):extend() -- stylua: ignore -M.icon = { +local symbols = { unix = '', -- e712 - dos = '', -- e70f - mac = '' -- e711 + dos = '', -- e70f + mac = '', -- e711 } -M.update_status = function(self) - if self.options.icons_enabled and not self.options.icon then - local format = vim.bo.fileformat - return M.icon[format] or format +-- Initializer +function M:init(options) + -- Run super() + M.super.init(self, options) + -- Apply default symbols + self.symbols = vim.tbl_extend('keep', self.options.symbols or {}, symbols) +end + +-- Function that runs everytime statusline is updated +function M:update_status() + local format = vim.bo.fileformat + if self.options.icons_enabled then + return self.symbols[format] or format + else + return format end - return vim.bo.fileformat end return M