refactor: rename component type luae and vimf

- rename luae -> lua_expr
- rename vimf -> vim_fun
luae & vimf were too vague and hand to understand.

BREAKING_CHANGE
This commit is contained in:
shadmansaleh 2021-10-11 13:47:37 +06:00
parent 6e936efe06
commit d25a37fea0
4 changed files with 43 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)