vim/lualine: improve extension of components
This commit is contained in:
parent
ecadf89867
commit
146ccc2d8f
1 changed files with 7 additions and 9 deletions
|
@ -24,16 +24,14 @@ local config = function()
|
|||
end
|
||||
end
|
||||
|
||||
local extend = function(component, overrides)
|
||||
local colored_when_focused = function(component)
|
||||
local new = require(component):extend()
|
||||
for k, v in pairs(overrides) do new[k] = v end
|
||||
return new
|
||||
end
|
||||
|
||||
local udpate_with_color = function(self, is_focused)
|
||||
function new:update_status(is_focused)
|
||||
self.options.colored = is_focused
|
||||
return self.super.update_status(self, is_focused)
|
||||
end
|
||||
return new
|
||||
end
|
||||
|
||||
local window_is_at_least = function(width)
|
||||
return function() return vim.fn.winwidth(0) > width end
|
||||
|
@ -51,7 +49,7 @@ local config = function()
|
|||
end
|
||||
},
|
||||
|
||||
diff = extend('lualine.components.diff', { update_status = udpate_with_color }),
|
||||
diff = colored_when_focused('lualine.components.diff'),
|
||||
|
||||
mode = { get_mode_icon() },
|
||||
|
||||
|
@ -100,7 +98,7 @@ local config = function()
|
|||
},
|
||||
|
||||
filetype = {
|
||||
extend('lualine.components.filetype', { update_status = udpate_with_color }),
|
||||
colored_when_focused('lualine.components.filetype'),
|
||||
cond = window_is_medium,
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue