summaryrefslogtreecommitdiff
path: root/dot-config
diff options
context:
space:
mode:
Diffstat (limited to 'dot-config')
-rw-r--r--dot-config/nvim/lua/plugins/lualine.lua16
-rw-r--r--dot-config/nvim/lua/wordcount.lua27
2 files changed, 43 insertions, 0 deletions
diff --git a/dot-config/nvim/lua/plugins/lualine.lua b/dot-config/nvim/lua/plugins/lualine.lua
new file mode 100644
index 0000000..d71612a
--- /dev/null
+++ b/dot-config/nvim/lua/plugins/lualine.lua
@@ -0,0 +1,16 @@
+local wc = require("wordcount")
+
+return {
+ "nvim-lualine/lualine.nvim",
+ opts = {
+ sections = {
+ lualine_y = {
+ -- Add wordcount
+ { wc.wordcount, cond = wc.is_available },
+ -- Existing conf
+ { "progress", separator = " ", padding = { left = 1, right = 0 } },
+ { "location", padding = { left = 0, right = 1 } },
+ },
+ },
+ },
+}
diff --git a/dot-config/nvim/lua/wordcount.lua b/dot-config/nvim/lua/wordcount.lua
new file mode 100644
index 0000000..b61a4ee
--- /dev/null
+++ b/dot-config/nvim/lua/wordcount.lua
@@ -0,0 +1,27 @@
+-- Wordcount in markdown
+--
+-- Credits
+-- https://github.com/nvim-lualine/lualine.nvim/issues/328#issuecomment-982672253
+-- https://github.com/skwee357/nvim-prose
+
+local M = {}
+
+function M.wordcount()
+ local wc = vim.fn.wordcount()
+
+ if not (wc.visual_words == nil) then
+ return tostring(wc.visual_words) .. " words"
+ end
+
+ return tostring(wc.words) .. " words"
+end
+
+function M.is_available()
+ if vim.bo.filetype == "markdown" then
+ return true
+ end
+
+ return false
+end
+
+return M