Refactor: simplify options (#24)
* Deprecate upper & lower option. These does not make much sense and `format` option can provide same results * Unify padding options * Add persistent notices * Make separators use left/right keys to specify left right instead of sequence * Rename format -> fmt * Rename condition -> cond * Rename disable_text -> icon_only * Unify color_error,warning,info,hint under diagnostics_color * Unify color_added,modified,removed hint under diff_color
This commit is contained in:
parent
62bfe80fb6
commit
2f801ed622
57
README.md
57
README.md
|
@ -99,8 +99,8 @@ require'lualine'.setup {
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = true,
|
icons_enabled = true,
|
||||||
theme = 'auto',
|
theme = 'auto',
|
||||||
component_separators = {'', ''},
|
component_separators = { left = '', right = ''},
|
||||||
section_separators = {'', ''},
|
section_separators = { left = '', right = ''},
|
||||||
disabled_filetypes = {}
|
disabled_filetypes = {}
|
||||||
},
|
},
|
||||||
sections = {
|
sections = {
|
||||||
|
@ -181,11 +181,14 @@ Lualine defines two kinds of separators:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
options = {
|
options = {
|
||||||
section_separators = {'', ''},
|
section_separators = { left = '', right = ''},
|
||||||
component_separators = {'', ''}
|
component_separators = { left = '', right = ''}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Here left means it'll be used for left sections (a, b, c) and right means
|
||||||
|
it'll be used for right sections (x, y, z).
|
||||||
|
|
||||||
<details><summary>Disabling separators</summary>
|
<details><summary>Disabling separators</summary>
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
|
@ -278,12 +281,16 @@ but you cannot use local options as global.
|
||||||
Global option used locally overwrites the global, for example:
|
Global option used locally overwrites the global, for example:
|
||||||
```lua
|
```lua
|
||||||
require'lualine'.setup {
|
require'lualine'.setup {
|
||||||
options = {lower = true},
|
options = {fmt = string.lower},
|
||||||
sections = {lualine_a = {{'mode', lower = false}}, lualine_b = {'branch'}}
|
sections = {lualine_a = {
|
||||||
|
{'mode', fmt = function(str) return str:sub(1,1) end}},
|
||||||
|
lualine_b = {'branch'}}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`mode` will be displayed with `lower = false` and `branch` will be displayed with `lower = true`
|
`mode` will be formatted with the passed fa=unction so only first char will be
|
||||||
|
shown . On the other hand branch will be formatted with global formatter
|
||||||
|
`string.lower` so it will be showed in lower case.
|
||||||
|
|
||||||
#### Available options
|
#### Available options
|
||||||
|
|
||||||
|
@ -294,11 +301,9 @@ Global option used locally overwrites the global, for example:
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = true, -- displays icons in alongside component
|
icons_enabled = true, -- displays icons in alongside component
|
||||||
padding = 1, -- adds padding to the left and right of components
|
padding = 1, -- adds padding to the left and right of components
|
||||||
left_padding = 1, -- adds padding to the left of components
|
-- padding can be specified to left or right separately like
|
||||||
right_padding =1, -- adds padding to the right of components
|
-- padding = { left = left_padding, right = right_padding }
|
||||||
upper = false, -- displays components in uppercase
|
fmt = nil -- fmt function, formats component's output
|
||||||
lower = false, -- displays components in lowercase
|
|
||||||
format = nil -- format function, formats component's output
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -317,10 +322,12 @@ sections = {
|
||||||
-- when a string is given it's treated as component_separator.
|
-- when a string is given it's treated as component_separator.
|
||||||
-- When a table is given it's treated as section_separator.
|
-- When a table is given it's treated as section_separator.
|
||||||
-- This options can be used to set colored separators
|
-- This options can be used to set colored separators
|
||||||
-- arround component. Option need to be set like `separator = {'', ''}`.
|
-- arround component. Option need to be set like
|
||||||
-- Where first element is left_separator and 2nd element is right separator.
|
-- `separator = { left = '', right = ''}`.
|
||||||
|
-- Where left will be placed in left side of component
|
||||||
|
-- and right will be placed in right side of component
|
||||||
-- Passing empty string disables that separator
|
-- Passing empty string disables that separator
|
||||||
condition = nil, -- condition function, component is loaded when function returns true
|
cond = nil, -- condition function, component is loaded when function returns true
|
||||||
-- custom color for component in format
|
-- custom color for component in format
|
||||||
-- color = {fg = '#rrggbb', bg= '#rrggbb', gui='style'}
|
-- color = {fg = '#rrggbb', bg= '#rrggbb', gui='style'}
|
||||||
-- or highlight group
|
-- or highlight group
|
||||||
|
@ -358,10 +365,12 @@ sections = {
|
||||||
-- displays diagnostics from defined severity
|
-- displays diagnostics from defined severity
|
||||||
sections = {'error', 'warn', 'info', 'hint'},
|
sections = {'error', 'warn', 'info', 'hint'},
|
||||||
-- all colors are in format #rrggbb
|
-- all colors are in format #rrggbb
|
||||||
color_error = nil, -- changes diagnostic's error foreground color
|
diagnostics_color = {
|
||||||
color_warn = nil, -- changes diagnostic's warn foreground color
|
error = nil, -- changes diagnostic's error foreground color
|
||||||
color_info = nil, -- Changes diagnostic's info foreground color
|
warn = nil, -- changes diagnostic's warn foreground color
|
||||||
color_hint = nil, -- Changes diagnostic's hint foreground color
|
info = nil, -- Changes diagnostic's info foreground color
|
||||||
|
hint = nil, -- Changes diagnostic's hint foreground color
|
||||||
|
}
|
||||||
symbols = {error = 'E', warn = 'W', info = 'I', hint = 'H'}
|
symbols = {error = 'E', warn = 'W', info = 'I', hint = 'H'}
|
||||||
update_in_insert = false, -- Update diagnostics in insert mode
|
update_in_insert = false, -- Update diagnostics in insert mode
|
||||||
}
|
}
|
||||||
|
@ -393,7 +402,7 @@ sections = {
|
||||||
{
|
{
|
||||||
'filetype',
|
'filetype',
|
||||||
colored = true, -- displays filetype icon in color if set to `true
|
colored = true, -- displays filetype icon in color if set to `true
|
||||||
disable_text = false -- Display only icon for filetype
|
icon_only = false -- Display only icon for filetype
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -408,9 +417,11 @@ sections = {
|
||||||
'diff',
|
'diff',
|
||||||
colored = true, -- displays diff status in color if set to true
|
colored = true, -- displays diff status in color if set to true
|
||||||
-- all colors are in format #rrggbb
|
-- all colors are in format #rrggbb
|
||||||
color_added = nil, -- changes diff's added foreground color
|
diff_color = {
|
||||||
color_modified = nil, -- changes diff's modified foreground color
|
added = nil, -- changes diff's added foreground color
|
||||||
color_removed = nil, -- changes diff's removed foreground color
|
modified = nil, -- changes diff's modified foreground color
|
||||||
|
removed = nil, -- changes diff's removed foreground color
|
||||||
|
}
|
||||||
symbols = {added = '+', modified = '~', removed = '-'} -- changes diff symbols
|
symbols = {added = '+', modified = '~', removed = '-'} -- changes diff symbols
|
||||||
source = nil, -- A function that works as a data source for diff.
|
source = nil, -- A function that works as a data source for diff.
|
||||||
-- it must return a table like
|
-- it must return a table like
|
||||||
|
|
|
@ -83,8 +83,8 @@ Default config
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = true,
|
icons_enabled = true,
|
||||||
theme = 'auto',
|
theme = 'auto',
|
||||||
component_separators = {'', ''},
|
component_separators = { left = '', right = ''},
|
||||||
section_separators = {'', ''},
|
section_separators = { left = '', right = ''},
|
||||||
disabled_filetypes = {}
|
disabled_filetypes = {}
|
||||||
},
|
},
|
||||||
sections = {
|
sections = {
|
||||||
|
@ -169,12 +169,15 @@ Lualine defines two kinds of separators:
|
||||||
|
|
||||||
>
|
>
|
||||||
options = {
|
options = {
|
||||||
section_separators = {'', ''},
|
section_separators = { left = '', right = ''},
|
||||||
component_separators = {'', ''}
|
component_separators = { left = '', right = ''}
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
|
Here left means it’ll be used for left sections (a, b, c) and right means
|
||||||
|
it’ll be used for right sections (x, y, z).
|
||||||
|
|
||||||
Disabling separators
|
Disabling separators
|
||||||
|
|
||||||
>
|
>
|
||||||
|
@ -273,14 +276,17 @@ locally overwrites the global, for example:
|
||||||
|
|
||||||
>
|
>
|
||||||
require'lualine'.setup {
|
require'lualine'.setup {
|
||||||
options = {lower = true},
|
options = {fmt = string.lower},
|
||||||
sections = {lualine_a = {{'mode', lower = false}}, lualine_b = {'branch'}}
|
sections = {lualine_a = {
|
||||||
|
{'mode', fmt = function(str) return str:sub(1,1) end}},
|
||||||
|
lualine_b = {'branch'}}
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
`mode` will be displayed with `lower = false` and `branch` will be displayed
|
`mode` will be formatted with the passed fa=unction so only first char will be
|
||||||
with `lower = true`
|
shown. On the other hand branch will be formatted with global formatter
|
||||||
|
`string.lower` so it will be showed in lower case.
|
||||||
|
|
||||||
*lualine-Available-options*
|
*lualine-Available-options*
|
||||||
|
|
||||||
|
@ -290,11 +296,9 @@ Global options ~
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = true, -- displays icons in alongside component
|
icons_enabled = true, -- displays icons in alongside component
|
||||||
padding = 1, -- adds padding to the left and right of components
|
padding = 1, -- adds padding to the left and right of components
|
||||||
left_padding = 1, -- adds padding to the left of components
|
-- padding can be specified to left or right separately like
|
||||||
right_padding =1, -- adds padding to the right of components
|
-- padding = { left = left_padding, right = right_padding }
|
||||||
upper = false, -- displays components in uppercase
|
fmt = nil -- fmt function, formats component's output
|
||||||
lower = false, -- displays components in lowercase
|
|
||||||
format = nil -- format function, formats component's output
|
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
|
@ -311,10 +315,12 @@ Local options ~
|
||||||
-- when a string is given it's treated as component_separator.
|
-- when a string is given it's treated as component_separator.
|
||||||
-- When a table is given it's treated as section_separator.
|
-- When a table is given it's treated as section_separator.
|
||||||
-- This options can be used to set colored separators
|
-- This options can be used to set colored separators
|
||||||
-- arround component. Option need to be set like `separator = {'', ''}`.
|
-- arround component. Option need to be set like
|
||||||
-- Where first element is left_separator and 2nd element is right separator.
|
-- `separator = { left = '', right = ''}`.
|
||||||
|
-- Where left will be placed in left side of component
|
||||||
|
-- and right will be placed in right side of component
|
||||||
-- Passing empty string disables that separator
|
-- Passing empty string disables that separator
|
||||||
condition = nil, -- condition function, component is loaded when function returns true
|
cond = nil, -- condition function, component is loaded when function returns true
|
||||||
-- custom color for component in format
|
-- custom color for component in format
|
||||||
-- color = {fg = '#rrggbb', bg= '#rrggbb', gui='style'}
|
-- color = {fg = '#rrggbb', bg= '#rrggbb', gui='style'}
|
||||||
-- or highlight group
|
-- or highlight group
|
||||||
|
@ -350,10 +356,12 @@ Component specific local options ~
|
||||||
-- displays diagnostics from defined severity
|
-- displays diagnostics from defined severity
|
||||||
sections = {'error', 'warn', 'info', 'hint'},
|
sections = {'error', 'warn', 'info', 'hint'},
|
||||||
-- all colors are in format #rrggbb
|
-- all colors are in format #rrggbb
|
||||||
color_error = nil, -- changes diagnostic's error foreground color
|
diagnostics_color = {
|
||||||
color_warn = nil, -- changes diagnostic's warn foreground color
|
error = nil, -- changes diagnostic's error foreground color
|
||||||
color_info = nil, -- Changes diagnostic's info foreground color
|
warn = nil, -- changes diagnostic's warn foreground color
|
||||||
color_hint = nil, -- Changes diagnostic's hint foreground color
|
info = nil, -- Changes diagnostic's info foreground color
|
||||||
|
hint = nil, -- Changes diagnostic's hint foreground color
|
||||||
|
}
|
||||||
symbols = {error = 'E', warn = 'W', info = 'I', hint = 'H'}
|
symbols = {error = 'E', warn = 'W', info = 'I', hint = 'H'}
|
||||||
update_in_insert = false, -- Update diagnostics in insert mode
|
update_in_insert = false, -- Update diagnostics in insert mode
|
||||||
}
|
}
|
||||||
|
@ -387,7 +395,7 @@ Component specific local options ~
|
||||||
{
|
{
|
||||||
'filetype',
|
'filetype',
|
||||||
colored = true, -- displays filetype icon in color if set to `true
|
colored = true, -- displays filetype icon in color if set to `true
|
||||||
disable_text = false -- Display only icon for filetype
|
icon_only = false -- Display only icon for filetype
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -403,9 +411,11 @@ Component specific local options ~
|
||||||
'diff',
|
'diff',
|
||||||
colored = true, -- displays diff status in color if set to true
|
colored = true, -- displays diff status in color if set to true
|
||||||
-- all colors are in format #rrggbb
|
-- all colors are in format #rrggbb
|
||||||
color_added = nil, -- changes diff's added foreground color
|
diff_color = {
|
||||||
color_modified = nil, -- changes diff's modified foreground color
|
added = nil, -- changes diff's added foreground color
|
||||||
color_removed = nil, -- changes diff's removed foreground color
|
modified = nil, -- changes diff's modified foreground color
|
||||||
|
removed = nil, -- changes diff's removed foreground color
|
||||||
|
}
|
||||||
symbols = {added = '+', modified = '~', removed = '-'} -- changes diff symbols
|
symbols = {added = '+', modified = '~', removed = '-'} -- changes diff symbols
|
||||||
source = nil, -- A function that works as a data source for diff.
|
source = nil, -- A function that works as a data source for diff.
|
||||||
-- it must return a table like
|
-- it must return a table like
|
||||||
|
|
|
@ -35,18 +35,18 @@ require('lualine').setup {
|
||||||
options = {
|
options = {
|
||||||
theme = bubbles_theme,
|
theme = bubbles_theme,
|
||||||
component_separators = '|',
|
component_separators = '|',
|
||||||
section_separators = { '', '' },
|
section_separators = { left = '', right = '' },
|
||||||
},
|
},
|
||||||
sections = {
|
sections = {
|
||||||
lualine_a = {
|
lualine_a = {
|
||||||
{ 'mode', separator = { '', '' }, right_padding = 2 },
|
{ 'mode', separator = { left = '' }, right_padding = 2 },
|
||||||
},
|
},
|
||||||
lualine_b = { 'filename', 'branch' },
|
lualine_b = { 'filename', 'branch' },
|
||||||
lualine_c = { 'fileformat' },
|
lualine_c = { 'fileformat' },
|
||||||
lualine_x = {},
|
lualine_x = {},
|
||||||
lualine_y = { 'filetype', 'progress' },
|
lualine_y = { 'filetype', 'progress' },
|
||||||
lualine_z = {
|
lualine_z = {
|
||||||
{ 'location', separator = { '', '' }, left_padding = 2 },
|
{ 'location', separator = { right = '' }, left_padding = 2 },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
inactive_sections = {
|
inactive_sections = {
|
||||||
|
|
|
@ -83,7 +83,7 @@ ins_left {
|
||||||
return '▊'
|
return '▊'
|
||||||
end,
|
end,
|
||||||
color = { fg = colors.blue }, -- Sets highlighting of component
|
color = { fg = colors.blue }, -- Sets highlighting of component
|
||||||
left_padding = 0, -- We don't need space before this
|
padding = { left = 0, right = 1 }, -- We don't need space before this
|
||||||
}
|
}
|
||||||
|
|
||||||
ins_left {
|
ins_left {
|
||||||
|
@ -116,18 +116,18 @@ ins_left {
|
||||||
return ''
|
return ''
|
||||||
end,
|
end,
|
||||||
color = 'LualineMode',
|
color = 'LualineMode',
|
||||||
left_padding = 0,
|
padding = { right = 1 },
|
||||||
}
|
}
|
||||||
|
|
||||||
ins_left {
|
ins_left {
|
||||||
-- filesize component
|
-- filesize component
|
||||||
'filesize',
|
'filesize',
|
||||||
condition = conditions.buffer_not_empty,
|
cond = conditions.buffer_not_empty,
|
||||||
}
|
}
|
||||||
|
|
||||||
ins_left {
|
ins_left {
|
||||||
'filename',
|
'filename',
|
||||||
condition = conditions.buffer_not_empty,
|
cond = conditions.buffer_not_empty,
|
||||||
color = { fg = colors.magenta, gui = 'bold' },
|
color = { fg = colors.magenta, gui = 'bold' },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,9 +139,11 @@ ins_left {
|
||||||
'diagnostics',
|
'diagnostics',
|
||||||
sources = { 'nvim_lsp' },
|
sources = { 'nvim_lsp' },
|
||||||
symbols = { error = ' ', warn = ' ', info = ' ' },
|
symbols = { error = ' ', warn = ' ', info = ' ' },
|
||||||
|
diagnostics_color = {
|
||||||
color_error = { fg = colors.red },
|
color_error = { fg = colors.red },
|
||||||
color_warn = { fg = colors.yellow },
|
color_warn = { fg = colors.yellow },
|
||||||
color_info = { fg = colors.cyan },
|
color_info = { fg = colors.cyan },
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Insert mid section. You can make any number of sections in neovim :)
|
-- Insert mid section. You can make any number of sections in neovim :)
|
||||||
|
@ -176,14 +178,14 @@ ins_left {
|
||||||
-- Add components to right sections
|
-- Add components to right sections
|
||||||
ins_right {
|
ins_right {
|
||||||
'o:encoding', -- option component same as &encoding in viml
|
'o:encoding', -- option component same as &encoding in viml
|
||||||
upper = true, -- I'm not sure why it's upper case either ;)
|
fmt = string.upper, -- I'm not sure why it's upper case either ;)
|
||||||
condition = conditions.hide_in_width,
|
cond = conditions.hide_in_width,
|
||||||
color = { fg = colors.green, gui = 'bold' },
|
color = { fg = colors.green, gui = 'bold' },
|
||||||
}
|
}
|
||||||
|
|
||||||
ins_right {
|
ins_right {
|
||||||
'fileformat',
|
'fileformat',
|
||||||
upper = true,
|
fmt = string.upper,
|
||||||
icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh
|
icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh
|
||||||
color = { fg = colors.green, gui = 'bold' },
|
color = { fg = colors.green, gui = 'bold' },
|
||||||
}
|
}
|
||||||
|
@ -191,7 +193,7 @@ ins_right {
|
||||||
ins_right {
|
ins_right {
|
||||||
'branch',
|
'branch',
|
||||||
icon = '',
|
icon = '',
|
||||||
condition = conditions.check_git_workspace,
|
cond = conditions.check_git_workspace,
|
||||||
color = { fg = colors.violet, gui = 'bold' },
|
color = { fg = colors.violet, gui = 'bold' },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,10 +201,12 @@ ins_right {
|
||||||
'diff',
|
'diff',
|
||||||
-- Is it me or the symbol for modified us really weird
|
-- Is it me or the symbol for modified us really weird
|
||||||
symbols = { added = ' ', modified = '柳 ', removed = ' ' },
|
symbols = { added = ' ', modified = '柳 ', removed = ' ' },
|
||||||
color_added = { fg = colors.green },
|
diff_color = {
|
||||||
color_modified = { fg = colors.orange },
|
added = { fg = colors.green },
|
||||||
color_removed = { fg = colors.red },
|
modified = { fg = colors.orange },
|
||||||
condition = conditions.hide_in_width,
|
removed = { fg = colors.red },
|
||||||
|
},
|
||||||
|
cond = conditions.hide_in_width,
|
||||||
}
|
}
|
||||||
|
|
||||||
ins_right {
|
ins_right {
|
||||||
|
@ -210,7 +214,7 @@ ins_right {
|
||||||
return '▊'
|
return '▊'
|
||||||
end,
|
end,
|
||||||
color = { fg = colors.blue },
|
color = { fg = colors.blue },
|
||||||
right_padding = 0,
|
padding = { left = 1 },
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Now don't forget to initialize lualine
|
-- Now don't forget to initialize lualine
|
||||||
|
|
|
@ -5,6 +5,28 @@ local highlight = require 'lualine.highlight'
|
||||||
-- Used to provide a unique id for each component
|
-- Used to provide a unique id for each component
|
||||||
local component_no = 1
|
local component_no = 1
|
||||||
|
|
||||||
|
local function check_deprecated_options(options)
|
||||||
|
local function rename_notice(before, now)
|
||||||
|
if options[before] then
|
||||||
|
require('lualine.utils.notices').add_notice(string.format(
|
||||||
|
[[
|
||||||
|
### option.%s
|
||||||
|
%s option has been renamed to `%s`. Please use `%s` instead in your config
|
||||||
|
for %s component.
|
||||||
|
]],
|
||||||
|
before,
|
||||||
|
before,
|
||||||
|
now,
|
||||||
|
now,
|
||||||
|
options.component_name or 'function'
|
||||||
|
))
|
||||||
|
options[now] = options[before]
|
||||||
|
options[before] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rename_notice('format', 'fmt')
|
||||||
|
rename_notice('condition', 'cond')
|
||||||
|
end
|
||||||
local Component = {
|
local Component = {
|
||||||
-- Creates a new component
|
-- Creates a new component
|
||||||
new = function(self, options, child)
|
new = function(self, options, child)
|
||||||
|
@ -15,6 +37,7 @@ local Component = {
|
||||||
-- Operation that are required for creating new components but not for inheritence
|
-- Operation that are required for creating new components but not for inheritence
|
||||||
if options ~= nil then
|
if options ~= nil then
|
||||||
component_no = component_no + 1
|
component_no = component_no + 1
|
||||||
|
check_deprecated_options(new_component.options)
|
||||||
if not options.component_name then
|
if not options.component_name then
|
||||||
new_component.options.component_name = tostring(component_no)
|
new_component.options.component_name = tostring(component_no)
|
||||||
end
|
end
|
||||||
|
@ -29,9 +52,9 @@ local Component = {
|
||||||
if self.options.separator == nil then
|
if self.options.separator == nil then
|
||||||
if self.options.component_separators then
|
if self.options.component_separators then
|
||||||
if self.options.self.section < 'lualine_x' then
|
if self.options.self.section < 'lualine_x' then
|
||||||
self.options.separator = self.options.component_separators[1]
|
self.options.separator = self.options.component_separators.left
|
||||||
else
|
else
|
||||||
self.options.separator = self.options.component_separators[2]
|
self.options.separator = self.options.component_separators.right
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -63,8 +86,16 @@ local Component = {
|
||||||
|
|
||||||
-- Adds spaces to left and right of a component
|
-- Adds spaces to left and right of a component
|
||||||
apply_padding = function(self)
|
apply_padding = function(self)
|
||||||
local l_padding = (self.options.left_padding or self.options.padding or 1)
|
local padding = self.options.padding
|
||||||
local r_padding = (self.options.right_padding or self.options.padding or 1)
|
local l_padding, r_padding
|
||||||
|
if padding == nil then
|
||||||
|
padding = 1
|
||||||
|
end
|
||||||
|
if type(padding) == 'number' then
|
||||||
|
l_padding, r_padding = padding, padding
|
||||||
|
elseif type(padding) == 'table' then
|
||||||
|
l_padding, r_padding = padding.left, padding.right
|
||||||
|
end
|
||||||
if l_padding then
|
if l_padding then
|
||||||
if self.status:find '%%#.*#' == 1 then
|
if self.status:find '%%#.*#' == 1 then
|
||||||
-- When component has changed the highlight at begining
|
-- When component has changed the highlight at begining
|
||||||
|
@ -114,9 +145,9 @@ local Component = {
|
||||||
if type(separator) == 'table' then
|
if type(separator) == 'table' then
|
||||||
if self.options.separator[2] == '' then
|
if self.options.separator[2] == '' then
|
||||||
if self.options.self.section < 'lualine_x' then
|
if self.options.self.section < 'lualine_x' then
|
||||||
separator = self.options.component_separators[1]
|
separator = self.options.component_separators.left
|
||||||
else
|
else
|
||||||
separator = self.options.component_separators[2]
|
separator = self.options.component_separators.right
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
|
@ -132,12 +163,12 @@ local Component = {
|
||||||
if type(self.options.separator) ~= 'table' then
|
if type(self.options.separator) ~= 'table' then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if self.options.separator[1] ~= '' then
|
if self.options.separator.left ~= nil and self.options.separator.left ~= '' then
|
||||||
self.status = string.format('%%s{%s}%s', self.options.separator[1], self.status)
|
self.status = string.format('%%s{%s}%s', self.options.separator.left, self.status)
|
||||||
self.strip_previous_separator = true
|
self.strip_previous_separator = true
|
||||||
end
|
end
|
||||||
if self.options.separator[2] ~= '' then
|
if self.options.separator.right ~= nil and self.options.separator.right ~= '' then
|
||||||
self.status = string.format('%s%%S{%s}', self.status, self.options.separator[2])
|
self.status = string.format('%s%%S{%s}', self.status, self.options.separator.right)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -162,12 +193,12 @@ local Component = {
|
||||||
self.status = ''
|
self.status = ''
|
||||||
self.applied_separator = ''
|
self.applied_separator = ''
|
||||||
|
|
||||||
if self.options.condition ~= nil and self.options.condition() ~= true then
|
if self.options.cond ~= nil and self.options.cond() ~= true then
|
||||||
return self.status
|
return self.status
|
||||||
end
|
end
|
||||||
local status = self:update_status(is_focused)
|
local status = self:update_status(is_focused)
|
||||||
if self.options.format then
|
if self.options.fmt then
|
||||||
status = self.options.format(status or '')
|
status = self.options.fmt(status or '')
|
||||||
end
|
end
|
||||||
if type(status) == 'string' and #status > 0 then
|
if type(status) == 'string' and #status > 0 then
|
||||||
self.status = status
|
self.status = status
|
||||||
|
|
|
@ -9,6 +9,33 @@ local modules = lualine_require.lazy_require {
|
||||||
|
|
||||||
local Diagnostics = lualine_require.require('lualine.component'):new()
|
local Diagnostics = lualine_require.require('lualine.component'):new()
|
||||||
|
|
||||||
|
local function check_deprecated_options(options)
|
||||||
|
if options.color_error or options.color_warn or options.color_info or options.color_hint then
|
||||||
|
options.diagnostics_color = options.diagnostics_color or {}
|
||||||
|
require('lualine.utils.notices').add_notice(string.format [[
|
||||||
|
### diagnostics.options.colors
|
||||||
|
Previously colors in diagnostics section was set with color_error, color_warning..
|
||||||
|
separate options . They've been unified under diagnostics_color options.
|
||||||
|
Now it should be something like:
|
||||||
|
```lua
|
||||||
|
{ 'diagnostics',
|
||||||
|
sources = {'nvim_lsp'},
|
||||||
|
diagnostics_color = {
|
||||||
|
error = color_error,
|
||||||
|
warning = color_warning,
|
||||||
|
info = color_info,
|
||||||
|
hint = color_hint,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
]])
|
||||||
|
options.diagnostics_color.error = options.color_error
|
||||||
|
options.diagnostics_color.warning = options.color_warning
|
||||||
|
options.diagnostics_color.info = options.color_info
|
||||||
|
options.diagnostics_color.hint = options.color_hint
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local default_symbols = {
|
local default_symbols = {
|
||||||
icons = {
|
icons = {
|
||||||
error = ' ', -- xf659
|
error = ' ', -- xf659
|
||||||
|
@ -24,26 +51,28 @@ local default_options = {
|
||||||
update_in_insert = false,
|
update_in_insert = false,
|
||||||
sources = nil,
|
sources = nil,
|
||||||
sections = { 'error', 'warn', 'info', 'hint' },
|
sections = { 'error', 'warn', 'info', 'hint' },
|
||||||
color_error = {
|
diagnostic_color = {
|
||||||
|
error = {
|
||||||
fg = modules.utils.extract_highlight_colors('LspDiagnosticsDefaultError', 'fg')
|
fg = modules.utils.extract_highlight_colors('LspDiagnosticsDefaultError', 'fg')
|
||||||
or modules.utils.extract_highlight_colors('DiffDelete', 'fg')
|
or modules.utils.extract_highlight_colors('DiffDelete', 'fg')
|
||||||
or '#e32636',
|
or '#e32636',
|
||||||
},
|
},
|
||||||
color_warn = {
|
warn = {
|
||||||
fg = modules.utils.extract_highlight_colors('LspDiagnosticsDefaultWarning', 'fg')
|
fg = modules.utils.extract_highlight_colors('LspDiagnosticsDefaultWarning', 'fg')
|
||||||
or modules.utils.extract_highlight_colors('DiffText', 'fg')
|
or modules.utils.extract_highlight_colors('DiffText', 'fg')
|
||||||
or '#ffdf00',
|
or '#ffdf00',
|
||||||
},
|
},
|
||||||
color_info = {
|
info = {
|
||||||
fg = modules.utils.extract_highlight_colors('LspDiagnosticsDefaultInformation', 'fg')
|
fg = modules.utils.extract_highlight_colors('LspDiagnosticsDefaultInformation', 'fg')
|
||||||
or modules.utils.extract_highlight_colors('Normal', 'fg')
|
or modules.utils.extract_highlight_colors('Normal', 'fg')
|
||||||
or '#ffffff',
|
or '#ffffff',
|
||||||
},
|
},
|
||||||
color_hint = {
|
hint = {
|
||||||
fg = modules.utils.extract_highlight_colors('LspDiagnosticsDefaultHint', 'fg')
|
fg = modules.utils.extract_highlight_colors('LspDiagnosticsDefaultHint', 'fg')
|
||||||
or modules.utils.extract_highlight_colors('DiffChange', 'fg')
|
or modules.utils.extract_highlight_colors('DiffChange', 'fg')
|
||||||
or '#d7afaf',
|
or '#d7afaf',
|
||||||
},
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
-- Initializer
|
-- Initializer
|
||||||
Diagnostics.new = function(self, options, child)
|
Diagnostics.new = function(self, options, child)
|
||||||
|
@ -51,6 +80,7 @@ Diagnostics.new = function(self, options, child)
|
||||||
local new_diagnostics = self._parent:new(options, child or Diagnostics)
|
local new_diagnostics = self._parent:new(options, child or Diagnostics)
|
||||||
-- Apply default options
|
-- Apply default options
|
||||||
new_diagnostics.options = vim.tbl_deep_extend('keep', new_diagnostics.options or {}, default_options)
|
new_diagnostics.options = vim.tbl_deep_extend('keep', new_diagnostics.options or {}, default_options)
|
||||||
|
check_deprecated_options(new_diagnostics.options)
|
||||||
-- Apply default symbols
|
-- Apply default symbols
|
||||||
new_diagnostics.symbols = vim.tbl_extend(
|
new_diagnostics.symbols = vim.tbl_extend(
|
||||||
'keep',
|
'keep',
|
||||||
|
@ -61,22 +91,22 @@ Diagnostics.new = function(self, options, child)
|
||||||
if new_diagnostics.options.colored then
|
if new_diagnostics.options.colored then
|
||||||
new_diagnostics.highlight_groups = {
|
new_diagnostics.highlight_groups = {
|
||||||
error = modules.highlight.create_component_highlight_group(
|
error = modules.highlight.create_component_highlight_group(
|
||||||
new_diagnostics.options.color_error,
|
new_diagnostics.options.diagnostic_color.error,
|
||||||
'diagnostics_error',
|
'diagnostics_error',
|
||||||
new_diagnostics.options
|
new_diagnostics.options
|
||||||
),
|
),
|
||||||
warn = modules.highlight.create_component_highlight_group(
|
warn = modules.highlight.create_component_highlight_group(
|
||||||
new_diagnostics.options.color_warn,
|
new_diagnostics.options.diagnostic_color.warn,
|
||||||
'diagnostics_warn',
|
'diagnostics_warn',
|
||||||
new_diagnostics.options
|
new_diagnostics.options
|
||||||
),
|
),
|
||||||
info = modules.highlight.create_component_highlight_group(
|
info = modules.highlight.create_component_highlight_group(
|
||||||
new_diagnostics.options.color_info,
|
new_diagnostics.options.diagnostic_color.info,
|
||||||
'diagnostics_info',
|
'diagnostics_info',
|
||||||
new_diagnostics.options
|
new_diagnostics.options
|
||||||
),
|
),
|
||||||
hint = modules.highlight.create_component_highlight_group(
|
hint = modules.highlight.create_component_highlight_group(
|
||||||
new_diagnostics.options.color_hint,
|
new_diagnostics.options.diagnostic_color.hint,
|
||||||
'diagnostics_hint',
|
'diagnostics_hint',
|
||||||
new_diagnostics.options
|
new_diagnostics.options
|
||||||
),
|
),
|
||||||
|
|
|
@ -9,6 +9,30 @@ local modules = lualine_require.lazy_require {
|
||||||
}
|
}
|
||||||
local Diff = lualine_require.require('lualine.component'):new()
|
local Diff = lualine_require.require('lualine.component'):new()
|
||||||
|
|
||||||
|
local function check_deprecated_options(options)
|
||||||
|
if options.color_added or options.color_modified or options.color_removed then
|
||||||
|
options.diagnostics_color = options.diagnostics_color or {}
|
||||||
|
require('lualine.utils.notices').add_notice(string.format [[
|
||||||
|
### diff.options.colors
|
||||||
|
Previously colors in diff section was set with color_added, color_modified..
|
||||||
|
separate options . They've been unified under diff_color option.
|
||||||
|
Now it should be something like:
|
||||||
|
```lua
|
||||||
|
{ 'diff',
|
||||||
|
diff_color = {
|
||||||
|
added = color_added,
|
||||||
|
modified = color_modified,
|
||||||
|
removed = color_removed,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
]])
|
||||||
|
options.diff_color.added = options.color_added
|
||||||
|
options.diff_color.modified = options.color_modified
|
||||||
|
options.diff_color.removed = options.color_removed
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Vars
|
-- Vars
|
||||||
-- variable to store git diff stats
|
-- variable to store git diff stats
|
||||||
Diff.git_diff = nil
|
Diff.git_diff = nil
|
||||||
|
@ -23,36 +47,39 @@ local diff_cache = {} -- Stores last known value of diff of a buffer
|
||||||
local default_options = {
|
local default_options = {
|
||||||
colored = true,
|
colored = true,
|
||||||
symbols = { added = '+', modified = '~', removed = '-' },
|
symbols = { added = '+', modified = '~', removed = '-' },
|
||||||
color_added = {
|
diff_color = {
|
||||||
|
added = {
|
||||||
fg = modules.utils.extract_highlight_colors('DiffAdd', 'fg') or '#f0e130',
|
fg = modules.utils.extract_highlight_colors('DiffAdd', 'fg') or '#f0e130',
|
||||||
},
|
},
|
||||||
color_modified = {
|
modified = {
|
||||||
fg = modules.utils.extract_highlight_colors('DiffChange', 'fg') or '#ff0038',
|
fg = modules.utils.extract_highlight_colors('DiffChange', 'fg') or '#ff0038',
|
||||||
},
|
},
|
||||||
color_removed = {
|
removed = {
|
||||||
fg = modules.utils.extract_highlight_colors('DiffDelete', 'fg') or '#ff0038',
|
fg = modules.utils.extract_highlight_colors('DiffDelete', 'fg') or '#ff0038',
|
||||||
},
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Initializer
|
-- Initializer
|
||||||
Diff.new = function(self, options, child)
|
Diff.new = function(self, options, child)
|
||||||
local new_instance = self._parent:new(options, child or Diff)
|
local new_instance = self._parent:new(options, child or Diff)
|
||||||
new_instance.options = vim.tbl_deep_extend('keep', new_instance.options or {}, default_options)
|
new_instance.options = vim.tbl_deep_extend('keep', new_instance.options or {}, default_options)
|
||||||
|
check_deprecated_options(new_instance.options)
|
||||||
-- create highlights and save highlight_name in highlights table
|
-- create highlights and save highlight_name in highlights table
|
||||||
if new_instance.options.colored then
|
if new_instance.options.colored then
|
||||||
new_instance.highlights = {
|
new_instance.highlights = {
|
||||||
added = modules.highlight.create_component_highlight_group(
|
added = modules.highlight.create_component_highlight_group(
|
||||||
new_instance.options.color_added,
|
new_instance.options.diff_color.added,
|
||||||
'diff_added',
|
'diff_added',
|
||||||
new_instance.options
|
new_instance.options
|
||||||
),
|
),
|
||||||
modified = modules.highlight.create_component_highlight_group(
|
modified = modules.highlight.create_component_highlight_group(
|
||||||
new_instance.options.color_modified,
|
new_instance.options.diff_color.modified,
|
||||||
'diff_modified',
|
'diff_modified',
|
||||||
new_instance.options
|
new_instance.options
|
||||||
),
|
),
|
||||||
removed = modules.highlight.create_component_highlight_group(
|
removed = modules.highlight.create_component_highlight_group(
|
||||||
new_instance.options.color_removed,
|
new_instance.options.diff_color.removed,
|
||||||
'diff_removed',
|
'diff_removed',
|
||||||
new_instance.options
|
new_instance.options
|
||||||
),
|
),
|
||||||
|
|
|
@ -7,14 +7,36 @@ local modules = lualine_require.lazy_require {
|
||||||
}
|
}
|
||||||
local FileType = lualine_require.require('lualine.component'):new()
|
local FileType = lualine_require.require('lualine.component'):new()
|
||||||
|
|
||||||
|
local function check_deprecated_options(options)
|
||||||
|
local function rename_notice(before, now)
|
||||||
|
if options[before] then
|
||||||
|
require('lualine.utils.notices').add_notice(string.format(
|
||||||
|
[[
|
||||||
|
### option.%s
|
||||||
|
%s option has been renamed to `%s`. Please use `%s` instead in your config
|
||||||
|
for filetype component.
|
||||||
|
]],
|
||||||
|
before,
|
||||||
|
before,
|
||||||
|
now,
|
||||||
|
now
|
||||||
|
))
|
||||||
|
options[now] = options[before]
|
||||||
|
options[before] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rename_notice('disable_text', 'icon_only')
|
||||||
|
end
|
||||||
|
|
||||||
local default_options = {
|
local default_options = {
|
||||||
colored = true,
|
colored = true,
|
||||||
disable_text = false,
|
icon_only = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
function FileType:new(options, child)
|
function FileType:new(options, child)
|
||||||
local new_instance = self._parent:new(options, child or FileType)
|
local new_instance = self._parent:new(options, child or FileType)
|
||||||
new_instance.options = vim.tbl_deep_extend('keep', new_instance.options or {}, default_options)
|
new_instance.options = vim.tbl_deep_extend('keep', new_instance.options or {}, default_options)
|
||||||
|
check_deprecated_options(new_instance.options)
|
||||||
return new_instance
|
return new_instance
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -59,7 +81,7 @@ function FileType:apply_icon()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.options.disable_text then
|
if self.options.icon_only then
|
||||||
self.status = icon
|
self.status = icon
|
||||||
else
|
else
|
||||||
self.status = icon .. ' ' .. self.status
|
self.status = icon .. ' ' .. self.status
|
||||||
|
|
|
@ -4,8 +4,8 @@ local config = {
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = true,
|
icons_enabled = true,
|
||||||
theme = 'auto',
|
theme = 'auto',
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
section_separators = { '', '' },
|
section_separators = { left = '', right = '' },
|
||||||
disabled_filetypes = {},
|
disabled_filetypes = {},
|
||||||
},
|
},
|
||||||
sections = {
|
sections = {
|
||||||
|
@ -28,13 +28,25 @@ local config = {
|
||||||
extensions = {},
|
extensions = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- change separator format 'x' or {'x'} to {'x', 'x'}
|
local function check_sep_format_deprication(sep)
|
||||||
|
if type(sep) == 'table' and vim.tbl_islist(sep) then
|
||||||
|
require('lualine.utils.notices').add_persistent_notice(string.format [[
|
||||||
|
### option.separator
|
||||||
|
Using list for configuring separators has been depricated. Please configure it
|
||||||
|
with {left = left_sep, right = right_sep} like table.
|
||||||
|
]])
|
||||||
|
sep = { left = sep[1], right = sep[2] or sep[1] }
|
||||||
|
end
|
||||||
|
return sep
|
||||||
|
end
|
||||||
|
|
||||||
|
-- change separator format 'x' to {left='x', right='x'}
|
||||||
local function fix_separators(separators)
|
local function fix_separators(separators)
|
||||||
if separators ~= nil then
|
if separators ~= nil then
|
||||||
if type(separators) == 'string' then
|
if type(separators) == 'string' then
|
||||||
return { separators, separators }
|
return { left = separators, right = separators }
|
||||||
elseif type(separators) == 'table' and #separators == 1 then
|
else
|
||||||
return { separators[1], separators[1] }
|
return check_sep_format_deprication(separators)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return separators
|
return separators
|
||||||
|
|
|
@ -10,8 +10,7 @@ local empty = {
|
||||||
function()
|
function()
|
||||||
return ' '
|
return ' '
|
||||||
end,
|
end,
|
||||||
left_padding = 0,
|
padding = 0,
|
||||||
right_padding = 0,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
M.sections = {
|
M.sections = {
|
||||||
|
|
|
@ -7,8 +7,7 @@ local empty = {
|
||||||
function()
|
function()
|
||||||
return ' '
|
return ' '
|
||||||
end,
|
end,
|
||||||
left_padding = 0,
|
padding = 0,
|
||||||
right_padding = 0,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
|
@ -7,8 +7,7 @@ local empty = {
|
||||||
function()
|
function()
|
||||||
return ' '
|
return ' '
|
||||||
end,
|
end,
|
||||||
left_padding = 0,
|
padding = 0,
|
||||||
right_padding = 0,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
|
@ -19,8 +19,7 @@ local empty = {
|
||||||
function()
|
function()
|
||||||
return ' '
|
return ' '
|
||||||
end,
|
end,
|
||||||
left_padding = 0,
|
padding = 0,
|
||||||
right_padding = 0,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
|
@ -8,8 +8,7 @@ local empty = {
|
||||||
function()
|
function()
|
||||||
return ' '
|
return ' '
|
||||||
end,
|
end,
|
||||||
left_padding = 0,
|
padding = 0,
|
||||||
right_padding = 0,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
|
@ -71,6 +71,90 @@ component type '%s' isn't recognised. Check if spelling is correct.]],
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function option_deprecatation_notice(component)
|
||||||
|
local types = {
|
||||||
|
case = function()
|
||||||
|
local kind = component.upper ~= nil and 'upper' or 'lower'
|
||||||
|
modules.notice.add_notice(string.format(
|
||||||
|
[[
|
||||||
|
### option.%s
|
||||||
|
|
||||||
|
Option `%s` has been deprecated.
|
||||||
|
Please use `fmt` option if you need to change case of a component.
|
||||||
|
|
||||||
|
You have some thing like this in your config:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
%s = true,
|
||||||
|
```
|
||||||
|
|
||||||
|
You'll have to change it to this to retain old behavior:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
fmt = string.%s
|
||||||
|
```
|
||||||
|
]],
|
||||||
|
kind,
|
||||||
|
kind,
|
||||||
|
kind,
|
||||||
|
kind
|
||||||
|
))
|
||||||
|
end,
|
||||||
|
padding = function()
|
||||||
|
local kind = component.left_padding ~= nil and 'left_padding' or 'right_padding'
|
||||||
|
modules.notice.add_notice(string.format(
|
||||||
|
[[
|
||||||
|
### option.%s
|
||||||
|
|
||||||
|
Option `%s` has been deprecated.
|
||||||
|
Please use `padding` option to set left/right padding.
|
||||||
|
|
||||||
|
You have some thing like this in your config:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
%s = %d,
|
||||||
|
```
|
||||||
|
|
||||||
|
You'll have to change it to this to retain old behavior:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
padding = { %s = %d }
|
||||||
|
```
|
||||||
|
if you've set both left_padding and right_padding for a component
|
||||||
|
you'll need to have something like
|
||||||
|
```lua
|
||||||
|
padding = { left = x, right = y }
|
||||||
|
```
|
||||||
|
When you set `padding = x` it's same as `padding = {left = x, right = x}`
|
||||||
|
]],
|
||||||
|
kind,
|
||||||
|
kind,
|
||||||
|
kind,
|
||||||
|
component[kind],
|
||||||
|
kind == 'left_padding' and 'left' or 'right',
|
||||||
|
component[kind]
|
||||||
|
))
|
||||||
|
if component.left_padding and component.right_padding then
|
||||||
|
component.padding = { left = component.left_padding, right = component.right_padding }
|
||||||
|
component.left_padding = nil
|
||||||
|
component.right_padding = nil
|
||||||
|
elseif component.left_padding then
|
||||||
|
component.padding = { left = component.left_padding, right = 1 }
|
||||||
|
component.left_padding = nil
|
||||||
|
else
|
||||||
|
component.padding = { left = 1, right = component.right_padding }
|
||||||
|
component.right_padding = nil
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
if component.upper ~= nil or component.lower ~= nil then
|
||||||
|
types.case()
|
||||||
|
end
|
||||||
|
if component.left_padding ~= nil or component.right_padding ~= nil then
|
||||||
|
types.padding()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function load_sections(sections, options)
|
local function load_sections(sections, options)
|
||||||
for section_name, section in pairs(sections) do
|
for section_name, section in pairs(sections) do
|
||||||
for index, component in pairs(section) do
|
for index, component in pairs(section) do
|
||||||
|
@ -81,6 +165,7 @@ local function load_sections(sections, options)
|
||||||
component.self.section = section_name
|
component.self.section = section_name
|
||||||
-- apply default args
|
-- apply default args
|
||||||
component = vim.tbl_extend('keep', component, options)
|
component = vim.tbl_extend('keep', component, options)
|
||||||
|
option_deprecatation_notice(component)
|
||||||
section[index] = component_loader(component)
|
section[index] = component_loader(component)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
-- To provide notices for user
|
-- To provide notices for user
|
||||||
local M = {}
|
local M = {}
|
||||||
local notices = {}
|
local notices = {}
|
||||||
|
local persistent_notices = {}
|
||||||
|
|
||||||
function M.add_notice(notice)
|
function M.add_notice(notice)
|
||||||
if type(notice) == 'string' then
|
if type(notice) == 'string' then
|
||||||
|
@ -9,8 +10,17 @@ function M.add_notice(notice)
|
||||||
table.insert(notices, notice)
|
table.insert(notices, notice)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.add_persistent_notice(notice)
|
||||||
|
if type(notice) == 'string' then
|
||||||
|
notice = vim.split(notice, '\n')
|
||||||
|
end
|
||||||
|
if not vim.tbl_contains(persistent_notices, notice) then
|
||||||
|
table.insert(persistent_notices, notice)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function M.notice_message_startup()
|
function M.notice_message_startup()
|
||||||
if #notices > 0 then
|
if #notices > 0 or #persistent_notices then
|
||||||
vim.cmd 'command! -nargs=0 LualineNotices lua require"lualine.utils.notices".show_notices()'
|
vim.cmd 'command! -nargs=0 LualineNotices lua require"lualine.utils.notices".show_notices()'
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
vim.notify(
|
vim.notify(
|
||||||
|
@ -35,7 +45,8 @@ function M.show_notices()
|
||||||
vim.cmd 'normal q'
|
vim.cmd 'normal q'
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local notice = vim.tbl_flatten(notices)
|
local notice = vim.tbl_flatten(persistent_notices)
|
||||||
|
notice = vim.list_extend(notice, vim.tbl_flatten(notices))
|
||||||
vim.fn.append(0, notice)
|
vim.fn.append(0, notice)
|
||||||
vim.api.nvim_win_set_cursor(0, { 1, 0 })
|
vim.api.nvim_win_set_cursor(0, { 1, 0 })
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,12 +34,12 @@ function M.draw_section(section, section_name, is_focused)
|
||||||
if section_name < 'c' then
|
if section_name < 'c' then
|
||||||
if
|
if
|
||||||
type(section[first_component_no].options.separator) ~= 'table'
|
type(section[first_component_no].options.separator) ~= 'table'
|
||||||
and section[1].options.section_separators[1] ~= ''
|
and (section[1].options.section_separators.left ~= nil and section[1].options.section_separators.left ~= '')
|
||||||
then
|
then
|
||||||
status[component_no] = string.format(
|
status[component_no] = string.format(
|
||||||
'%s%%S{%s}',
|
'%s%%S{%s}',
|
||||||
status[component_no],
|
status[component_no],
|
||||||
section[1].options.section_separators[1]
|
section[1].options.section_separators.left
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -68,11 +68,11 @@ function M.draw_section(section, section_name, is_focused)
|
||||||
section_name > 'x'
|
section_name > 'x'
|
||||||
and section[first_component_no]
|
and section[first_component_no]
|
||||||
and type(section[first_component_no].options.separator) ~= 'table'
|
and type(section[first_component_no].options.separator) ~= 'table'
|
||||||
and section[1].options.section_separators[2] ~= ''
|
and (section[1].options.section_separators.right ~= nil and section[1].options.section_separators.right ~= '')
|
||||||
then
|
then
|
||||||
left_sparator_string = string.format(
|
left_sparator_string = string.format(
|
||||||
'%%s{%s}',
|
'%%s{%s}',
|
||||||
section[first_component_no].options.ls_separator or section[1].options.section_separators[2]
|
section[first_component_no].options.ls_separator or section[1].options.section_separators.right
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -41,10 +41,10 @@ M.build_component_opts = function(opts)
|
||||||
opts.icons_enabled = true
|
opts.icons_enabled = true
|
||||||
end
|
end
|
||||||
if not opts.component_separators then
|
if not opts.component_separators then
|
||||||
opts.component_separators = { '', '' }
|
opts.component_separators = { left = '', right = '' }
|
||||||
end
|
end
|
||||||
if not opts.section_separators then
|
if not opts.section_separators then
|
||||||
opts.section_separators = { '', '' }
|
opts.section_separators = { left = '', right = '' }
|
||||||
end
|
end
|
||||||
return opts
|
return opts
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,7 +54,7 @@ describe('Component:', function()
|
||||||
|
|
||||||
it('can draw', function()
|
it('can draw', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
}
|
}
|
||||||
assert_component(nil, opts, 'test')
|
assert_component(nil, opts, 'test')
|
||||||
|
@ -89,7 +89,7 @@ describe('Component:', function()
|
||||||
describe('Global options:', function()
|
describe('Global options:', function()
|
||||||
it('upper', function()
|
it('upper', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
upper = true,
|
upper = true,
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ describe('Component:', function()
|
||||||
function()
|
function()
|
||||||
return 'TeSt'
|
return 'TeSt'
|
||||||
end,
|
end,
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
lower = true,
|
lower = true,
|
||||||
}
|
}
|
||||||
|
@ -110,25 +110,23 @@ describe('Component:', function()
|
||||||
|
|
||||||
it('left_padding', function()
|
it('left_padding', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = { left = 5 },
|
||||||
left_padding = 5,
|
|
||||||
}
|
}
|
||||||
assert_component(nil, opts, ' test')
|
assert_component(nil, opts, ' test')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('right_padding', function()
|
it('right_padding', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = { right = 5 },
|
||||||
right_padding = 5,
|
|
||||||
}
|
}
|
||||||
assert_component(nil, opts, 'test ')
|
assert_component(nil, opts, 'test ')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('padding', function()
|
it('padding', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 5,
|
padding = 5,
|
||||||
}
|
}
|
||||||
assert_component(nil, opts, ' test ')
|
assert_component(nil, opts, ' test ')
|
||||||
|
@ -136,7 +134,7 @@ describe('Component:', function()
|
||||||
|
|
||||||
it('icon', function()
|
it('icon', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
icon = '0',
|
icon = '0',
|
||||||
}
|
}
|
||||||
|
@ -145,14 +143,14 @@ describe('Component:', function()
|
||||||
|
|
||||||
it('icons_enabled', function()
|
it('icons_enabled', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
icons_enabled = true,
|
icons_enabled = true,
|
||||||
icon = '0',
|
icon = '0',
|
||||||
}
|
}
|
||||||
assert_component(nil, opts, '0 test')
|
assert_component(nil, opts, '0 test')
|
||||||
local opts2 = build_component_opts {
|
local opts2 = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
icons_enabled = false,
|
icons_enabled = false,
|
||||||
icon = '0',
|
icon = '0',
|
||||||
|
@ -162,37 +160,37 @@ describe('Component:', function()
|
||||||
|
|
||||||
it('separator', function()
|
it('separator', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
separator = '|',
|
separator = '|',
|
||||||
}
|
}
|
||||||
assert_component(nil, opts, 'test|')
|
assert_component(nil, opts, 'test|')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('format', function()
|
it('fmt', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
format = function(data)
|
fmt = function(data)
|
||||||
return data:sub(1, 1):upper() .. data:sub(2, #data)
|
return data:sub(1, 1):upper() .. data:sub(2, #data)
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
assert_component(nil, opts, 'Test')
|
assert_component(nil, opts, 'Test')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('condition', function()
|
it('cond', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
condition = function()
|
cond = function()
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
assert_component(nil, opts, 'test')
|
assert_component(nil, opts, 'test')
|
||||||
local opts2 = build_component_opts {
|
local opts2 = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
condition = function()
|
cond = function()
|
||||||
return false
|
return false
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
@ -201,7 +199,7 @@ describe('Component:', function()
|
||||||
|
|
||||||
it('color', function()
|
it('color', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
color = 'MyHl',
|
color = 'MyHl',
|
||||||
}
|
}
|
||||||
|
@ -209,7 +207,7 @@ describe('Component:', function()
|
||||||
local custom_link_hl_name = 'lualine_' .. comp.options.component_name .. '_no_mode'
|
local custom_link_hl_name = 'lualine_' .. comp.options.component_name .. '_no_mode'
|
||||||
eq('%#' .. custom_link_hl_name .. '#test', comp:draw(opts.hl))
|
eq('%#' .. custom_link_hl_name .. '#test', comp:draw(opts.hl))
|
||||||
local opts2 = build_component_opts {
|
local opts2 = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
color = { bg = '#230055', fg = '#223344' },
|
color = { bg = '#230055', fg = '#223344' },
|
||||||
}
|
}
|
||||||
|
@ -227,7 +225,7 @@ end)
|
||||||
describe('Encoding component', function()
|
describe('Encoding component', function()
|
||||||
it('works', function()
|
it('works', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
}
|
}
|
||||||
assert_component('encoding', opts, '%{strlen(&fenc)?&fenc:&enc}')
|
assert_component('encoding', opts, '%{strlen(&fenc)?&fenc:&enc}')
|
||||||
|
@ -237,7 +235,7 @@ end)
|
||||||
describe('Fileformat component', function()
|
describe('Fileformat component', function()
|
||||||
it('works with icons', function()
|
it('works with icons', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
}
|
}
|
||||||
local fmt = vim.bo.fileformat
|
local fmt = vim.bo.fileformat
|
||||||
|
@ -251,7 +249,7 @@ describe('Fileformat component', function()
|
||||||
end)
|
end)
|
||||||
it('works without icons', function()
|
it('works without icons', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
icons_enabled = false,
|
icons_enabled = false,
|
||||||
}
|
}
|
||||||
|
@ -273,7 +271,7 @@ describe('Filetype component', function()
|
||||||
|
|
||||||
it('does not add icon when library unavailable', function()
|
it('does not add icon when library unavailable', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
}
|
}
|
||||||
assert_component('filetype', opts, 'lua')
|
assert_component('filetype', opts, 'lua')
|
||||||
|
@ -294,10 +292,10 @@ describe('Filetype component', function()
|
||||||
utils.extract_highlight_colors.returns '#000'
|
utils.extract_highlight_colors.returns '#000'
|
||||||
|
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
colored = true,
|
colored = true,
|
||||||
disable_text = false,
|
icon_only = false,
|
||||||
}
|
}
|
||||||
assert_component('filetype', opts, '%#MyCompHl_normal#*%#lualine_c_normal# lua')
|
assert_component('filetype', opts, '%#MyCompHl_normal#*%#lualine_c_normal# lua')
|
||||||
assert.stub(utils.extract_highlight_colors).was_called_with('test_highlight_group', 'fg')
|
assert.stub(utils.extract_highlight_colors).was_called_with('test_highlight_group', 'fg')
|
||||||
|
@ -320,7 +318,7 @@ describe('Filetype component', function()
|
||||||
hl.create_component_highlight_group.returns 'MyCompHl'
|
hl.create_component_highlight_group.returns 'MyCompHl'
|
||||||
utils.extract_highlight_colors.returns '#000'
|
utils.extract_highlight_colors.returns '#000'
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
colored = false,
|
colored = false,
|
||||||
}
|
}
|
||||||
|
@ -330,7 +328,7 @@ describe('Filetype component', function()
|
||||||
package.loaded['nvim-web-devicons'] = nil
|
package.loaded['nvim-web-devicons'] = nil
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('displays only icon when disable_text is true', function()
|
it('displays only icon when icon_only is true', function()
|
||||||
package.loaded['nvim-web-devicons'] = {
|
package.loaded['nvim-web-devicons'] = {
|
||||||
get_icon = function()
|
get_icon = function()
|
||||||
return '*', 'test_highlight_group'
|
return '*', 'test_highlight_group'
|
||||||
|
@ -338,10 +336,10 @@ describe('Filetype component', function()
|
||||||
}
|
}
|
||||||
|
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
colored = false,
|
colored = false,
|
||||||
disable_text = true,
|
icon_only = true,
|
||||||
}
|
}
|
||||||
assert_component('filetype', opts, '*')
|
assert_component('filetype', opts, '*')
|
||||||
package.loaded['nvim-web-devicons'] = nil
|
package.loaded['nvim-web-devicons'] = nil
|
||||||
|
@ -353,7 +351,7 @@ describe('Hostname component', function()
|
||||||
stub(vim.loop, 'os_gethostname')
|
stub(vim.loop, 'os_gethostname')
|
||||||
vim.loop.os_gethostname.returns 'localhost'
|
vim.loop.os_gethostname.returns 'localhost'
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
}
|
}
|
||||||
assert_component('hostname', opts, 'localhost')
|
assert_component('hostname', opts, 'localhost')
|
||||||
|
@ -364,7 +362,7 @@ end)
|
||||||
describe('Location component', function()
|
describe('Location component', function()
|
||||||
it('works', function()
|
it('works', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
}
|
}
|
||||||
assert_component('location', opts, '%3l:%-2c')
|
assert_component('location', opts, '%3l:%-2c')
|
||||||
|
@ -374,7 +372,7 @@ end)
|
||||||
describe('Progress component', function()
|
describe('Progress component', function()
|
||||||
it('works', function()
|
it('works', function()
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
}
|
}
|
||||||
assert_component('progress', opts, '%3P')
|
assert_component('progress', opts, '%3P')
|
||||||
|
@ -386,7 +384,7 @@ describe('Mode component', function()
|
||||||
stub(vim.api, 'nvim_get_mode')
|
stub(vim.api, 'nvim_get_mode')
|
||||||
vim.api.nvim_get_mode.returns { mode = 'n', blocking = false }
|
vim.api.nvim_get_mode.returns { mode = 'n', blocking = false }
|
||||||
local opts = build_component_opts {
|
local opts = build_component_opts {
|
||||||
component_separators = { '', '' },
|
component_separators = { left = '', right = '' },
|
||||||
padding = 0,
|
padding = 0,
|
||||||
}
|
}
|
||||||
assert_component('mode', opts, 'NORMAL')
|
assert_component('mode', opts, 'NORMAL')
|
||||||
|
|
|
@ -34,19 +34,19 @@ describe('config parsing', function()
|
||||||
describe('separators', function()
|
describe('separators', function()
|
||||||
it('default', function()
|
it('default', function()
|
||||||
local config = config_module.apply_configuration {}
|
local config = config_module.apply_configuration {}
|
||||||
eq(config.options.component_separators, { '', '' })
|
eq(config.options.component_separators, { left = '', right = '' })
|
||||||
eq(config.options.section_separators, { '', '' })
|
eq(config.options.section_separators, { left = '', right = '' })
|
||||||
end)
|
end)
|
||||||
it('double separators', function()
|
it('double separators', function()
|
||||||
local config = {
|
local config = {
|
||||||
options = {
|
options = {
|
||||||
component_separators = { 'a', 'b' },
|
component_separators = { left = 'a', right = 'b' },
|
||||||
section_separators = { 'c', 'd' },
|
section_separators = { left = 'c', right = 'd' },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
config = config_module.apply_configuration(config)
|
config = config_module.apply_configuration(config)
|
||||||
eq(config.options.component_separators, { 'a', 'b' })
|
eq(config.options.component_separators, { left = 'a', right = 'b' })
|
||||||
eq(config.options.section_separators, { 'c', 'd' })
|
eq(config.options.section_separators, { left = 'c', right = 'd' })
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('single separator', function()
|
describe('single separator', function()
|
||||||
|
@ -55,16 +55,16 @@ describe('config parsing', function()
|
||||||
options = { component_separators = 'a', section_separators = 'b' },
|
options = { component_separators = 'a', section_separators = 'b' },
|
||||||
}
|
}
|
||||||
config = config_module.apply_configuration(config)
|
config = config_module.apply_configuration(config)
|
||||||
eq(config.options.component_separators, { 'a', 'a' })
|
eq(config.options.component_separators, { left = 'a', right = 'a' })
|
||||||
eq(config.options.section_separators, { 'b', 'b' })
|
eq(config.options.section_separators, { left = 'b', right = 'b' })
|
||||||
end)
|
end)
|
||||||
it('table', function()
|
it('table', function()
|
||||||
local config = {
|
local config = {
|
||||||
options = { component_separators = { 'a' }, section_separators = { 'b' } },
|
options = { component_separators = { 'a' }, section_separators = { 'b' } },
|
||||||
}
|
}
|
||||||
config = config_module.apply_configuration(config)
|
config = config_module.apply_configuration(config)
|
||||||
eq(config.options.component_separators, { 'a', 'a' })
|
eq(config.options.component_separators, { left = 'a', right = 'a' })
|
||||||
eq(config.options.section_separators, { 'b', 'b' })
|
eq(config.options.section_separators, { left = 'b', right = 'b' })
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
it('no seprarators', function()
|
it('no seprarators', function()
|
||||||
|
|
|
@ -54,7 +54,7 @@ end)
|
||||||
describe('Section genarator', function()
|
describe('Section genarator', function()
|
||||||
local sec = require 'lualine.utils.section'
|
local sec = require 'lualine.utils.section'
|
||||||
it('can draw', function()
|
it('can draw', function()
|
||||||
local opts = build_component_opts { section_separators = { '', '' } }
|
local opts = build_component_opts { section_separators = { left = '', right = '' } }
|
||||||
local section = {
|
local section = {
|
||||||
require('lualine.components.special.function_component'):new(opts),
|
require('lualine.components.special.function_component'):new(opts),
|
||||||
require('lualine.components.special.function_component'):new(opts),
|
require('lualine.components.special.function_component'):new(opts),
|
||||||
|
@ -63,15 +63,15 @@ describe('Section genarator', function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('can remove separators from component with custom colors', function()
|
it('can remove separators from component with custom colors', function()
|
||||||
local opts = build_component_opts { section_separators = { '', '' } }
|
local opts = build_component_opts { section_separators = { left = '', right = '' } }
|
||||||
local opts_colored = build_component_opts { color = 'MyColor' }
|
local opts_colored = build_component_opts { color = 'MyColor' }
|
||||||
local opts_colored2 = build_component_opts {
|
local opts_colored2 = build_component_opts {
|
||||||
color = { bg = '#223344' },
|
color = { bg = '#223344' },
|
||||||
section_separators = { '', '' },
|
section_separators = { left = '', right = '' },
|
||||||
}
|
}
|
||||||
local opts_colored3 = build_component_opts {
|
local opts_colored3 = build_component_opts {
|
||||||
color = { fg = '#223344' },
|
color = { fg = '#223344' },
|
||||||
section_separators = { '', '' },
|
section_separators = { left = '', right = '' },
|
||||||
}
|
}
|
||||||
require('lualine.highlight').create_highlight_groups(require 'lualine.themes.gruvbox')
|
require('lualine.highlight').create_highlight_groups(require 'lualine.themes.gruvbox')
|
||||||
local section = {
|
local section = {
|
||||||
|
|
Loading…
Reference in New Issue