summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Liu <joshua.liu@sourceobby.com>2026-08-02 23:13:15 -0400
committerJoshua Liu <joshua.liu@sourceobby.com>2026-08-02 23:13:15 -0400
commit04dfd76d4aea0a84c837d768a0d7692295f24966 (patch)
treeebd38e81792996448b29e486151ce0b9a77f0ef2
parent692428b52339c1d4e0fccd312bf467789d2f1b15 (diff)
feat: making this fucking POS work. apparently I needed the autoload directory and cannot use hyphens in the namemaster
-rw-r--r--autoload/latex_wordcount.vim38
-rw-r--r--lua/latex_wordcount.lua (renamed from lua/latex-wordcount.lua)4
-rw-r--r--plugin/latex_wordcount.vim (renamed from plugin/latex-wordcount.vim)13
3 files changed, 44 insertions, 11 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
diff --git a/lua/latex-wordcount.lua b/lua/latex_wordcount.lua
index 01af4ff..e0f0fef 100644
--- a/lua/latex-wordcount.lua
+++ b/lua/latex_wordcount.lua
@@ -888,7 +888,7 @@ end
-- ---------------------------------------------------------------------
if vim ~= nil and vim.api ~= nil and vim.api.nvim_create_user_command ~= nil then
- vim.api.nvim_create_user_command("MultiLatexWordCount", function(opts)
+ vim.api.nvim_create_user_command("GetWordCountMulti", function(opts)
local config = M.default_config()
if opts.args and opts.args ~= "" then
local ok, err = pcall(M.load_config, config, opts.args)
@@ -904,7 +904,7 @@ if vim ~= nil and vim.api ~= nil and vim.api.nvim_create_user_command ~= nil the
end
end, { nargs = "?", complete = "file", desc = "Count real (visible) words in the current LaTeX buffer (Including other files)" })
- vim.api.nvim_create_user_command("SingleLatexWordCount", function(opts)
+ vim.api.nvim_create_user_command("GetWordCountSingle", function(opts)
local config = M.default_config()
if opts.args and opts.args ~= "" then
local ok, err = pcall(M.load_config, config, opts.args)
diff --git a/plugin/latex-wordcount.vim b/plugin/latex_wordcount.vim
index 1ea85fe..c1c2ff6 100644
--- a/plugin/latex-wordcount.vim
+++ b/plugin/latex_wordcount.vim
@@ -1,4 +1,4 @@
-" Title: latex-wordcount.vim
+" Title: latex_wordcount.vim
" Description: A plugin to provide a more accurate wordcount of a LaTeX
" document
" Last Change: 14 July, 2026
@@ -13,15 +13,10 @@ endif
let g:loaded_latex_wordcount = 1
" Exposes the plugin's functions for use as commands in Vim.
-command! -nargs=0 GetWordCountSingle call latex-wordcount#GetWordCountSingle()
-command! -nargs=0 GetWordCountMulti call latex-wordcount#GetWordCountMulti()
-"command! -nargs=0 AspellCheck call latex-wordcount#AspellCheck()
+command! -nargs=0 GetWordCountSingle call latex_wordcount#GetWordCountSingle()
+command! -nargs=0 GetWordCountMulti call latex_wordcount#GetWordCountMulti()
if !exists('g:json_path')
- let g:json_path= "~/.config"
+ let g:json_path= "~/.config/nvim/cmds.json"
endif
-"
-"if !exists('g:my_plugin_max_items')
-" let g:my_plugin_max_items = 50
-"endif