aboutsummaryrefslogtreecommitdiff
path: root/lua/denote/util.lua
diff options
context:
space:
mode:
authorHumanEntity <human_entity@icloud.com>2023-12-24 23:34:26 +0100
committerHumanEntity <human_entity@icloud.com>2023-12-24 23:34:26 +0100
commitebca541f572cafb01a2f6daf8237492791f33891 (patch)
tree67ee14443dedfbeb0ab69ca7137a1a21f0de2c84 /lua/denote/util.lua
parentad698b11fc89401e77f1773abb1aee9dffbd2076 (diff)
downloadsimple-denote.nvim-ebca541f572cafb01a2f6daf8237492791f33891.tar.gz
Little restructurization
Diffstat (limited to 'lua/denote/util.lua')
-rw-r--r--lua/denote/util.lua107
1 files changed, 5 insertions, 102 deletions
diff --git a/lua/denote/util.lua b/lua/denote/util.lua
index 95ee7dc..ce998f0 100644
--- a/lua/denote/util.lua
+++ b/lua/denote/util.lua
@@ -1,108 +1,11 @@
local M = {}
-M.config = require("denote.config")
----@class DenoteDate
----@field year string
----@field month string
----@field day string
-
----@param name string
----@param tags table|nil
----@return string filename format of files in denote.nvim
-function M.file(name, tags)
- local file = ""
-
- local date = tostring(os.date("%Y%m%d"))
-
- local tags_str = ""
-
- if tags then
- for i, tag in pairs(tags) do
- tags_str = tags_str .. tag
- if i < #tags then
- tags_str = tags_str .. M.config.filename.tag_sep
- end
- end
- end
-
- file = date .. M.config.filename.date_sep .. M.config.filename.date_sep .. name
- if tags then
- file = file .. M.config.filename.name_sep .. M.config.filename.name_sep .. tags_str
- end
-
- return file .. "." .. M.config.filename.ext
-end
-
----@param name string
----@param tags table|nil
---- Opens your note
-function M.note(name, tags)
- local filename = M.config.vault.dir .. M.file(name, tags)
-
- -- Echo template
-
- vim.cmd("!mkdir -p " .. M.config.vault.dir)
- vim.cmd("e " .. filename)
-end
-
----@param date DenoteDate|nil
----@param name string|nil
----@param func function
-function M.search(date, name, func)
- local items = {}
- local matcher = ""
-
- if date then
- if date.year then
- matcher = date.year
- else
- matcher = "%d%d%d%d"
- end
- if date.month then
- matcher = matcher .. date.month
- else
- matcher = "%d%d"
- end
- if date.day then
- matcher = matcher .. date.day
- else
- matcher = "%d%d"
- end
-
- matcher = matcher .. M.config.filename.date_sep .. M.config.filename.date_sep
- else
- matcher = "%d+" .. M.config.filename.date_sep .. M.config.filename.date_sep
+function M.splitspace(str)
+ local chunks = {}
+ for substring in str:gmatch("%S+") do
+ table.insert(chunks, #chunks, substring)
end
-
- if name then
- matcher = matcher .. name
- else
- matcher = matcher .. ".+"
- end
-
- -- matcher = matcher .. M.config.filename.name_sep .. "?" .. M.config.filename.name_sep .. "?" .. ".-"
-
- for file in io.popen("ls " .. M.config.vault.dir):lines() do
- local matched = file:match(matcher)
-
- if matched then
- print("file " .. file)
- items[#items + 1] = file
- end
- end
-
- if not items or #items == 0 then
- return nil
- end
-
- vim.ui.select(items, {
- prompt = "Select note",
- -- format_item = function(item)
- -- return "" .. item
- -- end,
- }, func)
-
- return true
+ return chunks
end
return M