From e934e38bd01c9d2af9937dbf0e4f313ab57d3b44 Mon Sep 17 00:00:00 2001 From: Fabrice Mouhartem Date: Tue, 6 May 2025 13:57:26 +0200 Subject: [PATCH] feat(lualine): add counters to lualine - Word, character and line counters upon selection - From https://www.reddit.com/r/neovim/comments/1130kh5/comment/j8navg6/ --- lua/plugins-configure.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lua/plugins-configure.lua b/lua/plugins-configure.lua index 9c699e1..5d0190e 100644 --- a/lua/plugins-configure.lua +++ b/lua/plugins-configure.lua @@ -179,6 +179,23 @@ require('lazy').setup({ path = 1, } }, + lualine_y = { + { + -- Character, word and line counts + -- https://www.reddit.com/r/neovim/comments/1130kh5/comment/j8navg6/ + function() + local isVisualMode = vim.fn.mode():find("[Vv]") + if not isVisualMode then return "" end + local starts = vim.fn.line("v") + local ends = vim.fn.line(".") + local lines = starts <= ends and ends - starts + 1 or starts - ends + 1 + local wordcount = vim.fn.wordcount() + return tostring(wordcount.visual_words) .. + "W " .. tostring(wordcount.visual_chars) .. "C " .. tostring(lines) .. "L" + end + }, + 'progress' + } }, inactive_sections = { lualine_c = {