Remove deprecated feature: string color option bering treated as fg

This commit is contained in:
shadmansaleh 2021-08-09 14:12:39 +06:00 committed by Shadman
parent 85545bd192
commit ba1efb2a00
2 changed files with 0 additions and 84 deletions

View File

@ -18,34 +18,6 @@ Diagnostics.default_colors = {
} }
-- LuaFormatter on -- LuaFormatter on
local function color_deprecation_notice(color, opt_name)
modules.utils_notices.add_notice(string.format([[
### Diagnostics component
Using option `%s` as string to set foreground color has been deprecated
and will soon be removed. Now this option has same semantics as regular
`color` option for components. Means now you can set bg/fg or both.
String value is still valid but it's interpreted differemtly. When a
string is used for this option it's treated as a highlight group name.
In that case `%s` will be linked to that highlight group.
You have something like this in your config.
```lua
{'diagnostics',
%s = '%s',
}
```
You'll have to change it to this to retain previous behavior
```lua
{'diagnostics',
%s = { fg = '%s'},
}
```
]], opt_name, opt_name, opt_name, color, opt_name, color))
end
-- Initializer -- Initializer
Diagnostics.new = function(self, options, child) 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)
@ -77,40 +49,24 @@ Diagnostics.new = function(self, options, child)
modules.utils.extract_highlight_colors('LspDiagnosticsDefaultError', 'fg') or modules.utils.extract_highlight_colors('LspDiagnosticsDefaultError', 'fg') or
modules.utils.extract_highlight_colors('DiffDelete', 'fg') or modules.utils.extract_highlight_colors('DiffDelete', 'fg') or
Diagnostics.default_colors.error } Diagnostics.default_colors.error }
elseif type(new_diagnostics.options.color_error) == 'string'
and vim.fn.hlexists(new_diagnostics.options.color_error) == 0 then
new_diagnostics.options.color_error = {fg = new_diagnostics.options.color_error}
color_deprecation_notice(new_diagnostics.options.color_error.fg, 'color_error')
end end
if not new_diagnostics.options.color_warn then if not new_diagnostics.options.color_warn then
new_diagnostics.options.color_warn = {fg = new_diagnostics.options.color_warn = {fg =
modules.utils.extract_highlight_colors('LspDiagnosticsDefaultWarning', 'fg') or modules.utils.extract_highlight_colors('LspDiagnosticsDefaultWarning', 'fg') or
modules.utils.extract_highlight_colors('DiffText', 'fg') or modules.utils.extract_highlight_colors('DiffText', 'fg') or
Diagnostics.default_colors.warn } Diagnostics.default_colors.warn }
elseif type(new_diagnostics.options.color_warn) == 'string'
and vim.fn.hlexists(new_diagnostics.options.color_warn) == 0 then
new_diagnostics.options.color_warn = {fg = new_diagnostics.options.color_warn}
color_deprecation_notice(new_diagnostics.options.color_warn.fg, 'color_warn')
end end
if not new_diagnostics.options.color_info then if not new_diagnostics.options.color_info then
new_diagnostics.options.color_info = {fg = new_diagnostics.options.color_info = {fg =
modules.utils.extract_highlight_colors('LspDiagnosticsDefaultInformation', 'fg') or modules.utils.extract_highlight_colors('LspDiagnosticsDefaultInformation', 'fg') or
modules.utils.extract_highlight_colors('Normal', 'fg') or modules.utils.extract_highlight_colors('Normal', 'fg') or
Diagnostics.default_colors.info} Diagnostics.default_colors.info}
elseif type(new_diagnostics.options.color_info) == 'string'
and vim.fn.hlexists(new_diagnostics.options.color_info) == 0 then
new_diagnostics.options.color_info = {fg = new_diagnostics.options.color_info}
color_deprecation_notice(new_diagnostics.options.color_info.fg, 'color_info')
end end
if not new_diagnostics.options.color_hint then if not new_diagnostics.options.color_hint then
new_diagnostics.options.color_hint = {fg = new_diagnostics.options.color_hint = {fg =
modules.utils.extract_highlight_colors('LspDiagnosticsDefaultHint', 'fg') or modules.utils.extract_highlight_colors('LspDiagnosticsDefaultHint', 'fg') or
modules.utils.extract_highlight_colors('DiffChange', 'fg') or modules.utils.extract_highlight_colors('DiffChange', 'fg') or
Diagnostics.default_colors.hint} Diagnostics.default_colors.hint}
elseif type(new_diagnostics.options.color_hint) == 'string'
and vim.fn.hlexists(new_diagnostics.options.color_hint) == 0 then
new_diagnostics.options.color_hint = {fg = new_diagnostics.options.color_hint}
color_deprecation_notice(new_diagnostics.options.color_hint.fg, 'color_hint')
end end
if new_diagnostics.options.colored then if new_diagnostics.options.colored then

