1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
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 ~= "" and input then
tags = splitspace(input)
end
end)
if name == "" then
error("Didn't specify name")
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
---@param config DenoteConfig
function M.setup(config)
if config then
U.config = config
end
end
return M
|