aboutsummaryrefslogtreecommitdiff
path: root/lua/simple-denote/api.lua
diff options
context:
space:
mode:
authorDefaultGen <gravel.justness270@slmail.me>2024-06-04 17:13:32 -0400
committerDefaultGen <gravel.justness270@slmail.me>2024-06-04 17:13:32 -0400
commit9831fe1ec019e07251b209e73b3258d082d0ac94 (patch)
treea2443690eebb4e4a162b578f24588196f138be7c /lua/simple-denote/api.lua
parent45c6c2c12f97f91d0550db2aa888f68f68116e9a (diff)
downloadsimple-denote.nvim-9831fe1ec019e07251b209e73b3258d082d0ac94.tar.gz
Refactoring, fixing edge cases
Diffstat (limited to 'lua/simple-denote/api.lua')
-rw-r--r--lua/simple-denote/api.lua31
1 files changed, 17 insertions, 14 deletions
diff --git a/lua/simple-denote/api.lua b/lua/simple-denote/api.lua
index f835b7b..f99c21d 100644
--- a/lua/simple-denote/api.lua
+++ b/lua/simple-denote/api.lua
@@ -1,7 +1,14 @@
local M = {}
local internal = require("simple-denote.internal")
-local util = require("simple-denote.util")
+
+function M.splitspace(str)
+ local chunks = {}
+ for substring in str:gmatch("%S+") do
+ table.insert(chunks, #chunks, substring)
+ end
+ return chunks
+end
---@param options table
---@param name string|nil
@@ -14,9 +21,7 @@ function M.note(options, name, tags)
end
if not tags then
vim.ui.input({ prompt = "Tags: " }, function(input)
- if input ~= "" and input then
- tags = util.splitspace(input)
- end
+ tags = input
end)
end
internal.note(options, name, tags)
@@ -25,33 +30,31 @@ end
---@param options table
---@param filename string|nil
---@param new_title string|nil
-function M.retitle(options, filename, new_title)
+function M.retitle(options, filename, title)
if not filename then
filename = vim.fn.expand("%")
end
- if not new_title then
+ if not title then
vim.ui.input({ prompt = "New title: " }, function(input)
- new_title = input
+ title = input
end)
end
- internal.retitle(options, filename, new_title)
+ internal.retitle(options, filename, title)
end
---@param options table
---@param filename string|nil
---@param new_tags table|nil
-function M.retag(options, filename, new_tags)
+function M.retag(options, filename, tags)
if not filename then
filename = vim.fn.expand("%")
end
- if not new_tags then
+ if not tags then
vim.ui.input({ prompt = "New tags: " }, function(input)
- if input ~= "" and input then
- new_tags = util.splitspace(input)
- end
+ tags = input
end)
end
- internal.retag(options, filename, new_tags)
+ internal.retag(options, filename, tags)
end
return M