aboutsummaryrefslogtreecommitdiff
path: root/lua/simple-denote/init.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/init.lua
parent45c6c2c12f97f91d0550db2aa888f68f68116e9a (diff)
downloadsimple-denote.nvim-9831fe1ec019e07251b209e73b3258d082d0ac94.tar.gz
Refactoring, fixing edge cases
Diffstat (limited to 'lua/simple-denote/init.lua')
-rw-r--r--lua/simple-denote/init.lua23
1 files changed, 21 insertions, 2 deletions
diff --git a/lua/simple-denote/init.lua b/lua/simple-denote/init.lua
index 0d8654d..31abb58 100644
--- a/lua/simple-denote/init.lua
+++ b/lua/simple-denote/init.lua
@@ -1,15 +1,34 @@
local M = {}
-local cmd = require("simple-denote.cmd")
+local api = require("simple-denote.api")
local config = require("simple-denote.config")
+function M.load_cmd(options)
+ vim.api.nvim_create_user_command("Denote", function(opts)
+ if opts.fargs[1] == "note" then
+ api.note(options)
+ elseif opts.fargs[1] == "retitle" then
+ api.retitle(options)
+ elseif opts.fargs[1] == "retag" then
+ api.retag(options)
+ else
+ error("Unsupported operation " .. opts.fargs[1])
+ end
+ end, {
+ nargs = 1,
+ complete = function()
+ return { "note", "retitle", "retag" }
+ end,
+ })
+end
+
---@param options? table user configuration
function M.setup(options)
config.options = vim.tbl_deep_extend("force", config.defaults, options or {})
if config.options.dir:sub(-1) ~= "/" then
config.options.dir = config.options.dir .. "/"
end
- cmd.load_cmd(config.options)
+ M.load_cmd(config.options)
end
return M