Revert "Fix #14: better active window detection"
This reverts commit 680cfeb074.
This commit is contained in:
@@ -98,9 +98,9 @@ local function remove_hidden_sections(sections)
|
||||
end
|
||||
|
||||
-------------------- SECTION HIGHLIGHTING ------------------
|
||||
local function get_section_state(section, active)
|
||||
local function get_section_state(section)
|
||||
if section.class == 'mode' then
|
||||
if active then
|
||||
if common.is_active() then
|
||||
local mode = common.modes[fn.mode()] or common.modes['?']
|
||||
return mode.state
|
||||
end
|
||||
@@ -115,35 +115,40 @@ local function get_section_state(section, active)
|
||||
end
|
||||
return state
|
||||
end
|
||||
return active and 'active' or 'inactive'
|
||||
return common.is_active() and 'active' or 'inactive'
|
||||
end
|
||||
|
||||
local function highlight_sections(sections, active)
|
||||
local highlight_section = function(section)
|
||||
if type(section) ~= 'table' then
|
||||
return section
|
||||
end
|
||||
if section.class == 'none' then
|
||||
return section.item
|
||||
end
|
||||
local state = get_section_state(section, active)
|
||||
local hlgroup = fmt('Hardline_%s_%s', section.class, state)
|
||||
if fn.hlexists(hlgroup) == 0 then
|
||||
return section.item
|
||||
end
|
||||
return fmt('%%#%s#%s%%*', hlgroup, section.item)
|
||||
local function highlight_section(section)
|
||||
if type(section) ~= 'table' then
|
||||
return section
|
||||
end
|
||||
if section.class == 'none' then
|
||||
return section.item
|
||||
end
|
||||
local state = get_section_state(section)
|
||||
local hlgroup = fmt('Hardline_%s_%s', section.class, state)
|
||||
if fn.hlexists(hlgroup) == 0 then
|
||||
return section.item
|
||||
end
|
||||
return fmt('%%#%s#%s%%*', hlgroup, section.item)
|
||||
end
|
||||
|
||||
local function highlight_sections(sections)
|
||||
return vim.tbl_map(highlight_section, sections)
|
||||
end
|
||||
|
||||
-------------------- STATUSLINE ----------------------------
|
||||
function M.update_statusline(active)
|
||||
sections = M.options.sections
|
||||
sections = remove_hidden_sections(sections)
|
||||
sections = load_sections(sections)
|
||||
sections = remove_empty_sections(sections)
|
||||
sections = aggregate_sections(sections)
|
||||
return table.concat(highlight_sections(sections, active))
|
||||
function M.update_statusline()
|
||||
local sections = cache.previous
|
||||
if common.is_active() or not sections then
|
||||
sections = M.options.sections
|
||||
sections = remove_hidden_sections(sections)
|
||||
sections = load_sections(sections)
|
||||
sections = remove_empty_sections(sections)
|
||||
sections = aggregate_sections(sections)
|
||||
cache.previous, cache.current = cache.current, sections
|
||||
end
|
||||
return table.concat(highlight_sections(sections))
|
||||
end
|
||||
|
||||
-------------------- BUFFERLINE ----------------------------
|
||||
@@ -186,7 +191,8 @@ end
|
||||
|
||||
local function set_statusline()
|
||||
o.showmode = false
|
||||
o.statusline = [[%!luaeval('require("hardline").update_statusline(true)')]]
|
||||
o.statusline = [[%!luaeval('require("hardline").update_statusline()')]]
|
||||
wo.statusline = o.statusline
|
||||
end
|
||||
|
||||
local function set_bufferline()
|
||||
|
||||
Reference in New Issue
Block a user