aboutsummaryrefslogtreecommitdiff
path: root/fnl/nvrc/ui/modules/vi_mode.fnl
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2022-02-27 23:57:08 +0900
committersefidel <contact@sefidel.net>2022-02-27 23:58:05 +0900
commita15747ea28b1011d96aea09bc9779cb5f11ca7a9 (patch)
tree75ba23a8850a4eb57669a4980721b9f02d558884 /fnl/nvrc/ui/modules/vi_mode.fnl
parent56bf0ffd4304c610021268c675a59a4470fb29c6 (diff)
downloadnvimrc-a15747ea28b1011d96aea09bc9779cb5f11ca7a9.zip
feat(ui): feline -> homebrew statusline
Diffstat (limited to 'fnl/nvrc/ui/modules/vi_mode.fnl')
-rw-r--r--fnl/nvrc/ui/modules/vi_mode.fnl40
1 files changed, 40 insertions, 0 deletions
diff --git a/fnl/nvrc/ui/modules/vi_mode.fnl b/fnl/nvrc/ui/modules/vi_mode.fnl
new file mode 100644
index 0000000..1b9f1a1
--- /dev/null
+++ b/fnl/nvrc/ui/modules/vi_mode.fnl
@@ -0,0 +1,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}