nvim: Handle long method names/attrs in statusline
This commit is contained in:
parent
c808764e04
commit
c2e88d4ad2
1 changed files with 10 additions and 2 deletions
|
@ -22,6 +22,9 @@
|
||||||
(fn max-number [nums]
|
(fn max-number [nums]
|
||||||
(math.max (unpack nums)))
|
(math.max (unpack nums)))
|
||||||
|
|
||||||
|
(fn truncate-string [str max-length ellipsis]
|
||||||
|
(if (> (length str) max-length) (.. (str:sub 1 max-length) ellipsis) str))
|
||||||
|
|
||||||
;; Utils
|
;; Utils
|
||||||
(set mod.default-hl (fn []
|
(set mod.default-hl (fn []
|
||||||
{:bg colors.black}))
|
{:bg colors.black}))
|
||||||
|
@ -261,6 +264,7 @@
|
||||||
:Event "@keyword"
|
:Event "@keyword"
|
||||||
:Operator "@operator"
|
:Operator "@operator"
|
||||||
:TypeParameter "@type"}
|
:TypeParameter "@type"}
|
||||||
|
:separator " "
|
||||||
:enc (fn [line col winnr]
|
:enc (fn [line col winnr]
|
||||||
(let [enc-line (bit.lshift line 16)
|
(let [enc-line (bit.lshift line 16)
|
||||||
enc-col (bit.lshift col 6)]
|
enc-col (bit.lshift col 6)]
|
||||||
|
@ -279,7 +283,10 @@
|
||||||
(let [pos (self.enc d.scope.start.line
|
(let [pos (self.enc d.scope.start.line
|
||||||
d.scope.start.character self.winnr)
|
d.scope.start.character self.winnr)
|
||||||
child [{:provider d.icon :hl (. self.type-hl d.type)}
|
child [{:provider d.icon :hl (. self.type-hl d.type)}
|
||||||
{:provider (string.gsub d.name "%%" "%%%%")
|
{:provider (truncate-string (string.gsub d.name
|
||||||
|
"%%"
|
||||||
|
"%%%%")
|
||||||
|
45 "…")
|
||||||
:on_click {:name :heirline_navic
|
:on_click {:name :heirline_navic
|
||||||
:minwid pos
|
:minwid pos
|
||||||
:callback (fn [_ minwid]
|
:callback (fn [_ minwid]
|
||||||
|
@ -290,7 +297,8 @@
|
||||||
col])))}}]]
|
col])))}}]]
|
||||||
(when (and (> data-len 1) (< i data-len))
|
(when (and (> data-len 1) (< i data-len))
|
||||||
(table.insert child
|
(table.insert child
|
||||||
{:provider " " :hl {:fg colors.white}}))
|
{:provider self.separator
|
||||||
|
:hl {:fg colors.white}}))
|
||||||
(table.insert children child)))
|
(table.insert children child)))
|
||||||
(set self.child (self:new children 1)))
|
(set self.child (self:new children 1)))
|
||||||
:update :CursorMoved
|
:update :CursorMoved
|
||||||
|
|
Loading…
Reference in a new issue