nvim: ruler format tweaks

This commit is contained in:
Daniel Lundin 2025-01-11 23:08:35 +01:00
parent fec53f5ca0
commit cea9b407c8
Signed by: dln
SSH key fingerprint: SHA256:dQy1Xj3UiqJYpKR5ggQ2bxgz4jCH8IF+k3AB8o0kmdI

View file

@ -24,7 +24,26 @@ function GetIndicators()
return warn_string .. error_string
end
vim.opt.rulerformat = "%40(%=%{%v:lua.GetIndicators()%}%#Label#│ %t %)"
function CondensedPath()
local path = vim.fn.expand("%:p")
-- path = vim.fn.fnamemodify(path, ':p')
local home = os.getenv("HOME")
if home then
path = vim.fn.substitute(path, '^' .. home, '~', '')
end
local segments = vim.fn.split(path, '/')
if #segments <= 3 then
return path
end
local early_path = table.concat(vim.list_slice(segments, 1, #segments - 2), '/')
local late_path = table.concat(vim.list_slice(segments, #segments - 1), '/')
return vim.fn.pathshorten(early_path) .. '/' .. late_path
end
vim.opt.rulerformat = "%50(%=%{%v:lua.GetIndicators()%}%#Label#%#MsgArea#| %{%v:lua.CondensedPath()%}%)"
-- Search
vim.opt.ignorecase = true