1-- reading_time.lua
2-- Estimates reading time based on word count while composing.
3-- Assumes ~200 words per minute average reading speed.
4
5local matcha = require("matcha")
6
7matcha.on("composer_updated", function(state)
8 local words = 0
9 for _ in state.body:gmatch("%S+") do
10 words = words + 1
11 end
12 if words > 0 then
13 local minutes = math.ceil(words / 200)
14 if minutes <= 1 then
15 matcha.set_status("composer", "~1 min read")
16 else
17 matcha.set_status("composer", "~" .. minutes .. " min read")
18 end
19 end
20end)