diff --git a/lua/lualine/components/special/vim_var_component.lua b/lua/lualine/components/special/vim_var_component.lua index 53e3dbd..b318f17 100644 --- a/lua/lualine/components/special/vim_var_component.lua +++ b/lua/lualine/components/special/vim_var_component.lua @@ -9,7 +9,14 @@ VarComponent.update_status = function(self) local var_name = component:sub(#scope + 2, #component) -- Displays nothing when veriable aren't present if not (scope and var_name) then return '' end - local return_val = vim[scope][var_name] + -- Support accessing keys within dictionary + -- https://github.com/shadmansaleh/lualine.nvim/issues/25#issuecomment-907374548 + local name_chunks = vim.split(var_name, '%.') + local return_val = vim[scope][name_chunks[1]] + for i=2,#name_chunks do + if return_val == nil then break end + return_val = return_val[name_chunks[i]] + end if return_val == nil then return '' end local ok ok, return_val = pcall(tostring, return_val)