nvim: statusline: Make winbar status be relative to current directory

We want file path being shown in winbar to be relative to the current
directory or in our case frequently the git root. For whatever reason,
only the first opened leftmost split would show the file path relative
to current git root while any files opened later would show the full
path starting from `HOME`/~ directory. So something around how '%f%m%r'
actually works or how it is being used to set winbar has been a problem.
This commit is contained in:
Sanchayan Maity 2024-04-11 21:58:43 +05:30
parent f27f6629de
commit cd50d8f956
Signed by: sanchayanmaity
GPG key ID: 6F6A0609C12038F3

View file

@ -294,7 +294,10 @@ api.nvim_create_autocmd({"BufWinEnter", "BufFilePost"}, {
return
end
vim.opt_local.winbar = string.format(" %s%s", "%#WinbarFile#", '%f%m%r')
-- `:.` Reduces file name to be relative to current directory, if possible.
local winbar_file = vim.fn.expand('%:.')
vim.opt_local.winbar = string.format(" %s%s", "%#WinbarFile#", winbar_file)
end,
})
api.nvim_create_autocmd({"TermOpen", "TermEnter"}, {