diff options
| author | Joshua Liu <joshua.liu@sourceobby.com> | 2026-08-02 23:13:15 -0400 |
|---|---|---|
| committer | Joshua Liu <joshua.liu@sourceobby.com> | 2026-08-02 23:13:15 -0400 |
| commit | 04dfd76d4aea0a84c837d768a0d7692295f24966 (patch) | |
| tree | ebd38e81792996448b29e486151ce0b9a77f0ef2 /autoload/latex_wordcount.vim | |
| parent | 692428b52339c1d4e0fccd312bf467789d2f1b15 (diff) | |
feat: making this fucking POS work. apparently I needed the autoload directory and cannot use hyphens in the namemaster
Diffstat (limited to 'autoload/latex_wordcount.vim')
| -rw-r--r-- | autoload/latex_wordcount.vim | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/autoload/latex_wordcount.vim b/autoload/latex_wordcount.vim new file mode 100644 index 0000000..c60a4d0 --- /dev/null +++ b/autoload/latex_wordcount.vim @@ -0,0 +1,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 |
