-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add BOM indicator to encoding component (#1228)
* feat: Add BOM indicator to encoding component * feat: Make BOM indicator optional * chore: Add more tests for encoding component
- Loading branch information
1 parent
6a40b53
commit be2d876
Showing
3 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,32 @@ | ||
-- Copyright (c) 2020-2021 hoob3rt | ||
-- MIT license, see LICENSE for more details. | ||
local function encoding() | ||
return vim.opt.fileencoding:get() | ||
local lualine_require = require('lualine_require') | ||
local M = lualine_require.require('lualine.component'):extend() | ||
|
||
local default_options = { | ||
-- Show '[BOM]' when the file has a byte-order mark | ||
show_bomb = false, | ||
} | ||
|
||
function M:init(options) | ||
M.super.init(self, options) | ||
self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options) | ||
end | ||
|
||
function M:update_status() | ||
local show_bomb = self.options.show_bomb | ||
|
||
local result = vim.opt.fileencoding:get() | ||
|
||
if not show_bomb then | ||
return result | ||
end | ||
|
||
if vim.opt.bomb:get() then | ||
result = result .. ' [BOM]' | ||
end | ||
|
||
return result | ||
end | ||
|
||
return encoding | ||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters