diff options
author | sefidel <contact@sefidel.net> | 2022-03-06 20:44:10 +0900 |
---|---|---|
committer | sefidel <contact@sefidel.net> | 2022-03-06 20:44:10 +0900 |
commit | f98bb630c4bc3562749ffe6b5d18c6a06955af36 (patch) | |
tree | cc8cd0d8798ed04d2d855040993c6eef352d6968 /fnl/nvrc/ui | |
parent | 5186760ef60dd0e16431125d9474e3d8d76eccba (diff) | |
download | nvimrc-f98bb630c4bc3562749ffe6b5d18c6a06955af36.tar.gz nvimrc-f98bb630c4bc3562749ffe6b5d18c6a06955af36.zip |
feat!: UI rewrite
Diffstat (limited to 'fnl/nvrc/ui')
-rw-r--r-- | fnl/nvrc/ui/modules/misc.fnl | 14 | ||||
-rw-r--r-- | fnl/nvrc/ui/modules/vi_mode.fnl | 40 | ||||
-rw-r--r-- | fnl/nvrc/ui/statusline.fnl | 11 |
3 files changed, 3 insertions, 62 deletions
diff --git a/fnl/nvrc/ui/modules/misc.fnl b/fnl/nvrc/ui/modules/misc.fnl deleted file mode 100644 index 24d84f9..0000000 --- a/fnl/nvrc/ui/modules/misc.fnl +++ /dev/null @@ -1,14 +0,0 @@ -(fn file-size [] - "feline.nvim's file size calculation module." - (let [suffix [:b :k :M :G :T :P :E]] - (var index 1) - (var fsize (vim.fn.getfsize (vim.api.nvim_buf_get_name 0))) - (when (< fsize 0) - (set fsize 0)) - (while (and (> fsize 1024) (< index 7)) - (set fsize (/ fsize 1024)) - (set index (+ index 1))) - (string.format (or (and (= index 1) "%g%s | ") "%.2f%s | ") fsize - (. suffix index)))) - -{: file-size} diff --git a/fnl/nvrc/ui/modules/vi_mode.fnl b/fnl/nvrc/ui/modules/vi_mode.fnl deleted file mode 100644 index 0fd4e16..0000000 --- a/fnl/nvrc/ui/modules/vi_mode.fnl +++ /dev/null @@ -1,40 +0,0 @@ -(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} diff --git a/fnl/nvrc/ui/statusline.fnl b/fnl/nvrc/ui/statusline.fnl index 9c6d04c..c50bc81 100644 --- a/fnl/nvrc/ui/statusline.fnl +++ b/fnl/nvrc/ui/statusline.fnl @@ -2,25 +2,20 @@ (import-macros {: ag! : au!} :nvrc.macro.event) -(local {: mode : update-mode-colors} (require :nvrc.ui.modules.vi_mode)) (local {: diagnostics} (require :nvrc.ui.modules.diagnostics)) -(local {: file-size} (require :nvrc.ui.modules.misc)) (global statusline {}) (set statusline.enable (fn [] - (table.concat ["%#StatusLinePad#" + (table.concat ["%#StatusLineAccent#" "▊ " "%#StatusLine#" - (update-mode-colors) - (mode) - "%#StatusLineFile#" + "%#StatusLineAccentBold#" "%f%m%r " "%#StatusLine#" - (file-size) "%l:%c | " (diagnostics) "%=" - "%#StatusLineFileData#" + "%#StatusLineAccentBold#" "%y *%n "]))) (ag! ui-statusline |