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:
parent
9e2492fd07
commit
e6cc09c2e9
|
@ -302,6 +302,7 @@ Option | Default | Behaviour
|
||||||
file_status | true | Displays file status (readonly status, modified status)
|
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`
|
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`
|
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
|
* `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_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_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
|
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.
|
Component specific options can only be set with component configs.
|
||||||
|
|
|
@ -409,6 +409,9 @@ In addition, some components have unique options.
|
||||||
if `full_path` is `true` and `shorten` is `false` it shortens
|
if `full_path` is `true` and `shorten` is `false` it shortens
|
||||||
absolute path `aaa/bbb/ccc/file` to `a/b/c/file`
|
absolute path `aaa/bbb/ccc/file` to `a/b/c/file`
|
||||||
|
|
||||||
|
• symbols (`{modified = '[+]', readonly = '[-]'}`)
|
||||||
|
changes status symbols
|
||||||
|
|
||||||
• fileformat~
|
• fileformat~
|
||||||
• icons_enabled (true)
|
• icons_enabled (true)
|
||||||
Whether to displays icon before component. Colors
|
Whether to displays icon before component. Colors
|
||||||
|
|
|
@ -4,6 +4,9 @@ local FileName = require('lualine.component'):new()
|
||||||
|
|
||||||
FileName.new = function(self, options, child)
|
FileName.new = function(self, options, child)
|
||||||
local new_instance = self._parent:new(options, child or FileName)
|
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
|
-- setting defaults
|
||||||
if new_instance.options.file_status == nil then
|
if new_instance.options.file_status == nil then
|
||||||
|
@ -35,9 +38,9 @@ FileName.update_status = function(self)
|
||||||
|
|
||||||
if self.options.file_status then
|
if self.options.file_status then
|
||||||
if vim.bo.modified 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
|
elseif vim.bo.modifiable == false or vim.bo.readonly == true then
|
||||||
data = data .. '[-]'
|
data = data .. self.options.symbols.readonly
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return data
|
return data
|
||||||
|
|
Loading…
Reference in New Issue