(let pal-bg-deep (rgb 18 18 30)) (let pal-bg-line (rgb 32 32 52)) (let pal-bg-sel (rgb 20 60 110)) (let pal-bg-panel (rgb 26 26 42)) (let pal-fg-base (rgb 220 220 240)) (let pal-fg-dim (rgb 110 110 140)) (let pal-accent (rgb 180 150 220)) (let pal-warn (rgb 230 180 60)) (let pal-error (rgb 230 90 90)) (let pal-mode-i (rgb 230 160 80)) (let pal-mode-v (rgb 210 110 200)) (let pal-mode-c (rgb 110 210 210))
(face-define "twilight.base" {"fg": pal-fg-base "bg": pal-bg-deep})
(face-define "twilight.muted" {"fg": pal-fg-dim "italic": 1})
(face-define "twilight.accent" {"fg": pal-accent "bold": 1})
(face-define "twilight.error" {"fg": pal-error "bold": 1 "underline": 1})
(face-define "twilight.warn" {"fg": pal-warn "bold": 1})
(face-define "twilight.mode.normal" {"fg": 'green "bold": 1})
(face-define "twilight.mode.insert" {"fg": pal-mode-i "bold": 1})
(face-define "twilight.mode.visual" {"fg": pal-mode-v "bold": 1})
(face-define "twilight.mode.visual-line" {"fg": pal-mode-v "bold": 1 "italic": 1})
(face-define "twilight.mode.visual-block" {"fg": pal-mode-v "bold": 1 "underline": 1})
(face-define "twilight.mode.command" {"fg": pal-mode-c "bold": 1})
(face-define "twilight.gutter" {"fg": pal-fg-dim})
(face-define "twilight.gutter-current" {"fg": pal-accent "bold": 1})
(face-define "twilight.cursor-marker" {"fg": pal-bg-deep "bg": pal-accent})
(face-define "twilight.signature" {"fg": 215 "italic": 1})
(face-define "twilight.reverse" {"reverse": 1 "bold": 1})
(face-define "twilight.everything"
{"fg": (rgb 255 240 200)
"bg": (rgb 60 20 60)
"bold": 1
"italic": 1
"underline": 1
"reverse": 0})
(fn _mode-face (m)
(if (= m "normal") "twilight.mode.normal"
(if (= m "insert") "twilight.mode.insert"
(if (= m "visual") "twilight.mode.visual"
(if (= m "visual-line") "twilight.mode.visual-line"
(if (= m "visual-block") "twilight.mode.visual-block"
(if (= m "command") "twilight.mode.command"
"twilight.muted")))))))
(fn _mode-glyph (m)
(if (= m "normal") "N"
(if (= m "insert") "I"
(if (= m "visual") "V"
(if (= m "visual-line") "L"
(if (= m "visual-block") "B"
(if (= m "command") "C"
"?")))))))
(fn _pad-right (s w)
(do
(let pad (- w (len s)))
(if (> pad 0)
(str-join [s (str-join (fmap (fn _spc (_) " ") (range 0 pad)) "")] "")
s)))
(fn _gutter (n)
(if (= n ())
(span " " "twilight.gutter")
(if (= n (cursor-line))
(span (_pad-right (str-join ["▎ " (to-str n)] "") 5)
"twilight.gutter-current")
(span (_pad-right (str-join ["│ " (to-str n)] "") 5)
"twilight.gutter"))))
(gutter-add 'line-numbers 5 _gutter)
(decorator-add 'base-fg 'base-fg)
(decorator-add 'selection-highlight 'selection-highlight)
(decorator-add 'current-line-highlight 'current-line-highlight)
(fn _cursor-marker ()
[{"row": (cursor-line)
"col": (cursor-col)
"len": 1
"style": "twilight.cursor-marker"
"pad-to-width": 0}])
(decorator-add 'cursor-marker _cursor-marker)
(status-segment-remove 'mode-glyph)
(status-segment-remove 'last-key)
(status-segment-remove 'spacer)
(status-segment-remove 'buffer-no)
(fn _mode-segment ()
(do
(let m (focused-mode))
(span (str-join [" " (_mode-glyph m) " "] "")
(_mode-face m))))
(status-segment-add 'mode 'left _mode-segment)
(status-segment-add 'brand 'left
(span " twilight " "twilight.signature"))
(fn _selection-hint ()
(do
(let sel (selected-text))
(if (= sel ())
"" (span (str-join [" " (to-str (len sel)) " chars selected "] "")
"twilight.accent"))))
(status-segment-add 'sel-hint 'left _selection-hint)
(fn _cursor-pos ()
(span (str-join [(to-str (cursor-line)) ":" (to-str (cursor-col))] "")
"twilight.accent"))
(status-segment-add 'cursor 'right _cursor-pos)
(status-segment-add 'pip 'right
(span " • " "twilight.muted"))
(status-segment-add 'last-key 'right 'last-key)
(status-segment-add 'spacer 'right " ")
(fn _bufno ()
(do
(let m (focused-mode))
(if (= m "command")
(span (to-str (cursor-line)) "twilight.reverse")
(span (to-str (cursor-line)) "twilight.warn"))))
(status-segment-add 'bufno 'right _bufno)
(fn _hint-bar ()
(do
(let m (focused-mode))
(let lhs
(if (= m "normal")
(span " press : for commands · i to insert · v to select "
"twilight.muted")
(if (= m "insert")
(span " press <esc> to leave insert mode " "twilight.muted")
(if (= m "command")
(span " command mode — type a form and press <enter> "
"twilight.muted")
(span " visual: y to yank · d to delete · <esc> to cancel "
"twilight.muted")))))
[[lhs]]))
(bottom-add 'hint-bar 1 _hint-bar)
(fn _phantom-ranges ()
(fmap (fn _to-range (i)
{"row": (+ (cursor-line) i)
"col": 0
"len": 0
"style": "twilight.everything"
"pad-to-width": 0})
(range 1 1)))
(decorator-add 'phantom _phantom-ranges)