Skip to content

Commit

Permalink
refactor!: deprecate properties table
Browse files Browse the repository at this point in the history
  • Loading branch information
famiu committed Sep 11, 2021
1 parent a870c07 commit 617a4a6
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 42 deletions.
16 changes: 16 additions & 0 deletions lua/feline/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ M.vi_mode_colors = {
['NONE'] = 'yellow'
}

M.force_inactive = {
filetypes = {
'NvimTree',
'packer',
'startify',
'fugitive',
'fugitiveblame',
'qf',
'help'
},
buftypes = {
'terminal'
},
bufnames = {}
}

M.update_triggers = {
'VimEnter',
'WinEnter',
Expand Down
8 changes: 4 additions & 4 deletions lua/feline/generator.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local bo = vim.bo
local fn = vim.fn
local cmd = vim.cmd
local api = vim.api

local feline = require('feline')
local colors = feline.colors
Expand All @@ -12,11 +12,11 @@ M.highlights = {}

-- Check if current buffer is forced to have inactive statusline
local function is_forced_inactive()
local force_inactive = feline.properties.force_inactive
local force_inactive = feline.force_inactive

local buftype = bo.buftype
local filetype = bo.filetype
local bufname = fn.bufname()
local bufname = api.nvim_buf_get_name(0)

return vim.tbl_contains(force_inactive.buftypes, buftype) or
vim.tbl_contains(force_inactive.filetypes, filetype) or
Expand Down Expand Up @@ -216,7 +216,7 @@ function M.generate_statusline(winid)

local statusline_type

if winid == vim.api.nvim_get_current_win() and not is_forced_inactive() then
if winid == api.nvim_get_current_win() and not is_forced_inactive() then
statusline_type='active'
else
statusline_type='inactive'
Expand Down
25 changes: 21 additions & 4 deletions lua/feline/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ function M.setup(config)

local defaults = require('feline.defaults')
local presets = require('feline.presets')
local preset, components, properties
local preset, components

-- Configuration options that aren't defined in a preset
-- Configuration options
local config_opts = {
'colors',
'separators',
'force_inactive',
'vi_mode_colors',
'update_triggers'
}
Expand All @@ -95,6 +96,24 @@ function M.setup(config)
end
end

if config.properties then
-- Deprecation warning for the `properties` table
api.nvim_echo(
{{
'\nDeprecation warning:\n' ..
'The `properties` table for Feline has been deprecated and support for it ' ..
'will be removed soon. Please put the `force_inactive` table directly ' ..
'inside the setup function instead',

'WarningMsg'
}},
true, {}
)

local properties = parse_config(config, 'properties', 'table', {})
M.force_inactive = properties.force_inactive
end

-- Deprecation warning for `default_fg` and `default_bg`
if config.default_fg or config.default_bg then
api.nvim_echo(
Expand Down Expand Up @@ -123,7 +142,6 @@ function M.setup(config)
end

components = parse_config(config, 'components', 'table', preset.components)
properties = parse_config(config, 'properties', 'table', preset.properties)

-- Deprecation warning for old component format
if not (components.active and components.inactive) then
Expand All @@ -141,7 +159,6 @@ function M.setup(config)
end

M.components = components
M.properties = properties

-- Ensures custom quickfix statusline isn't loaded
g.qf_disable_statusline = true
Expand Down
17 changes: 0 additions & 17 deletions lua/feline/presets/default.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,6 @@ local b = vim.b
local fn = vim.fn

local M = {
properties = {
force_inactive = {
filetypes = {
'NvimTree',
'packer',
'startify',
'fugitive',
'fugitiveblame',
'qf',
'help'
},
buftypes = {
'terminal'
},
bufnames = {}
}
},
components = {
active = {},
inactive = {}
Expand Down
17 changes: 0 additions & 17 deletions lua/feline/presets/noicon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,6 @@ local b = vim.b
local fn = vim.fn

local M = {
properties = {
force_inactive = {
filetypes = {
'NvimTree',
'packer',
'startify',
'fugitive',
'fugitiveblame',
'qf',
'help'
},
buftypes = {
'terminal'
},
bufnames = {}
}
},
components = {
active = {},
inactive = {}
Expand Down

0 comments on commit 617a4a6

Please sign in to comment.