View File

@ -1,6 +1,5 @@
-- Copyright (c) 2020-2021 shadmansaleh -- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details. -- MIT license, see LICENSE for more details.
local lualine_require = require'lualine_require' local lualine_require = require'lualine_require'
local modules = lualine_require.lazy_require{ local modules = lualine_require.lazy_require{
utils = 'lualine.utils.utils', utils = 'lualine.utils.utils',
@ -27,33 +26,6 @@ Diff.default_colors = {
local diff_cache = {} -- Stores last known value of diff of a buffer local diff_cache = {} -- Stores last known value of diff of a buffer
local function color_deprecation_notice(color, opt_name)
modules.utils_notices.add_notice(string.format([[
### Diff component
Using option `%s` as string to set foreground color has been deprecated
and will soon be removed. Now this option has same semantics as regular
`color` option for components. Means now you can set bg/fg or both.
String value is still valid but it's interpreted differemtly. When a
string is used for this option it's treated as a highlight group name.
In that case `%s` will be linked to that highlight group.
You have something like this in your config.
```lua
{'diff',
%s = '%s',
}
```
You'll have to change it to this to retain previous behavior
```lua
{'diff',
%s = { fg = '%s'},
}
```
]], opt_name, opt_name, opt_name, color, opt_name, color))
end
-- 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)
@ -69,28 +41,16 @@ Diff.new = function(self, options, child)
new_instance.options.color_added = {fg = new_instance.options.color_added = {fg =
modules.utils.extract_highlight_colors('DiffAdd', 'fg') or modules.utils.extract_highlight_colors('DiffAdd', 'fg') or
Diff.default_colors.added} Diff.default_colors.added}
elseif type(new_instance.options.color_added) == 'string'
and vim.fn.hlexists(new_instance.options.color_added) == 0 then
new_instance.options.color_added = {fg = new_instance.options.color_added}
color_deprecation_notice(new_instance.options.color_added.fg, 'color_added')
end end
if not new_instance.options.color_modified then if not new_instance.options.color_modified then
new_instance.options.color_modified = {fg = new_instance.options.color_modified = {fg =
modules.utils.extract_highlight_colors('DiffChange', 'fg') or modules.utils.extract_highlight_colors('DiffChange', 'fg') or
Diff.default_colors.modified} Diff.default_colors.modified}
elseif type(new_instance.options.color_modified) == 'string'
and vim.fn.hlexists(new_instance.options.color_modified) == 0 then
new_instance.options.color_modified = {fg = new_instance.options.color_modified}
color_deprecation_notice(new_instance.options.color_modified.fg, 'color_modified')
end end
if not new_instance.options.color_removed then if not new_instance.options.color_removed then
new_instance.options.color_removed = {fg = new_instance.options.color_removed = {fg =
modules.utils.extract_highlight_colors('DiffDelete', 'fg') or modules.utils.extract_highlight_colors('DiffDelete', 'fg') or
Diff.default_colors.removed} Diff.default_colors.removed}
elseif type(new_instance.options.color_removed) == 'string'
and vim.fn.hlexists(new_instance.options.color_removed) == 0 then
new_instance.options.color_removed = {fg = new_instance.options.color_removed}
color_deprecation_notice(new_instance.options.color_removed.fg, 'color_removed')
end end
-- create highlights and save highlight_name in highlights table -- create highlights and save highlight_name in highlights table