vim/lualine: refactor component extensions
This commit is contained in:
parent
c0ef1e17b9
commit
8d8def18dd
1 changed files with 11 additions and 9 deletions
|
@ -38,17 +38,17 @@ local config = function()
|
||||||
['t'] = ' Term ',
|
['t'] = ' Term ',
|
||||||
}
|
}
|
||||||
|
|
||||||
local update_status = function(self, is_focused)
|
local extend = function(component, overrides)
|
||||||
|
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)
|
||||||
self.options.colored = is_focused
|
self.options.colored = is_focused
|
||||||
return self.super.update_status(self, is_focused)
|
return self.super.update_status(self, is_focused)
|
||||||
end
|
end
|
||||||
|
|
||||||
local diff = require'lualine.components.diff':extend()
|
|
||||||
diff.update_status = update_status
|
|
||||||
|
|
||||||
local filetype = require'lualine.components.filetype':extend()
|
|
||||||
filetype.update_status = update_status
|
|
||||||
|
|
||||||
local window_is_at_least = function(width)
|
local window_is_at_least = function(width)
|
||||||
return function() return vim.fn.winwidth(0) > width end
|
return function() return vim.fn.winwidth(0) > width end
|
||||||
end
|
end
|
||||||
|
@ -67,6 +67,8 @@ local config = function()
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
|
diff = extend('lualine.components.diff', { update_status = udpate_with_color }),
|
||||||
|
|
||||||
mode = {
|
mode = {
|
||||||
function()
|
function()
|
||||||
local code = vim.api.nvim_get_mode().mode
|
local code = vim.api.nvim_get_mode().mode
|
||||||
|
@ -125,7 +127,7 @@ local config = function()
|
||||||
},
|
},
|
||||||
|
|
||||||
filetype = {
|
filetype = {
|
||||||
filetype,
|
extend('lualine.components.filetype', { update_status = udpate_with_color }),
|
||||||
cond = window_is_medium,
|
cond = window_is_medium,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -138,7 +140,7 @@ local config = function()
|
||||||
local inactive_sections = {
|
local inactive_sections = {
|
||||||
lualine_a = {},
|
lualine_a = {},
|
||||||
lualine_b = { my.visual_multi, my.branch },
|
lualine_b = { my.visual_multi, my.branch },
|
||||||
lualine_c = { diff, my.filename, my.status },
|
lualine_c = { my.diff, my.filename, my.status },
|
||||||
lualine_x = { my.filetype },
|
lualine_x = { my.filetype },
|
||||||
lualine_y = { my.fileformat, 'progress' },
|
lualine_y = { my.fileformat, 'progress' },
|
||||||
lualine_z = { 'location' },
|
lualine_z = { 'location' },
|
||||||
|
|
Loading…
Add table
Reference in a new issue