nvim: tweak trailing whitespace counter in lualine
This commit is contained in:
parent
f23a73d02b
commit
50117b8d09
2 changed files with 13 additions and 14 deletions
|
@ -23,16 +23,16 @@ return {
|
||||||
local spell = "fschauen.spell"
|
local spell = "fschauen.spell"
|
||||||
local status =
|
local status =
|
||||||
{ dynamic_color("fschauen.status"), color = { fg = orange }, padding = 0 }
|
{ 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 wrap = "fschauen.wrap"
|
||||||
|
|
||||||
local sections = {
|
local sections = {
|
||||||
lualine_a = { mode },
|
lualine_a = { mode },
|
||||||
lualine_b = { branch },
|
lualine_b = { branch },
|
||||||
lualine_c = { filename, status },
|
lualine_c = { filename, status },
|
||||||
lualine_x = { diagnostics, searchcount, filetype },
|
lualine_x = { diagnostics, searchcount, whitespace, filetype },
|
||||||
lualine_y = { spell, wrap, autoformat, fileformat, "progress" },
|
lualine_y = { spell, wrap, autoformat, fileformat, "progress" },
|
||||||
lualine_z = { "location", whitespace },
|
lualine_z = { "location" },
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -4,23 +4,22 @@ function M:init(options)
|
||||||
M.super.init(
|
M.super.init(
|
||||||
self,
|
self,
|
||||||
vim.tbl_deep_extend("keep", options or {}, {
|
vim.tbl_deep_extend("keep", options or {}, {
|
||||||
color = { bg = "#d65d0e" },
|
color = { fg = "#d65d0e" },
|
||||||
cond = function() return vim.bo.filetype ~= "help" end,
|
cond = function() return vim.bo.filetype ~= "help" end,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
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]]_)
|
function M:update_status(--[[is_focused]]_)
|
||||||
local trailing = [[\s\+$]]
|
local lineno = vim.fn.search(TRAILING_WS_PATTERN, "nwc")
|
||||||
local lineno = vim.fn.search(trailing, "nwc")
|
return lineno > 0 and string.format(" %d%s", lineno, total()) or ""
|
||||||
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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Add table
Reference in a new issue