aboutsummaryrefslogtreecommitdiff
path: root/lua/simple-denote/cmd.lua
blob: 177db88798c70f405deee14a0c5ae037c7796a54 (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
local M = {
  commands = { "note", "retitle", "retag" },
}

local api = require("simple-denote.api")

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 M.commands
    end,
  })
end

return M