From cdd3b5024888215e5c25a208c2a26306e6016d72 Mon Sep 17 00:00:00 2001 From: David JULIEN Date: Mon, 13 Feb 2023 09:49:14 +0100 Subject: [PATCH] [nvim] fix: shorten filenames in unfocused buffers 786d119 shortened the filename for the current buffer, but didn't change the filename in other buffers --- .config/nvim/lua/statusline.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.config/nvim/lua/statusline.lua b/.config/nvim/lua/statusline.lua index b864704..a383585 100644 --- a/.config/nvim/lua/statusline.lua +++ b/.config/nvim/lua/statusline.lua @@ -215,8 +215,14 @@ local function statusline_focused() end local function statusline_not_focused() + local bufnr = vim.fn.winbufnr(vim.g.statusline_winid) + local file = vim.fn.expand("#" .. bufnr .. ":p:~") + local winwidth = vim.fn.winwidth(0) return table.concat { - gen_section("%#StatuslineNF#", { "%f", "%m" }), + gen_section("%#StatuslineNF#", { + shorten_path(file, winwidth / 3), + "%m" + }), "%=", gen_section("%#StatuslineNF#", { "%03.p%%" }), gen_section("%#StatuslineNF#", { "-%03.c-" })