aboutsummaryrefslogtreecommitdiff
path: root/lua/simple-denote/util.lua
diff options
context:
space:
mode:
authorworkhorse <gravel.justness270@slmail.me>2024-06-03 16:48:36 -0400
committerworkhorse <gravel.justness270@slmail.me>2024-06-03 16:48:36 -0400
commit516bc5e46c8e8a4f63df0a21bf7efbe835bdec2a (patch)
treebca5f5d8c72b25a0db65d28f42cd3eb7bd8ef6ae /lua/simple-denote/util.lua
parent1bf7bc5b79636814db73a9148998c72fbe554d58 (diff)
downloadsimple-denote.nvim-516bc5e46c8e8a4f63df0a21bf7efbe835bdec2a.tar.gz
Fixed heading config
Diffstat (limited to 'lua/simple-denote/util.lua')
-rw-r--r--lua/simple-denote/util.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/lua/simple-denote/util.lua b/lua/simple-denote/util.lua
new file mode 100644
index 0000000..643e2e7
--- /dev/null
+++ b/lua/simple-denote/util.lua
@@ -0,0 +1,32 @@
+local M = {}
+
+
+function M.splitspace(str)
+ local chunks = {}
+ for substring in str:gmatch("%S+") do
+ table.insert(chunks, #chunks, substring)
+ end
+ return chunks
+end
+
+function M.splitstring(str, delim)
+ local items = {}
+ local fulldelim = nil
+ if delim == "." or delim == "-" then
+ fulldelim = "%" .. delim
+ else
+ fulldelim = delim
+ end
+ str = str .. delim
+ for w in str:gmatch("(.-)" .. fulldelim) do
+ items[#items + 1] = w
+ end
+ return items
+end
+
+--- Escape a string to use as a lua pattern
+function M.escape(str)
+ return str:gsub("(%W)", "%%%1")
+end
+
+return M