aboutsummaryrefslogtreecommitdiff
path: root/lua/denote/init.lua
diff options
context:
space:
mode:
authorHumanEntity <human_entity@icloud.com>2023-12-22 20:56:41 +0100
committerHumanEntity <human_entity@icloud.com>2023-12-22 20:56:41 +0100
commit26f605ecf08800850fd02c5fee6d2b74d7ceea64 (patch)
tree8fe1ec4d6918653b319f73f519c259637afa628f /lua/denote/init.lua
downloadsimple-denote.nvim-26f605ecf08800850fd02c5fee6d2b74d7ceea64.tar.gz
Initial commit
Diffstat (limited to 'lua/denote/init.lua')
-rw-r--r--lua/denote/init.lua84
1 files changed, 84 insertions, 0 deletions
diff --git a/lua/denote/init.lua b/lua/denote/init.lua
new file mode 100644
index 0000000..18f57c1
--- /dev/null
+++ b/lua/denote/init.lua
@@ -0,0 +1,84 @@
+local M = {}
+local U = require("denote.util")
+
+local function splitlines(str)
+ local result = {}
+ for line in string.gmatch(str .. "\n", "(.-)\n") do
+ table.insert(result, line)
+ end
+ return result
+end
+
+local function splitspace(str)
+ local chunks = {}
+ for substring in str:gmatch("%S+") do
+ table.insert(chunks, #chunks, substring)
+ end
+ return chunks
+end
+
+function M.note()
+ local name = ""
+ local tags = nil
+
+ vim.ui.input({ prompt = "Note name: " }, function(input)
+ name = input
+ end)
+
+ vim.ui.input({ prompt = "Enter tags: " }, function(input)
+ if input ~= "" then
+ tags = splitspace(input)
+ end
+ end)
+
+ U.note(name, tags)
+end
+
+function M.search()
+ local date = nil
+ local name = nil
+
+ vim.ui.input({ prompt = "Date: " }, function(input)
+ local split = splitspace(input)
+ if split[0] then
+ date = {}
+ date.year = split[0]
+ if split[1] then
+ date.month = split[1]
+ if split[2] then
+ date.day = split[2]
+ end
+ end
+ end
+ end)
+ vim.ui.input({ prompt = "Name: " }, function(input)
+ name = input
+ end)
+
+ local status = U.search(date, name, function(input)
+ if input then
+ vim.cmd("e " .. U.config.vault_dir .. "/" .. input)
+ end
+ if date then
+ print(date.year, " ", date.month, " ", date.day)
+ print("FSD")
+ end
+ end)
+ -- print(date)
+ -- if date then
+ -- print(date.year, " ", date.month, " ", date.day)
+ -- print("FSD")
+ -- end
+
+ if not status then
+ print("Error opening file")
+ end
+end
+
+function M.setup(config)
+ if config then
+ U.config = config
+ end
+end
+
+return M