blob: feecefe446c7cbaea405f728be8eb5b10759026b (
plain)
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
|
local M = {}
local internal = require("denote.internal")
local util = require("denote.util")
local config = require("denote.config")
---@param name string|nil
---@param tags table|nil
function M.note(name, tags)
if not name then
vim.ui.input({ prompt = "Note name: " }, function(input)
name = input
end)
end
if not tags then
vim.ui.input({ prompt = "Enter tags: " }, function(input)
if input ~= "" and input then
tags = util.splitspace(input)
end
end)
end
if name == "" then
error("Didn't specify name")
end
internal.note(name, tags)
end
---@param date DenoteDate|nil
---@param name string|nil
function M.search(date, name)
if not date then
vim.ui.input({ prompt = "Date: " }, function(input)
local split = util.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)
end
if not name then
vim.ui.input({ prompt = "Name: " }, function(input)
name = input
end)
end
local status = internal.search(date, name, function(input)
if input then
vim.cmd("e " .. config.vault.dir .. "/" .. input)
end
end)
if not status then
print("Error opening file")
end
end
return M
|