Skip to content

Commit

Permalink
Add ReadingTime function
Browse files Browse the repository at this point in the history
Command gets created in the ftplugin for markdown, which... might be
wrong? I think that might mean it's available in any buffers when I have
a markdown buffer open. That's fine though, I only really care that it's
available when I'm in markdown buffers, so, you know, requirements met.
  • Loading branch information
jisantuc committed Sep 22, 2024
1 parent fd2c4d9 commit 45635b1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dotfiles/neovim/ftplugin/markdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,11 @@ require('render-markdown').setup({

vim.opt_local.foldmethod = "expr"
vim.opt_local.foldexpr = "nvim_treesitter#foldexpr()"

local function readingTime()
local count = vim.fn.wordcount().words
local readingTimeMinutes = count / 238
print(string.format("%.1f", readingTimeMinutes) .. " minutes")
end

vim.api.nvim_create_user_command("ReadingTime", readingTime, {})

0 comments on commit 45635b1

Please sign in to comment.