aboutsummaryrefslogtreecommitdiff
path: root/lua/denote/api.lua
diff options
context:
space:
mode:
authorHumanEntity <human_entity@icloud.com>2023-12-25 13:28:02 +0100
committerHumanEntity <human_entity@icloud.com>2023-12-25 13:28:02 +0100
commitf94d9d4419e3a32ecee4410619c34a9433ca996d (patch)
treec45a0e00ae4dcfb741cce63ee21c107448ad8f99 /lua/denote/api.lua
parentd622dfc65774320032f2a9f8bb3a0e74b90d0b3b (diff)
downloadsimple-denote.nvim-f94d9d4419e3a32ecee4410619c34a9433ca996d.tar.gz
Made api more flexible
Diffstat (limited to 'lua/denote/api.lua')
-rw-r--r--lua/denote/api.lua72
1 files changed, 37 insertions, 35 deletions
diff --git a/lua/denote/api.lua b/lua/denote/api.lua
index d794fa7..feecefe 100644
--- a/lua/denote/api.lua
+++ b/lua/denote/api.lua
@@ -3,19 +3,22 @@ local internal = require("denote.internal")
local util = require("denote.util")
local config = require("denote.config")
-function M.note()
- local name = ""
- local tags = nil
-
- vim.ui.input({ prompt = "Note name: " }, function(input)
- name = input
- end)
+---@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
- vim.ui.input({ prompt = "Enter tags: " }, function(input)
- if input ~= "" and input then
- tags = splitspace(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")
@@ -24,37 +27,36 @@ function M.note()
internal.note(name, tags)
end
-function M.search()
- local date = nil
- local name = nil
-
- 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]
+---@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)
- vim.ui.input({ prompt = "Name: " }, function(input)
- name = input
- 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)
- -- print(date)
- -- if date then
- -- print(date.year, " ", date.month, " ", date.day)
- -- print("FSD")
- -- end
if not status then
print("Error opening file")