diff options
author | sefidel <contact@sefidel.net> | 2022-02-27 23:57:08 +0900 |
---|---|---|
committer | sefidel <contact@sefidel.net> | 2022-02-27 23:58:05 +0900 |
commit | a15747ea28b1011d96aea09bc9779cb5f11ca7a9 (patch) | |
tree | 75ba23a8850a4eb57669a4980721b9f02d558884 /fnl/nvrc/ui/modules/misc.fnl | |
parent | 56bf0ffd4304c610021268c675a59a4470fb29c6 (diff) | |
download | nvimrc-a15747ea28b1011d96aea09bc9779cb5f11ca7a9.tar.gz nvimrc-a15747ea28b1011d96aea09bc9779cb5f11ca7a9.zip |
feat(ui): feline -> homebrew statusline
Diffstat (limited to 'fnl/nvrc/ui/modules/misc.fnl')
-rw-r--r-- | fnl/nvrc/ui/modules/misc.fnl | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/fnl/nvrc/ui/modules/misc.fnl b/fnl/nvrc/ui/modules/misc.fnl new file mode 100644 index 0000000..24d84f9 --- /dev/null +++ b/fnl/nvrc/ui/modules/misc.fnl @@ -0,0 +1,14 @@ +(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} |