feat(filename): add support for custom filename symbols (modified, readonly) (#185)

* feat(filename): add support for custom filename symbols (modified, readonly)

* update docs
This commit is contained in:
Tim Bedard 2021-04-20 11:25:25 -05:00 committed by GitHub
parent 9e2492fd07
commit e6cc09c2e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 3 deletions

View File

@ -302,6 +302,7 @@ Option | Default | Behaviour
file_status | true | Displays file status (readonly status, modified status)
full_path | false | Displays relative path if set to `true`, absolute path if set to `false`
shorten | true | if `full_path` is true and `shorten` is `false` it shortens absolute path `aaa/bbb/ccc/file` to `a/b/c/file`
symbols | `{modified = '[+]', readonly = '[-]'}` | changes status symbols | table containing one or more symbols |
* `diff` component options
@ -311,7 +312,7 @@ colored | true | displays diff status in color if set to `true` |
color_added | `DiffAdd` foreground color | changes diff's added section foreground color | color in `#rrggbb` format
color_modified | `DiffChange` foreground color | changes diff's changed section foreground color | color in `#rrggbb` format
color_removed | `DiffDelete` foreground color | changes diff's removed section foreground color | color in `#rrggbb` format
symbols | `{added = '+', modified = '~', removed = '-'}` | changes diff's symbols | table containing on or more symbols |
symbols | `{added = '+', modified = '~', removed = '-'}` | changes diff's symbols | table containing one or more symbols |
Component specific options can only be set with component configs.

View File

@ -409,6 +409,9 @@ In addition, some components have unique options.
if `full_path` is `true` and `shorten` is `false` it shortens
absolute path `aaa/bbb/ccc/file` to `a/b/c/file`
• symbols (`{modified = '[+]', readonly = '[-]'}`)
changes status symbols
• fileformat~
• icons_enabled (true)
Whether to displays icon before component. Colors

View File

@ -4,6 +4,9 @@ local FileName = require('lualine.component'):new()
FileName.new = function(self, options, child)
local new_instance = self._parent:new(options, child or FileName)
local default_symbols = {modified = '[+]', readonly = '[-]'}
new_instance.options.symbols =
vim.tbl_extend('force', default_symbols, new_instance.options.symbols or {})
-- setting defaults
if new_instance.options.file_status == nil then
@ -35,9 +38,9 @@ FileName.update_status = function(self)
if self.options.file_status then
if vim.bo.modified then
data = data .. '[+]'
data = data .. self.options.symbols.modified
elseif vim.bo.modifiable == false or vim.bo.readonly == true then
data = data .. '[-]'
data = data .. self.options.symbols.readonly
end
end
return data