summaryrefslogtreecommitdiff
path: root/dot-config/nvim-old/lua/wordcount.lua
blob: 92944e56b250f0fe459c61093eeba45bf7d29354 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
-- Wordcount in markdown
--
-- Credits
-- https://github.com/nvim-lualine/lualine.nvim/issues/328#issuecomment-982672253
-- https://github.com/skwee357/nvim-prose

local M = {}

local config = {
  filetypes = { "markdown", "text", "typst" },
}

function M.wordcount()
  local wc = vim.fn.wordcount()

  if wc.visual_words then
    return tostring(wc.visual_words) .. " words"
  end

  return tostring(wc.words) .. " words"
end

function M.is_available()
  for _, ft in ipairs(config.filetypes) do
    if ft == vim.bo.filetype then
      return true
    end
  end

  return false
end

return M