From 05deaec00e74011955c54ffdc23d4b8715118233 Mon Sep 17 00:00:00 2001 From: Olivier Roques Date: Wed, 30 Dec 2020 20:40:40 +0100 Subject: [PATCH] Minor improvements --- lua/hardline.lua | 10 ++++------ lua/hardline/bufferline.lua | 6 +++--- lua/hardline/statusline.lua | 4 +--- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/lua/hardline.lua b/lua/hardline.lua index c04ec61..9dc8878 100644 --- a/lua/hardline.lua +++ b/lua/hardline.lua @@ -32,16 +32,14 @@ M.options = { -------------------- STATUSLINE ---------------------------- function M.update_statusline() - local sections = M.options.sections - if common.is_active() or not cache.previous then + local sections = cache.previous + if common.is_active() or not sections then + sections = M.options.sections sections = statusline.remove_hidden_sections(sections) sections = statusline.reload_sections(sections) sections = statusline.remove_empty_sections(sections) sections = statusline.aggregate_sections(sections) - cache.previous = cache.current - cache.current = sections - else - sections = cache.previous + cache.previous, cache.current = cache.current, sections end return table.concat(vim.tbl_map(common.color, sections)) end diff --git a/lua/hardline/bufferline.lua b/lua/hardline/bufferline.lua index b4a6ccb..f9a1a4d 100644 --- a/lua/hardline/bufferline.lua +++ b/lua/hardline/bufferline.lua @@ -5,9 +5,9 @@ local function exclude(bufnr) end local function get_head(path, tail) - local result = path - for i = 1, #vim.split(tail, '/', true) do - result = fn.fnamemodify(result, ':~:h') + local result = fn.fnamemodify(path, ':p') + for i = 1, #vim.split(tail, '/') do + result = fn.fnamemodify(result, ':h') end return fn.fnamemodify(result, ':t') end diff --git a/lua/hardline/statusline.lua b/lua/hardline/statusline.lua index 1f69a39..8f531a4 100644 --- a/lua/hardline/statusline.lua +++ b/lua/hardline/statusline.lua @@ -27,8 +27,7 @@ end local function remove_empty_sections(sections) local filter = function(s) - if type(s) == 'table' then return s.item ~= '' end - return s ~= '' + if type(s) == 'table' then return s.item ~= '' else return s ~= '' end end return vim.tbl_filter(filter, sections) end @@ -43,7 +42,6 @@ local function reload_sections(sections) return { class = section.class or 'none', item = map(section.item), - hide = section.hide or 0, } end common.echo('WarningMsg', 'Invalid section.')