summaryrefslogtreecommitdiff
path: root/fnl
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2022-07-17 19:09:24 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2022-07-17 19:09:24 +0200
commit794890b6dbab3328565de0c7b37a053643f8a721 (patch)
tree3e106dced2cbbafbf52cff23811160e10314be1a /fnl
parent531de7d6d78c4c15f97c4a08c5606abcfdb7e699 (diff)
Add more advanced winbar
Diffstat (limited to 'fnl')
-rw-r--r--fnl/config/winbar.fnl45
1 files changed, 43 insertions, 2 deletions
diff --git a/fnl/config/winbar.fnl b/fnl/config/winbar.fnl
index 6b1c548..a472f19 100644
--- a/fnl/config/winbar.fnl
+++ b/fnl/config/winbar.fnl
@@ -1,4 +1,45 @@
;; Winbar settings
-(module config.winbar)
+(module config.winbar {autoload {nvim aniseed.nvim}})
-(tset vim.opt :winbar :%t%m)
+(def- ignore-filetypes {:help true
+ :startify true
+ :dashboard true
+ :packer true
+ :neogitstatus true
+ :NvimTree true
+ :Trouble true
+ :alpha true
+ :lir true
+ :Outline true
+ :spectre_panel true})
+
+(defn- is-empty [arg] (or (= arg nil) (= arg "")))
+
+(defn- get-filename [] (vim.fn.expand "%t:"))
+
+(defn- get-filetype [] vim.bo.filetype)
+
+(defn- get-extension [] (vim.fn.expand "%:e"))
+
+(defn- ignore [] (. ignore-filetypes (get-filetype)))
+
+(defn- get-icon [] (let [(ok? devicons) (pcall require :nvim-web-devicons)]
+ (if ok?
+ (let [filename (get-filename)
+ extension (get-extension)]
+ (if (not (is-empty filename))
+ (let [(icon _) (devicons.get_icon filename
+ extension)]
+ icon))))))
+
+(defn- get-winbar []
+ (if (and (not= (ignore) true) (not= (is-empty (get-filename)) true))
+ (let [icon (get-icon)]
+ (if (not= icon nil)
+ (vim.api.nvim_set_option_value :winbar (.. icon " " "%t%m")
+ {:scope :local})))
+ (vim.api.nvim_set_option_value :winbar "" {:scope :local})))
+
+(nvim.create_autocmd "BufEnter,CursorMoved,CursorHold,BufWinEnter,BufFilePost,InsertEnter,BufWritePost,TabClosed"
+ {:callback (lambda []
+ (get-winbar))})