about summary refs log tree commit diff
path: root/fnl/nvrc/ui/modules/vi_mode.fnl
blob: 1b9f1a1c2aad3a808fa1870e19f9d8fc4daf22e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(local modes {:n :NORMAL
              :no :NORMAL
              :v :VISUAL
              :V "V-LINE"
              "\022" "V-BLOCK"
              :s :SELECT
              :S "L-SELECT"
              "\019" "B-SELECT"
              :i :INSERT
              :ic :INSERT
              :R :REPLACE
              :Rv "V-REPLACE"
              :c :COMMAND
              :cv "VIM-EX"
              :ce :EX
              :r :PROMPT
              :rm :MOAR
              :r? :CONFIRM
              :! :SHELL
              :t :TERMINAL})

(fn mode []
  (let [current-mode (. (vim.api.nvim_get_mode) :mode)]
    (: (string.format "%s " (. modes current-mode)) :upper)))

(fn update-mode-colors []
  (let [current-mode (. (vim.api.nvim_get_mode) :mode)]
    (var mode-color "%#StatuslineAccent#")
    (if (= current-mode :n) (set mode-color "%#StatuslineAccent#")
        (or (= current-mode :i) (= current-mode :ic))
        (set mode-color "%#StatuslineInsertAccent#")
        (or (or (= current-mode :v) (= current-mode :V))
            (= current-mode "\022"))
        (set mode-color "%#StatusLineVisualAccent#") (= current-mode :R)
        (set mode-color "%#StatusLineReplaceAccent#") (= current-mode :c)
        (set mode-color "%#StatusLineCmdLineAccent#") (= current-mode :t)
        (set mode-color "%#StatusLineTerminalAccent#"))
    mode-color))

{: mode : update-mode-colors}