1
0
Fork 0

nvim: Update statusline

This commit is contained in:
Daniel Kempkens 2023-04-11 10:55:50 +02:00
parent 47c87b7b1e
commit 57958b8d99
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM
3 changed files with 24 additions and 9 deletions

View file

@ -54,6 +54,7 @@
(set o.mouse :a)
(set o.mousemodel :popup_setpos)
(set o.cmdheight 1)
(set o.showcmdloc :statusline)
;; Backups
(set o.backup false)
(set o.swapfile false)

View file

@ -26,8 +26,7 @@
(if (> (length str) max-length) (.. (str:sub 1 max-length) ellipsis) str))
;; Utils
(set mod.default-hl (fn []
{:bg colors.black}))
(set mod.default-hl #{:bg colors.black})
(set mod.space {:provider " "})
(set mod.spacer {:provider " " :hl {:fg colors.bg :bg colors.bg}})
(set mod.push-right {:provider "%="})
@ -37,9 +36,7 @@
{:condition #(or (> $1.check-count 0) (> $1.check-length 0))
:provider " "})
;; Mode
(set mod.vi-mode {:init (fn [self]
(let [mode (. (api.nvim_get_mode) :mode)]
(set self.mode mode)))
(set mod.vi-mode {:init #(set $1.mode (. (api.nvim_get_mode) :mode))
:update {1 :ModeChanged
:pattern "*:*"
:callback (vim.schedule_wrap #(vim.cmd.redrawstatus))}
@ -122,9 +119,7 @@
(let [short-mode (self.mode:sub 1 1)]
(. self :mode-hl short-mode)))})
;; Filetype
(set mod.filetype-block
{:init (fn [self]
(set self.filename (api.nvim_buf_get_name 0)))})
(set mod.filetype-block {:init #(set $1.filename (api.nvim_buf_get_name 0))})
(set mod.file-icon {:init (fn [self]
(let [filename self.filename
ext (vim.fn.fnamemodify filename ":e")
@ -361,6 +356,24 @@
:init #(set $1.count (vim.fn.searchcount {:timeout 5}))
:provider #(string.format "[%s/%s]" $1.count.current $1.count.total)
:hl {:fg colors.black :bg colors.purple}})
;; Command
(set mod.command
{:condition (fn [self]
(let [mode (. (api.nvim_get_mode) :mode)]
(vim.tbl_contains self.enabled-modes mode)))
:update {1 :ModeChanged :pattern "*:*"}
:static {:enabled-modes [:no
:nov
:noV
"no\022"
:v
:vs
:V
:Vs
"\022"
"\022s"]}
:provider "[%S]"
:hl {:fg colors.black :bg colors.purple}})
;; Custom Mode
(fn mod.custom-mode [str fg bg]

View file

@ -18,7 +18,8 @@
ns.scrollbar
ns.space
ns.position
ns.search-count])
ns.search-count
ns.command])
(local telescope-statusline
{:condition (fn []
(conditions.buffer_matches {:filetype [:TelescopePrompt]}))