| 1 |
-- Copyright (c) 2020-2021 hoob3rt |
| 2 |
-- MIT license, see LICENSE for more details. |
| 3 |
local lualine_require = require('lualine_require') |
| 4 |
local M = lualine_require.require('lualine.component'):extend() |
| 5 |
|
| 6 |
local default_options = { |
| 7 |
-- Show '[BOM]' when the file has a byte-order mark |
| 8 |
show_bomb = false, |
| 9 |
} |
| 10 |
|
| 11 |
function M:init(options) |
| 12 |
M.super.init(self, options) |
| 13 |
self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options) |
| 14 |
end |
| 15 |
|
| 16 |
function M:update_status() |
| 17 |
local show_bomb = self.options.show_bomb |
| 18 |
|
| 19 |
local result = vim.opt.fileencoding:get() |
| 20 |
|
| 21 |
if not show_bomb then |
| 22 |
return result |
| 23 |
end |
| 24 |
|
| 25 |
if vim.opt.bomb:get() then |
| 26 |
result = result .. ' [BOM]' |
| 27 |
end |
| 28 |
|
| 29 |
return result |
| 30 |
end |
| 31 |
|
| 32 |
return M |