1
0
Fork 0

nvim: Make more use of the fennel # function

This commit is contained in:
Daniel Kempkens 2023-04-03 22:30:57 +02:00
parent 01271138d3
commit cf213116e9
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM

View file

@ -133,14 +133,11 @@
{:default true})] {:default true})]
(set self.icon icon) (set self.icon icon)
(set self.icon-color color))) (set self.icon-color color)))
:provider (fn [self] :provider #(when $1.icon
(when self.icon (.. $1.icon " "))
(.. self.icon " "))) :hl #{:fg $1.icon-color}})
:hl (fn [self] (set mod.filetype {:provider #(let [ft vim.bo.filetype]
{:fg self.icon-color})}) (if (> (ft:len) 0) ft "no ft"))
(set mod.filetype {:provider (fn []
(let [ft vim.bo.filetype]
(if (> (ft:len) 0) ft "no ft")))
:hl {:fg colors.white}}) :hl {:fg colors.white}})
(set mod.encoding {:provider (fn [] (set mod.encoding {:provider (fn []
(let [vim-enc (if (not= vim.bo.fenc nil) (let [vim-enc (if (not= vim.bo.fenc nil)
@ -155,7 +152,8 @@
{:provider " | " :hl {:fg colors.white}} {:provider " | " :hl {:fg colors.white}}
mod.encoding)) mod.encoding))
;; git ;; git
(set mod.git {:condition heirline-conditions.is_git_repo (set mod.git
{:condition heirline-conditions.is_git_repo
:init (fn [self] :init (fn [self]
(let [git-status vim.b.gitsigns_status_dict] (let [git-status vim.b.gitsigns_status_dict]
(set self.git-head git-status.head) (set self.git-head git-status.head)
@ -171,15 +169,11 @@
2 {:provider #(.. "  " $1.git-head " ") 2 {:provider #(.. "  " $1.git-head " ")
:hl {:fg colors.black :bg colors.orange :bold true}} :hl {:fg colors.black :bg colors.orange :bold true}}
3 mod.space 3 mod.space
4 {:provider (fn [self] 4 {:provider #(.. " " $1.git-added " ")
(.. " " self.git-added " "))
:hl {:fg colors.bright_green}} :hl {:fg colors.bright_green}}
5 {:provider (fn [self] 5 {:provider #(.. " " $1.git-removed " ")
(.. " " self.git-removed " "))
:hl {:fg colors.bright_red}} :hl {:fg colors.bright_red}}
6 {:provider (fn [self] 6 {:provider #(.. " " $1.git-changed) :hl {:fg colors.cyan}}})
(.. " " self.git-changed))
:hl {:fg colors.cyan}}})
;; Diagnostics ;; Diagnostics
(set mod.diagnostics {:condition heirline-conditions.has_diagnostics (set mod.diagnostics {:condition heirline-conditions.has_diagnostics
:init (fn [self] :init (fn [self]
@ -233,10 +227,9 @@
;; Current Function ;; Current Function
(set mod.current-function (set mod.current-function
{:condition heirline-conditions.lsp_attached {:condition heirline-conditions.lsp_attached
:init (fn [self] :init #(if (navic.is_available)
(if (navic.is_available) (set $1.check-length 1)
(set self.check-length 1) (set $1.check-length 0))
(set self.check-length 0)))
:update :CursorMoved :update :CursorMoved
1 mod.space-if-length 1 mod.space-if-length
2 {:provider #(string.gsub (navic.get_location) "%%" "%%%%") 2 {:provider #(string.gsub (navic.get_location) "%%" "%%%%")
@ -330,9 +323,8 @@
(let [pos (api.nvim_win_get_cursor 0)] (let [pos (api.nvim_win_get_cursor 0)]
(set self.position-line (tostring (. pos 1))) (set self.position-line (tostring (. pos 1)))
(set self.position-column (tostring (. pos 2))))) (set self.position-column (tostring (. pos 2)))))
:provider (fn [self] :provider #(string.format " %3s:%-3s " $1.position-line
(string.format " %3s:%-3s " self.position-line $1.position-column)
self.position-column))
:hl {:fg colors.black :bg colors.purple :bold true}}) :hl {:fg colors.black :bg colors.purple :bold true}})
;; Scrollbar ;; Scrollbar
(set mod.scrollbar {:init (fn [self] (set mod.scrollbar {:init (fn [self]
@ -366,11 +358,8 @@
;; Search count ;; Search count
(set mod.search-count (set mod.search-count
{:condition #(> vim.v.hlsearch 0) {:condition #(> vim.v.hlsearch 0)
:init (fn [self] :init #(set $1.count (vim.fn.searchcount {:timeout 5}))
(set self.count (vim.fn.searchcount {:timeout 5}))) :provider #(string.format "[%s/%s]" $1.count.current $1.count.total)
:provider (fn [self]
(string.format "[%s/%s]" self.count.current
self.count.total))
:hl {:fg colors.black :bg colors.purple}}) :hl {:fg colors.black :bg colors.purple}})
;; Custom Mode ;; Custom Mode