From 2a222d7ad6091a5abbc8e8e40d2ee13dabf2c062 Mon Sep 17 00:00:00 2001 From: Shadman Date: Wed, 14 Apr 2021 18:25:34 +0600 Subject: [PATCH] Better fix to nil on vimfunc (#178) --- lua/lualine/components/special/eval_func_component.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/lualine/components/special/eval_func_component.lua b/lua/lualine/components/special/eval_func_component.lua index 6dc6a2d..3bad302 100644 --- a/lua/lualine/components/special/eval_func_component.lua +++ b/lua/lualine/components/special/eval_func_component.lua @@ -3,14 +3,14 @@ local EvalFuncComponent = require('lualine.component'):new() EvalFuncComponent.update_status = function(self) local component = self.options[1] local ok, status = pcall(EvalFuncComponent.eval_lua, component) - if not ok or status == 'nil' then - status = EvalFuncComponent.vim_function(component) - end + if not ok then status = EvalFuncComponent.vim_function(component) end return status end 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 EvalFuncComponent.vim_function = function(name)