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:
parent
6e936efe06
commit
d25a37fea0
|
@ -390,8 +390,8 @@ sections = {
|
||||||
-- When type is omitted lualine will guess it.
|
-- When type is omitted lualine will guess it.
|
||||||
-- Available types [format: type_name(example)]
|
-- Available types [format: type_name(example)]
|
||||||
-- mod(branch/filename), stl(%f/%m), var(g:coc_status/bo:modifiable),
|
-- mod(branch/filename), stl(%f/%m), var(g:coc_status/bo:modifiable),
|
||||||
-- luae(lua expressions), vimf(viml function name)
|
-- lua_expr(lua expressions), vim_fun(viml function name)
|
||||||
-- luae is short for lua-expression and vimf is short fror vim-function
|
-- lua_expr is short for lua-expression and vim_fun is short fror vim-function
|
||||||
type = nil,
|
type = nil,
|
||||||
padding = 1, -- adds padding to the left and right of components
|
padding = 1, -- adds padding to the left and right of components
|
||||||
-- padding can be specified to left or right separately like
|
-- padding can be specified to left or right separately like
|
||||||
|
|
|
@ -371,8 +371,8 @@ for all components.
|
||||||
-- When type is omitted lualine will guess it.
|
-- When type is omitted lualine will guess it.
|
||||||
-- Available types [format: type_name(example)]
|
-- Available types [format: type_name(example)]
|
||||||
-- mod(branch/filename), stl(%f/%m), var(g:coc_status/bo:modifiable),
|
-- mod(branch/filename), stl(%f/%m), var(g:coc_status/bo:modifiable),
|
||||||
-- luae(lua expressions), vimf(viml function name)
|
-- lua_expr(lua expressions), vim_fun(viml function name)
|
||||||
-- luae is short for lua-expression and vimf is short fror vim-function
|
-- lua_expr is short for lua-expression and vim_fun is short fror vim-function
|
||||||
type = nil,
|
type = nil,
|
||||||
padding = 1, -- adds padding to the left and right of components
|
padding = 1, -- adds padding to the left and right of components
|
||||||
-- padding can be specified to left or right separately like
|
-- padding can be specified to left or right separately like
|
||||||
|
|
|
@ -11,12 +11,12 @@ function M:update_status()
|
||||||
status = M.vim_function(component)
|
status = M.vim_function(component)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if self.options.type == 'luae' then
|
if self.options.type == 'lua_expr' then
|
||||||
ok, status = pcall(M.lua_eval, component)
|
ok, status = pcall(M.lua_eval, component)
|
||||||
if not ok then
|
if not ok then
|
||||||
status = nil
|
status = nil
|
||||||
end
|
end
|
||||||
elseif self.options.type == 'vimf' then
|
elseif self.options.type == 'vim_fun' then
|
||||||
status = M.vim_function(component)
|
status = M.vim_function(component)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@ local is_valid_filename = lualine_require.is_valid_filename
|
||||||
local sep = lualine_require.sep
|
local sep = lualine_require.sep
|
||||||
|
|
||||||
local component_types = {
|
local component_types = {
|
||||||
luaf = function(component)
|
lua_fun = function(component)
|
||||||
return require 'lualine.components.special.function_component'(component)
|
return require 'lualine.components.special.function_component'(component)
|
||||||
end,
|
end,
|
||||||
mod = function(component)
|
mod = function(component)
|
||||||
|
@ -44,14 +44,14 @@ local component_types = {
|
||||||
|
|
||||||
local function component_loader(component)
|
local function component_loader(component)
|
||||||
if type(component[1]) == 'function' then
|
if type(component[1]) == 'function' then
|
||||||
return component_types.luaf(component)
|
return component_types.lua_fun(component)
|
||||||
end
|
end
|
||||||
if type(component[1]) == 'string' then
|
if type(component[1]) == 'string' then
|
||||||
-- load the component
|
-- load the component
|
||||||
if component.type ~= nil then
|
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)
|
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)
|
return component_types['_'](component)
|
||||||
else
|
else
|
||||||
modules.notice.add_notice(string.format(
|
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
|
component.right_padding = nil
|
||||||
end
|
end
|
||||||
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
|
if component.upper ~= nil or component.lower ~= nil then
|
||||||
types.case()
|
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
|
if component.left_padding ~= nil or component.right_padding ~= nil then
|
||||||
types.padding()
|
types.padding()
|
||||||
end
|
end
|
||||||
|
if component.type == 'luae' or component.type == 'vimf' then
|
||||||
|
types.type_name()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function load_sections(sections, options)
|
local function load_sections(sections, options)
|
||||||
|
|
Loading…
Reference in New Issue