diff --git a/lua/feline/defaults.lua b/lua/feline/defaults.lua index b6e5156..794c945 100644 --- a/lua/feline/defaults.lua +++ b/lua/feline/defaults.lua @@ -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', diff --git a/lua/feline/generator.lua b/lua/feline/generator.lua index 88c812e..93779cd 100644 --- a/lua/feline/generator.lua +++ b/lua/feline/generator.lua @@ -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 @@ -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 @@ -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' diff --git a/lua/feline/init.lua b/lua/feline/init.lua index 7f40b45..db83f1b 100644 --- a/lua/feline/init.lua +++ b/lua/feline/init.lua @@ -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' } @@ -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( @@ -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 @@ -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 diff --git a/lua/feline/presets/default.lua b/lua/feline/presets/default.lua index c839a21..566b8a5 100644 --- a/lua/feline/presets/default.lua +++ b/lua/feline/presets/default.lua @@ -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 = {} diff --git a/lua/feline/presets/noicon.lua b/lua/feline/presets/noicon.lua index 47a2135..404823f 100644 --- a/lua/feline/presets/noicon.lua +++ b/lua/feline/presets/noicon.lua @@ -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 = {}