2021-04-11 08:20:41 +00:00
|
|
|
local VarComponent = require('lualine.component'):new()
|
|
|
|
VarComponent.update_status = function(self)
|
|
|
|
local component = self.options[1]
|
|
|
|
-- vim veriable component
|
|
|
|
-- accepts g:, v:, t:, w:, b:, o, go:, vo:, to:, wo:, bo:
|
|
|
|
-- filters g portion from g:var
|
|
|
|
local scope = component:match('[gvtwb]?o?')
|
|
|
|
-- filters var portion from g:var
|
|
|
|
local var_name = component:sub(#scope + 2, #component)
|
|
|
|
-- Displays nothing when veriable aren't present
|
2021-08-20 12:32:56 +00:00
|
|
|
if not (scope and var_name) then return '' end
|
2021-04-11 08:20:41 +00:00
|
|
|
local return_val = vim[scope][var_name]
|
|
|
|
if return_val == nil then return '' end
|
|
|
|
local ok
|
|
|
|
ok, return_val = pcall(tostring, return_val)
|
2021-08-20 12:32:56 +00:00
|
|
|
return ok and return_val or ''
|
2021-04-11 08:20:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return VarComponent
|