summaryrefslogtreecommitdiff
path: root/pkgs/custom-neovim/config/lua
diff options
context:
space:
mode:
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