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
34
35
36
37
38
|
" autoload/latex_wordcount.vim
function! latex_wordcount#GetWordCountSingle() abort
lua << EOF
local wc = require("latex_wordcount")
local config = wc.default_config()
local json_path = vim.g.json_path
if json_path and json_path ~= "" then
local ok, err = pcall(wc.load_config, config, vim.fn.expand(json_path))
if not ok then
vim.notify(tostring(err), vim.log.levels.ERROR)
return
end
end
local count = wc.count_buffer(0, config, { follow_includes = false })
vim.notify(string.format("Real words (this file only): %d", count))
EOF
endfunction
function! latex_wordcount#GetWordCountMulti() abort
lua << EOF
local wc = require("latex_wordcount")
local config = wc.default_config()
local json_path = vim.g.json_path
if json_path and json_path ~= "" then
local ok, err = pcall(wc.load_config, config, vim.fn.expand(json_path))
if not ok then
vim.notify(tostring(err), vim.log.levels.ERROR)
return
end
end
local count, _, _, warnings = wc.count_buffer(0, config, { follow_includes = true })
vim.notify(string.format("Real words (including \\input/\\include): %d", count))
if warnings and #warnings > 0 then
vim.notify("include warnings:\n" .. table.concat(warnings, "\n"), vim.log.levels.WARN)
end
EOF
endfunction
|