diff --git a/README.md b/README.md index 880bd3e..56dbb15 100644 --- a/README.md +++ b/README.md @@ -390,8 +390,8 @@ sections = { -- When type is omitted lualine will guess it. -- Available types [format: type_name(example)] -- mod(branch/filename), stl(%f/%m), var(g:coc_status/bo:modifiable), - -- luae(lua expressions), vimf(viml function name) - -- luae is short for lua-expression and vimf is short fror vim-function + -- lua_expr(lua expressions), vim_fun(viml function name) + -- lua_expr is short for lua-expression and vim_fun is short fror vim-function type = nil, padding = 1, -- adds padding to the left and right of components -- padding can be specified to left or right separately like diff --git a/doc/lualine.txt b/doc/lualine.txt index 63cd840..33e0d00 100644 --- a/doc/lualine.txt +++ b/doc/lualine.txt @@ -371,8 +371,8 @@ for all components. -- When type is omitted lualine will guess it. -- Available types [format: type_name(example)] -- mod(branch/filename), stl(%f/%m), var(g:coc_status/bo:modifiable), - -- luae(lua expressions), vimf(viml function name) - -- luae is short for lua-expression and vimf is short fror vim-function + -- lua_expr(lua expressions), vim_fun(viml function name) + -- lua_expr is short for lua-expression and vim_fun is short fror vim-function type = nil, padding = 1, -- adds padding to the left and right of components -- padding can be specified to left or right separately like diff --git a/lua/lualine/components/special/eval_func_component.lua b/lua/lualine/components/special/eval_func_component.lua index a209eba..94253e3 100644 --- a/lua/lualine/components/special/eval_func_component.lua +++ b/lua/lualine/components/special/eval_func_component.lua @@ -11,12 +11,12 @@ function M:update_status() status = M.vim_function(component) end else - if self.options.type == 'luae' then + if self.options.type == 'lua_expr' then ok, status = pcall(M.lua_eval, component) if not ok then status = nil end - elseif self.options.type == 'vimf' then + elseif self.options.type == 'vim_fun' then status = M.vim_function(component) end end diff --git a/lua/lualine/utils/loader.lua b/lua/lualine/utils/loader.lua index 175008f..45a7788 100644 --- a/lua/lualine/utils/loader.lua +++ b/lua/lualine/utils/loader.lua @@ -11,7 +11,7 @@ local is_valid_filename = lualine_require.is_valid_filename local sep = lualine_require.sep local component_types = { - luaf = function(component) + lua_fun = function(component) return require 'lualine.components.special.function_component'(component) end, mod = function(component) @@ -44,14 +44,14 @@ local component_types = { local function component_loader(component) if type(component[1]) == 'function' then - return component_types.luaf(component) + return component_types.lua_fun(component) end if type(component[1]) == 'string' then -- load the component if component.type ~= nil then - if component_types[component.type] and component.type ~= 'luaf' then + if component_types[component.type] and component.type ~= 'lua_fun' then return component_types[component.type](component) - elseif component.type == 'vimf' or component.type == 'luae' then + elseif component.type == 'vim_fun' or component.type == 'lua_expr' then return component_types['_'](component) else modules.notice.add_notice(string.format( @@ -151,6 +151,36 @@ When you set `padding = x` it's same as `padding = {left = x, right = x}` component.right_padding = nil end end, + type_name = function() + local changed_to = component.type == 'luae' and 'lua_expr' or 'vim_fun' + modules.notice.add_notice(string.format( + [[ +### option.type.%s + +type name `%s` has been deprecated. +Please use `%s`. + +You have some thing like this in your config config for %s component: + +```lua + type = %s, +``` + +You'll have to change it to this to retain old behavior: + +```lua + type = %s +``` +]], + component.type, + component.type, + changed_to, + tostring(component[1]), + component.type, + changed_to + )) + component.type = changed_to + end, } if component.upper ~= nil or component.lower ~= nil then types.case() @@ -158,6 +188,9 @@ When you set `padding = x` it's same as `padding = {left = x, right = x}` if component.left_padding ~= nil or component.right_padding ~= nil then types.padding() end + if component.type == 'luae' or component.type == 'vimf' then + types.type_name() + end end local function load_sections(sections, options)