diff --git a/init.lua b/init.lua index 32259ae..ea26110 100644 --- a/init.lua +++ b/init.lua @@ -65,6 +65,7 @@ vim.keymap.set("n", "Q", ":quit!") vim.keymap.set("n", "q", ":bd") vim.keymap.set("n", "", ":%s///cg") vim.keymap.set("n", "", ":echo wordcount()['chars']") +vim.keymap.set("n", "", ":lua print(genko())") vim.keymap.set("v", "i", "iW") vim.keymap.set("o", "i", "iW") vim.keymap.set("n", "U", "") @@ -1033,3 +1034,15 @@ require("everforest").setup({ vim.cmd("colorscheme everforest") --OTHER SETTINGS +function genko() + local line_count = 0 + local num_lines = vim.api.nvim_buf_line_count(0) + + for i = 1, num_lines do + local line = vim.api.nvim_buf_get_lines(0, i - 1, i, false)[1] + local s = math.ceil(vim.fn.strchars(line) / 20.0) + line_count = line_count + (s == 0 and 1 or s) + end + + return line_count / 20.0 +end