aboutsummaryrefslogtreecommitdiff
path: root/lua/simple-denote/api.lua
diff options
context:
space:
mode:
authorworkhorse <gravel.justness270@slmail.me>2024-06-03 16:48:36 -0400
committerworkhorse <gravel.justness270@slmail.me>2024-06-03 16:48:36 -0400
commit516bc5e46c8e8a4f63df0a21bf7efbe835bdec2a (patch)
treebca5f5d8c72b25a0db65d28f42cd3eb7bd8ef6ae /lua/simple-denote/api.lua
parent1bf7bc5b79636814db73a9148998c72fbe554d58 (diff)
downloadsimple-denote.nvim-516bc5e46c8e8a4f63df0a21bf7efbe835bdec2a.tar.gz
Fixed heading config
Diffstat (limited to 'lua/simple-denote/api.lua')
-rw-r--r--lua/simple-denote/api.lua57
1 files changed, 57 insertions, 0 deletions
diff --git a/lua/simple-denote/api.lua b/lua/simple-denote/api.lua
new file mode 100644
index 0000000..f835b7b
--- /dev/null
+++ b/lua/simple-denote/api.lua
@@ -0,0 +1,57 @@
+local M = {}
+
+local internal = require("simple-denote.internal")
+local util = require("simple-denote.util")
+
+---@param options table
+---@param name string|nil
+---@param tags table|nil
+function M.note(options, name, tags)
+ if not name then
+ vim.ui.input({ prompt = "Note title: " }, function(input)
+ name = input
+ end)
+ end
+ if not tags then
+ vim.ui.input({ prompt = "Tags: " }, function(input)
+ if input ~= "" and input then
+ tags = util.splitspace(input)
+ end
+ end)
+ end
+ internal.note(options, name, tags)
+end
+
+---@param options table
+---@param filename string|nil
+---@param new_title string|nil
+function M.retitle(options, filename, new_title)
+ if not filename then
+ filename = vim.fn.expand("%")
+ end
+ if not new_title then
+ vim.ui.input({ prompt = "New title: " }, function(input)
+ new_title = input
+ end)
+ end
+ internal.retitle(options, filename, new_title)
+end
+
+---@param options table
+---@param filename string|nil
+---@param new_tags table|nil
+function M.retag(options, filename, new_tags)
+ if not filename then
+ filename = vim.fn.expand("%")
+ end
+ if not new_tags then
+ vim.ui.input({ prompt = "New tags: " }, function(input)
+ if input ~= "" and input then
+ new_tags = util.splitspace(input)
+ end
+ end)
+ end
+ internal.retag(options, filename, new_tags)
+end
+
+return M