Better fix to nil on vimfunc (#178)
This commit is contained in:
parent
dac7a290df
commit
2a222d7ad6
|
@ -3,14 +3,14 @@ local EvalFuncComponent = require('lualine.component'):new()
|
||||||
EvalFuncComponent.update_status = function(self)
|
EvalFuncComponent.update_status = function(self)
|
||||||
local component = self.options[1]
|
local component = self.options[1]
|
||||||
local ok, status = pcall(EvalFuncComponent.eval_lua, component)
|
local ok, status = pcall(EvalFuncComponent.eval_lua, component)
|
||||||
if not ok or status == 'nil' then
|
if not ok then status = EvalFuncComponent.vim_function(component) end
|
||||||
status = EvalFuncComponent.vim_function(component)
|
|
||||||
end
|
|
||||||
return status
|
return status
|
||||||
end
|
end
|
||||||
|
|
||||||
EvalFuncComponent.eval_lua = function(code)
|
EvalFuncComponent.eval_lua = function(code)
|
||||||
return tostring(loadstring('return ' .. code)())
|
local result = loadstring('return ' .. code)()
|
||||||
|
assert(result, 'String expected got nil')
|
||||||
|
return tostring(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
EvalFuncComponent.vim_function = function(name)
|
EvalFuncComponent.vim_function = function(name)
|
||||||
|
|
Loading…
Reference in New Issue