diff --git a/config/nvim/lua/fschauen/plugins/lualine.lua b/config/nvim/lua/fschauen/plugins/lualine.lua index 2923fab..342373c 100644 --- a/config/nvim/lua/fschauen/plugins/lualine.lua +++ b/config/nvim/lua/fschauen/plugins/lualine.lua @@ -23,16 +23,16 @@ return { local spell = "fschauen.spell" local status = { dynamic_color("fschauen.status"), color = { fg = orange }, padding = 0 } - local whitespace = { dynamic_color("fschauen.whitespace"), color = { bg = orange } } + local whitespace = { dynamic_color("fschauen.whitespace"), cond = window.is_wide } local wrap = "fschauen.wrap" local sections = { lualine_a = { mode }, lualine_b = { branch }, lualine_c = { filename, status }, - lualine_x = { diagnostics, searchcount, filetype }, + lualine_x = { diagnostics, searchcount, whitespace, filetype }, lualine_y = { spell, wrap, autoformat, fileformat, "progress" }, - lualine_z = { "location", whitespace }, + lualine_z = { "location" }, } return { diff --git a/config/nvim/lua/lualine/components/fschauen/whitespace.lua b/config/nvim/lua/lualine/components/fschauen/whitespace.lua index 9d0c5bb..671cd0a 100644 --- a/config/nvim/lua/lualine/components/fschauen/whitespace.lua +++ b/config/nvim/lua/lualine/components/fschauen/whitespace.lua @@ -4,23 +4,22 @@ function M:init(options) M.super.init( self, vim.tbl_deep_extend("keep", options or {}, { - color = { bg = "#d65d0e" }, + color = { fg = "#d65d0e" }, cond = function() return vim.bo.filetype ~= "help" end, }) ) end +local TRAILING_WS_PATTERN = [[\s\+$]] + +local total = function() + local count = vim.fn.searchcount({ pattern = TRAILING_WS_PATTERN }).total + return count > 1 and string.format("·%d", count) or "" +end + function M:update_status(--[[is_focused]]_) - local trailing = [[\s\+$]] - local lineno = vim.fn.search(trailing, "nwc") - if lineno == 0 then return "" end - - local result = " " .. lineno - - local total = vim.fn.searchcount({ pattern = trailing }).total - if total > 1 then result = result .. string.format(" (%d total)", total) end - - return result + local lineno = vim.fn.search(TRAILING_WS_PATTERN, "nwc") + return lineno > 0 and string.format("󰢤 %d%s", lineno, total()) or "" end return M