Skip to content

Commit

Permalink
refactor!: deprecate default_fg and default_bg
Browse files Browse the repository at this point in the history
  • Loading branch information
famiu committed Sep 11, 2021
1 parent 8d14059 commit d204113
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,12 @@ NOTE: This is also the configuration used by default if you don't have `nvim-web
You can also make minor tweaks like changing the default foreground and background color like this:

```lua
require('feline').setup({
default_fg = '#D0D0D0',
default_bg = '#1F1F23'
})
require('feline').setup {
colors = {
fg = '#D0D0D0',
bg = '#1F1F23'
}
}
```

### 2. Building your own statusline.
Expand Down Expand Up @@ -538,8 +540,6 @@ And that's it, that's how you set up the properties table
Now that we've learned to set up both the components table and the properties table, it's finally time to revisit the setup function. The setup function takes a table that can have the following values:

- `preset` - Set it to use a preconfigured statusline. Currently it can be equal to either `default` for the default statusline or `noicon` for the default statusline without icons. You don't have to put any of the other values if you use a preset, but if you do, your settings will override the preset's settings. To see more info such as how to modify a preset to build a statusline, see: [Modifying an existing preset](#3.-modifying-an-existing-preset)
- `default_fg` - [Name](#value-presets) or RGB hex code of default foreground color.
- `default_bg` - [Name](#value-presets) or RGB hex code of default background color.
- `colors` - A table containing custom [color value presets](#value-presets).
- `separators` - A table containing custom [separator value presets](#value-presets).
- `components` - The components table.
Expand Down Expand Up @@ -768,6 +768,8 @@ components.inactive[1] = {

-- This table is equal to the default colors table
local colors = {
fg = '#D0D0D0',
bg = '#1F1F23',
black = '#1B1B1B',
skyblue = '#50B0F0',
cyan = '#009090',
Expand Down Expand Up @@ -824,8 +826,6 @@ local vi_mode_colors = {
}

require('feline').setup({
default_bg = '#1F1F23',
default_fg = '#D0D0D0',
colors = colors,
separators = separators,
components = components,
Expand Down
28 changes: 21 additions & 7 deletions lua/feline/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,26 @@ function M.setup(config)
local preset, components, properties
local custom_colors, custom_separators, vi_mode_colors

-- Deprecation warning for `default_fg` and `default_bg`
if config.default_fg or config.default_bg then
api.nvim_echo(
{{
'\nDeprecation warning:\n' ..
'The setup options `default_fg` and `default_bg` for Feline have been ' ..
'removed and no longer work. Please use the `fg` and `bg` values ' ..
'of the `colors` table instead.\n',

'WarningMsg'
}},
true, {}
)
end

if parse_config(config, 'preset', 'string') then
preset = presets[config.preset]
else
local has_devicons = pcall(require,'nvim-web-devicons')

if has_devicons then
preset = presets['default']
else
Expand All @@ -76,8 +92,6 @@ function M.setup(config)
for color, hex in pairs(custom_colors) do colors[color] = hex end
for name, str in pairs(custom_separators) do separators[name] = str end

colors.fg = parse_config(config, 'default_fg', 'string', colors.fg)
colors.bg = parse_config(config, 'default_bg', 'string', colors.bg)
vi_mode_colors = parse_config(config, 'vi_mode_colors', 'table', {})
components = parse_config(config, 'components', 'table', preset.components)
properties = parse_config(config, 'properties', 'table', preset.properties)
Expand All @@ -91,12 +105,12 @@ function M.setup(config)
if not (components.active and components.inactive) then
api.nvim_echo(
{{
"\nDeprecation warning:\n" ..
"This format for defining Feline components has been deprecated and will soon " ..
"become unsupported. Please check the docs and switch your statusline " ..
"configuration to the new format as soon as possible.\n",
'\nDeprecation warning:\n' ..
'This format for defining Feline components has been deprecated and will soon ' ..
'become unsupported. Please check the docs and switch your statusline ' ..
'configuration to the new format as soon as possible.\n',

"WarningMsg"
'WarningMsg'
}},
true, {}
)
Expand Down

0 comments on commit d204113

Please sign in to comment.