feat: add symbols option to fileformat (#401)

* doc: add symbol to fileformat component specific option
This commit is contained in:
André Augusto 2021-10-26 18:04:53 -03:00 committed by GitHub
parent 8d8c538fb9
commit 0b0233f808
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 8 deletions

View File

@ -483,6 +483,23 @@ sections = {
} }
``` ```
#### fileformat component options
```lua
sections = {
lualine_a = {
{
'fileformat',
symbols = {
unix = '', -- e712
dos = '', -- e70f
mac = '', -- e711
}
}
}
}
```
#### filename component options #### filename component options
```lua ```lua

View File

@ -3,18 +3,28 @@
local M = require('lualine.component'):extend() local M = require('lualine.component'):extend()
-- stylua: ignore -- stylua: ignore
M.icon = { local symbols = {
unix = '', -- e712 unix = '', -- e712
dos = '', -- e70f dos = '', -- e70f
mac = '' -- e711 mac = '', -- e711
} }
M.update_status = function(self) -- Initializer
if self.options.icons_enabled and not self.options.icon then 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 local format = vim.bo.fileformat
return M.icon[format] or format if self.options.icons_enabled then
return self.symbols[format] or format
else
return format
end end
return vim.bo.fileformat
end end
return M return M