summaryrefslogtreecommitdiff
path: root/pkgs/custom-neovim/config/lua
diff options
context:
space:
mode:
authortriethyl <triethylammonium@pm.me>2025-09-02 09:33:09 -0400
committertriethyl <triethylammonium@pm.me>2025-09-02 09:33:09 -0400
commit7a59b950b0a5433df79a32d272e91dc21ccf8697 (patch)
tree1a9a34599c0d928bb1b1c7453ab1d073dd5e7f40 /pkgs/custom-neovim/config/lua
parent8c8f05f61efb19fb88a435a41e2896a22ffa7f53 (diff)
neovim: made winbar filename self shortening
Diffstat (limited to 'pkgs/custom-neovim/config/lua')
-rw-r--r--pkgs/custom-neovim/config/lua/winbar.lua33
1 files changed, 32 insertions, 1 deletions
diff --git a/pkgs/custom-neovim/config/lua/winbar.lua b/pkgs/custom-neovim/config/lua/winbar.lua
index ba02e1c..6202065 100644
--- a/pkgs/custom-neovim/config/lua/winbar.lua
+++ b/pkgs/custom-neovim/config/lua/winbar.lua
@@ -27,7 +27,38 @@ components.filename = function (args)
local before = args.before or ""
local after = args.after or ""
- return before.."%f %m"..after
+ -- Get filename
+ local filename = vim.fn.expand("%t")
+
+ -- Shorten if too large
+ if utils.component_takes_percentage(#filename, 40) then
+ filename = vim.fn.pathshorten(filename)
+ end
+ if utils.component_takes_percentage(#filename, 80) then
+ return ""
+ end
+
+ -- Handle empty filenames
+ if filename == "" then
+ filename = "[No Name]"
+ end
+
+ -- Get modified status
+ local modified_bool = vim.bo.modified
+ local modifiable_bool = vim.bo.modifiable
+
+ local modified = ""
+
+ if modified_bool then modified = "[+]" end
+ if not modifiable_bool then modified = "[-]" end
+
+ -- append space if not empty
+ if modified ~= "" then
+ modified = " "..modified
+ end
+
+ -- Compose component
+ return before..filename..modified..after
end
-- Git status component