added statusline

This commit is contained in:
2026-03-29 13:13:00 +02:00
parent a4007a1c34
commit 8b3c1acbd3
3 changed files with 55 additions and 5 deletions

View File

@@ -0,0 +1,49 @@
local M = {}
local function progress_bar()
local columns = vim.o.columns
local total_lines = vim.fn.line("$")
local current_line = vim.fn.line(".")
local current_col = vim.fn.virtcol(".")
local bar_width = math.max(columns - 65, 3)
local progress
if total_lines > 1 then
progress = math.floor((current_line - 1) * (bar_width - 1) / (total_lines - 1))
else
progress = math.floor(bar_width / 2)
end
local pad = #tostring(total_lines) - #tostring(current_line) + 3
- #tostring(current_col) + 3
- #tostring(math.floor(current_line * 100 / math.max(total_lines, 1)))
return string.rep(" ", math.max(pad, 0))
.. " ["
.. "%#DiffAdd#"
.. string.rep("-", progress)
.. "%#DiffDelete#0%#DiffAdd#"
.. string.rep("-", math.max(bar_width - progress - 1, 0))
.. "%*]"
end
function M.render()
local encoding = vim.bo.fenc ~= "" and vim.bo.fenc or vim.o.enc
local bomb = vim.bo.bomb and ",B" or ""
return table.concat({
"%f",
" [",
encoding,
bomb,
"%M%R%H%W] ",
"%y",
" [%l/%L,%v] [%p%%]",
progress_bar(),
})
end
vim.o.statusline = "%!v:lua.require'tracer.statusline'.render()"
return M