Skip to content

Commit

Permalink
Add word count to status line for markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
zmre committed Nov 12, 2024
1 parent dba136d commit f52d437
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pwnvim/plugins/lualine.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
local lualine = require('lualine')

-- Functions to show word count and reading time in markdown files
-- Credit: https://yieldcode.blog/snippets/neovim-reading-time/
local function wordcount()
return tostring(vim.fn.wordcount().words) .. ' words'
end

local function readingtime()
return tostring(math.ceil(vim.fn.wordcount().words / 200.0)) .. ' min'
end

local function is_markdown()
return vim.bo.filetype == "markdown"
end

local paper = {
options = {
theme = 'papercolor_light',
Expand All @@ -14,7 +29,7 @@ local paper = {
lualine_b = { 'branch' },
lualine_c = { 'filename' },
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'progress', 'location' },
lualine_y = { 'progress', 'location', { wordcount, cond = is_markdown }, { readingtime, cond = is_markdown } },
lualine_z = {
--{
-- require("noice").api.statusline.mode.get,
Expand Down Expand Up @@ -170,6 +185,8 @@ ins_left { 'location' }

ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } }

ins_left { wordcount, cond = is_markdown, color = { fg = colors.green } }
ins_left { readingtime, cond = is_markdown, color = { fg = colors.green } }
ins_left {
'diagnostics',
sources = { 'nvim_diagnostic' },
Expand Down

0 comments on commit f52d437

Please sign in to comment.